HandmadeHero/project/handmade.hpp

176 lines
2.7 KiB
C++
Raw Normal View History

2023-09-26 14:26:35 -07:00
#pragma once
2023-10-06 23:33:39 -07:00
#if INTELLISENSE_DIRECTIVES
2023-09-26 14:26:35 -07:00
#include "engine/engine.hpp"
2023-10-06 23:33:39 -07:00
#endif
2023-09-26 14:26:35 -07:00
2023-09-28 10:44:43 -07:00
#define NS_HANDMADE_BEGIN namespace hh {
2023-09-26 14:26:35 -07:00
#define NS_HANDMADE_END }
NS_HANDMADE_BEGIN
struct Memory
{
// Subscection of engine memory for the game to use.
void* persistent;
2023-10-11 14:52:13 -07:00
ssize persistent_size;
2023-09-26 14:26:35 -07:00
// void* Frame;
// u64 FrameSize;
void* transient;
2023-10-11 14:52:13 -07:00
ssize transient_size;
2023-10-11 14:52:13 -07:00
ssize total_size()
{
return persistent_size + transient_size;
}
2023-09-26 14:26:35 -07:00
};
// We want a 'binding' to have multiple binds to active it (most likely)
struct Actionable
{
char const* name;
engine::InputBindCallback* binds;
s32 num_binds;
2023-09-26 14:26:35 -07:00
};
struct ActionableMode
{
};
/*
Platform Layer:
Controller : Keyboard & Mouse, XPad, DSPad
---VV---
Engine Layer:
InputBinding callbacks (per-game-logic frame basis)
Push/Pop input modes (binding sets)
---VV---
Game Layer:
Actionables : Binding Sets where a raw input, or input interpretation leads to an player action.
ActionSet : Actionables.Push/Pop -> Input.Push/Pop ?
Player : Controller, Actionables, ActionSets
*/
struct ControllerState
2023-09-26 14:26:35 -07:00
{
s32 xpad_id;
s32 ds_pad_id;
engine::KeyboardState* keyboard;
engine::MousesState* mouse;
engine::XInputPadState* xpad;
engine::DualsensePadState* ds_pad;
};
2023-12-29 22:45:48 -08:00
enum EFacingDirection : u32
{
2023-12-29 22:45:48 -08:00
FacingDirection_Front,
FacingDirection_Back,
FacingDirection_Left,
FacingDirection_Right
};
enum EEntityKind : u32
{
EntityKind_Hero,
};
struct HeroBitmaps
{
using Bitmap = engine::Bitmap;
s32 align_x;
s32 align_y;
2023-09-26 14:26:35 -07:00
Bitmap head;
Bitmap cape;
Bitmap torso;
2023-09-26 14:26:35 -07:00
};
struct Entity
2023-09-28 10:44:43 -07:00
{
2023-12-29 22:45:48 -08:00
EEntityKind kind;
b32 exists;
2023-10-04 10:55:15 -07:00
f32 width;
f32 height;
2023-12-29 22:45:48 -08:00
EFacingDirection facing_direction;
engine::TileMapPos position;
Vel2 velocity;
};
2023-10-11 14:52:13 -07:00
struct PlayerState
{
b32 mid_jump;
f32 jump_time;
};
struct PlayerActions
{
s32 player_x_move_digital;
s32 player_y_move_digital;
f32 player_x_move_analog;
f32 player_y_move_analog;
2023-09-28 10:44:43 -07:00
2023-10-11 14:52:13 -07:00
b32 sprint;
b32 jump;
b32 join;
2023-09-28 10:44:43 -07:00
};
struct Player
2023-10-21 19:21:53 -07:00
{
// So far just has an assigned controller.
ControllerState controller;
2023-12-29 22:45:48 -08:00
s32 entity_id;
PlayerState state;
// TODO(Ed) : If the player ever gets different actions depending on a context, change it here.
PlayerActions actions;
2023-10-21 19:21:53 -07:00
};
2023-10-06 10:06:40 -07:00
struct GameState
{
Entity entities[256];
Player player_1;
Player player_2;
2023-12-31 23:53:15 -08:00
engine::TileMapPos spawn_pos;
// PlayerState player_state;
// PlayerState player_state_2;
2023-10-21 19:21:53 -07:00
2023-10-20 20:15:35 -07:00
using Bitmap = engine::Bitmap;
2023-10-21 19:21:53 -07:00
2023-10-20 20:15:35 -07:00
Bitmap debug_bitmap;
Bitmap test_bg;
Bitmap mojito;
Bitmap mojito_head;
2023-10-21 19:21:53 -07:00
2023-10-20 20:15:35 -07:00
Bitmap test_bg_hh;
2023-10-21 19:21:53 -07:00
// TODO(Ed) : Allow splitscreen?
s32 camera_assigned_entity_id;
engine::TileMapPos camera_pos;
2023-10-21 19:21:53 -07:00
HeroBitmaps hero_bitmaps[4];
2023-10-06 10:06:40 -07:00
};
2023-09-26 14:26:35 -07:00
NS_HANDMADE_END
2023-10-06 23:33:39 -07:00