open-card-table/oct_termbox_sprite.h

51 lines
1.3 KiB
C
Raw Normal View History

2023-01-06 19:12:24 -05:00
#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>
2023-01-06 19:12:24 -05:00
#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
2023-01-06 19:12:24 -05:00
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 {
2023-01-06 19:12:24 -05:00
// Array of pointers to oct_tb_sprites
struct oct_tb_sprite** sprite_list;
uint32_t new_index;
uint32_t size;
uint8_t initialized;
};
2023-01-06 19:12:24 -05:00
// Forward declarations of global variables
extern struct otsl oct_tb_sprite_list;
extern struct luaL_Reg oct_tb_sprite_metamethods[];
2023-01-06 19:12:24 -05:00
// Functions
int oct_tb_sprite_list_initialize();
int oct_tb_sprite_list_deinitialize();
2023-01-06 19:12:24 -05:00
// 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);
void oct_tb_initialize_lua(lua_State *L);
2023-01-06 19:12:24 -05:00
#endif