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.
|
|
|
|
|
2023-09-30 07:05:37 -07:00
|
|
|
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;
|
|
|
|
|
2023-09-30 07:05:37 -07:00
|
|
|
void* transient;
|
2023-10-11 14:52:13 -07:00
|
|
|
ssize transient_size;
|
2023-09-30 07:05:37 -07:00
|
|
|
|
2023-10-11 14:52:13 -07:00
|
|
|
ssize total_size()
|
2023-09-30 07:05:37 -07:00
|
|
|
{
|
|
|
|
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
|
|
|
|
{
|
2023-09-30 07:05:37 -07:00
|
|
|
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
|
|
|
|
*/
|
|
|
|
|
2023-12-29 16:21:44 -08:00
|
|
|
struct ControllerState
|
2023-09-26 14:26:35 -07:00
|
|
|
{
|
2023-12-29 19:50:22 -08:00
|
|
|
s32 xpad_id;
|
|
|
|
s32 ds_pad_id;
|
|
|
|
|
2023-12-29 16:21:44 -08:00
|
|
|
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 16:21:44 -08:00
|
|
|
{
|
2023-12-29 22:45:48 -08:00
|
|
|
FacingDirection_Front,
|
|
|
|
FacingDirection_Back,
|
|
|
|
FacingDirection_Left,
|
|
|
|
FacingDirection_Right
|
|
|
|
};
|
|
|
|
|
|
|
|
enum EEntityKind : u32
|
|
|
|
{
|
|
|
|
EntityKind_Hero,
|
2023-12-29 16:21:44 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct HeroBitmaps
|
|
|
|
{
|
|
|
|
using Bitmap = engine::Bitmap;
|
|
|
|
|
|
|
|
s32 align_x;
|
|
|
|
s32 align_y;
|
2023-09-26 14:26:35 -07:00
|
|
|
|
2023-12-29 16:21:44 -08:00
|
|
|
Bitmap head;
|
|
|
|
Bitmap cape;
|
|
|
|
Bitmap torso;
|
2023-09-26 14:26:35 -07:00
|
|
|
};
|
|
|
|
|
2023-12-29 19:50:22 -08:00
|
|
|
struct Entity
|
2023-09-28 10:44:43 -07:00
|
|
|
{
|
2023-12-29 22:45:48 -08:00
|
|
|
EEntityKind kind;
|
|
|
|
|
2023-12-29 19:50:22 -08:00
|
|
|
b32 exists;
|
|
|
|
|
2023-10-04 10:55:15 -07:00
|
|
|
f32 width;
|
|
|
|
f32 height;
|
2023-12-29 19:50:22 -08:00
|
|
|
|
2023-12-29 22:45:48 -08:00
|
|
|
EFacingDirection facing_direction;
|
|
|
|
|
2023-10-22 18:52:41 -07:00
|
|
|
engine::TileMapPos position;
|
2023-12-30 12:25:58 -08:00
|
|
|
Vel2 velocity;
|
2023-12-29 19:50:22 -08:00
|
|
|
};
|
2023-10-11 14:52:13 -07:00
|
|
|
|
2023-12-29 19:50:22 -08:00
|
|
|
struct PlayerState
|
|
|
|
{
|
2023-09-30 07:05:37 -07:00
|
|
|
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;
|
2023-12-29 16:21:44 -08:00
|
|
|
|
|
|
|
b32 join;
|
2023-09-28 10:44:43 -07:00
|
|
|
};
|
|
|
|
|
2023-12-29 16:21:44 -08:00
|
|
|
struct Player
|
2023-10-21 19:21:53 -07:00
|
|
|
{
|
2023-12-29 16:21:44 -08:00
|
|
|
// So far just has an assigned controller.
|
|
|
|
ControllerState controller;
|
2023-12-29 19:50:22 -08:00
|
|
|
|
2023-12-29 22:45:48 -08:00
|
|
|
s32 entity_id;
|
|
|
|
PlayerState state;
|
2023-12-29 19:50:22 -08:00
|
|
|
|
|
|
|
// 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
|
|
|
|
{
|
2023-12-29 19:50:22 -08:00
|
|
|
Entity entities[256];
|
|
|
|
|
2023-12-29 16:21:44 -08:00
|
|
|
Player player_1;
|
|
|
|
Player player_2;
|
2023-12-31 23:53:15 -08:00
|
|
|
|
|
|
|
engine::TileMapPos spawn_pos;
|
2023-12-29 16:21:44 -08:00
|
|
|
|
2023-12-29 19:50:22 -08: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
|
|
|
|
2023-12-29 19:50:22 -08:00
|
|
|
// TODO(Ed) : Allow splitscreen?
|
|
|
|
s32 camera_assigned_entity_id;
|
2023-10-22 18:52:41 -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
|
|
|
|