open-card-table/oct_termbox_sprite.h

55 lines
1.5 KiB
C

#ifndef OCT_TERMBOX_SPRITE_H
#define OCT_TERMBOX_SPRITE_H
#include <string.h>
#include <stdint.h>
#include <stdio.h>
#include <lua5.3/lualib.h>
#include <lua5.3/lauxlib.h>
#include "termbox.h"
#define OCT_MAX_SPRITE_SIZE 101
#define OCT_INITIAL_NUM_SPRITES 100
#define OCT_SPRITE_LIST_REALLOC_LENGTH 100
#define OCT_SPRITE_MEMBER_NAME_MAXLENGTH 10
#define OCT_SPRITE_PRINT_BUFFER_SIZE 1024
#define OCT_OUT_OF_SCREEN 1000
struct oct_tb_sprite {
int x;
int y;
uintattr_t fg;
uintattr_t bg;
char shape[OCT_MAX_SPRITE_SIZE];
};
// This could technically be anonymous
// but I don't know the syntax for anonymous global struct variables
struct otsl {
// Array of pointers to oct_tb_sprites
struct oct_tb_sprite** sprite_list;
uint32_t new_index;
uint32_t size;
uint8_t initialized;
};
// Forward declarations of global variables
extern struct otsl oct_tb_sprite_list;
extern struct luaL_Reg oct_tb_sprite_metamethods[];
// Functions
int oct_tb_sprite_list_initialize();
int oct_tb_sprite_list_deinitialize();
// No functionality to remove sprites (just draw offscreen)
int oct_tb_sprite__index(lua_State *L);
int oct_tb_sprite__newindex(lua_State *L);
int oct_tb_sprite__tostring(lua_State *L);
int oct_tb_sprite_new(lua_State *L);
int oct_tb_sprite_new_uninit(lua_State *L);
void oct_tb_initialize_lua(lua_State *L);
// Points lua's oct_tb_sprite_new from C's oct_tb_sprite new to C's
// oct_tb_sprite_new_uninit, which just prints a warning
void oct_tb_change_oct_tb_sprite_new(lua_State *L);
#endif