feely_pona/feely_pona_game.h

172 lines
5.4 KiB
C
Raw Normal View History

#if defined(__clang__)
#pragma once
#include "feely_pona_unity.h"
#endif
enum TELY_EntityFlag
{
TELY_EntityFlag_Clickable = 1 << 0,
TELY_EntityFlag_MoveByKeyboard = 1 << 1,
TELY_EntityFlag_MoveByMouse = 1 << 2,
TELY_EntityFlag_DrawHitBox = 1 << 3,
TELY_EntityFlag_DeriveHitBoxFromChildrenBoundingBox = 1 << 4,
};
enum TELY_GameShapeType
{
TELY_GameShapeType_None,
TELY_GameShapeType_Circle,
TELY_GameShapeType_Rect,
TELY_GameShapeType_Line,
};
struct TELY_GameShape
{
TELY_GameShapeType type;
Dqn_V2 p1;
Dqn_V2 p2;
Dqn_V4 colour;
Dqn_f32 line_thickness;
Dqn_f32 circle_radius;
TELY_RenderShapeMode render_mode;
};
const uint64_t TELY_GAME_ENTITY_HANDLE_GENERATION_MASK = 0xFFFF'0000'0000'0000;
const uint64_t TELY_GAME_ENTITY_HANDLE_GENERATION_RSHIFT = 48;
const uint64_t TELY_GAME_ENTITY_HANDLE_GENERATION_MAX = TELY_GAME_ENTITY_HANDLE_GENERATION_MASK >> TELY_GAME_ENTITY_HANDLE_GENERATION_RSHIFT;
const uint64_t TELY_GAME_ENTITY_HANDLE_INDEX_MASK = 0x0000'FFFF'FFFF'FFFF;
const uint64_t TELY_GAME_ENTITY_HANDLE_INDEX_MAX = TELY_GAME_ENTITY_HANDLE_INDEX_MASK - 1;
struct TELY_GameEntityHandle
{
uint64_t id;
};
enum TELY_GameEntityState
{
TELY_GameEntityState_Nil,
TELY_GameEntityState_Idle,
TELY_GameEntityState_Attack,
TELY_GameEntityState_Run,
};
struct TELY_GameEntityAnimation
{
uint16_t index;
uint16_t frame;
uint16_t ticks;
uint16_t ticks_per_frame;
};
struct TELY_GameWaypoint
{
Dqn_V2I pos;
TELY_GameWaypoint *next;
TELY_GameWaypoint *prev;
};
struct TELY_GameEntity
{
Dqn_String8 name;
TELY_GameEntityHandle handle;
TELY_AssetSpriteSheet *sprite_sheet;
Dqn_Slice<TELY_AssetSpriteAnimation> sprite_anims;
Dqn_V2 size_scale;
TELY_GameEntityAnimation anim;
TELY_GameEntityState state;
Dqn_V2 velocity;
TELY_GameEntityHandle stalk_entity;
Dqn_V2I stalk_entity_last_known_tile;
TELY_GameWaypoint *waypoints;
// NOTE: The entity hit box is positioned at the center of the entity.
Dqn_V2 local_hit_box_size;
Dqn_V2 local_hit_box_offset;
Dqn_V2 attack_box_size;
Dqn_V2 attack_box_offset;
uint64_t flags;
bool facing_left;
Dqn_V2 local_pos;
Dqn_f64 alive_time_s;
Dqn_FArray<TELY_GameShape, 4> shapes;
TELY_GameEntity *next;
TELY_GameEntity *prev;
TELY_GameEntity *first_child;
TELY_GameEntity *last_child;
TELY_GameEntity *parent;
};
struct TELY_GameEntityIterator
{
bool init;
Dqn_usize iteration_count;
TELY_GameEntity *entity;
TELY_GameEntity *last_visited;
TELY_GameEntity *entity_parent;
TELY_GameEntity *entity_next;
TELY_GameEntity *entity_first_child;
};
struct TELY_FreyaGameMath
{
TELY_GameEntityHandle lec01_group_box;
TELY_GameEntityHandle lec01_axis;
TELY_GameEntityHandle lec01_point_a;
TELY_GameEntityHandle lec01_point_b;
TELY_GameEntityHandle lec01_task01_group_box;
TELY_GameEntityHandle lec01_task01_radial_trigger;
Dqn_f32 lec01_task01_radial_trigger_radius;
TELY_GameEntityHandle lec01_task01_player;
TELY_GameEntityHandle lec01_task02_group_box;
TELY_GameEntityHandle lec01_task02_ray_begin;
TELY_GameEntityHandle lec01_task02_ray_end;
TELY_GameEntityHandle lec01_task02_surface;
};
struct TELY_GameCamera
{
Dqn_V2 world_pos;
Dqn_f32 rotate_rads;
Dqn_V2 scale;
};
struct TELY_Game
{
TELY_Platform *platform;
TELY_RFui rfui;
TELY_UI ui;
TELY_ChunkPool chunk_pool;
TELY_AssetFontHandle inter_regular_font;
TELY_AssetFontHandle inter_italic_font;
TELY_AssetFontHandle jetbrains_mono_font;
TELY_AssetAudioHandle test_audio;
Dqn_Slice<TELY_AssetSpriteAnimation> hero_sprite_anims;
TELY_AssetSpriteSheet hero_sprite_sheet;
Dqn_FArray<TELY_GameEntityHandle, 8> parent_entity_stack;
Dqn_VArray<TELY_GameEntity> entities;
TELY_GameEntity *root_entity;
TELY_GameEntity *entity_free_list;
TELY_GameEntityHandle clicked_entity;
TELY_GameEntityHandle hot_entity;
TELY_GameEntityHandle active_entity;
TELY_GameEntityHandle prev_clicked_entity;
TELY_GameEntityHandle prev_hot_entity;
TELY_GameEntityHandle prev_active_entity;
TELY_FreyaGameMath freya_game_math;
TELY_GameCamera camera;
};