HandmadeHero/project/handmade.hpp

157 lines
2.4 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
*/
#if NEW_INPUT_DESIGN
struct ControllerState
2023-09-26 14:26:35 -07:00
{
engine::KeyboardState* keyboard;
engine::MousesState* mouse;
engine::XInputPadState* xpad;
engine::DualsensePadState* ds_pad;
};
#endif
enum EHeroBitmapsDirection : u32
{
HeroBitmaps_Front,
HeroBitmaps_Back,
HeroBitmaps_Left,
HeroBitmaps_Right
};
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
};
2023-09-28 10:44:43 -07:00
struct PlayerState
{
2023-10-04 10:55:15 -07:00
f32 width;
f32 height;
engine::TileMapPos position;
2023-10-28 14:10:30 -07:00
Vel2 move_velocity;
2023-10-11 14:52:13 -07:00
b32 mid_jump;
f32 jump_time;
EHeroBitmapsDirection hero_direction;
};
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
{
#if NEW_INPUT_DESIGN
// So far just has an assigned controller.
ControllerState controller;
#else
engine::ControllerState* controller;
#endif
2023-10-21 19:21:53 -07:00
PlayerState state;
2023-10-21 19:21:53 -07:00
};
2023-10-06 10:06:40 -07:00
struct GameState
{
Player player_1;
Player player_2;
2023-10-06 10:06:40 -07:00
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
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