|
- #ifndef IZ_APP_H
- #define IZ_APP_H
-
- #include <SDL.h>
- #include <libwebsockets.h>
- #include "input/IZ_input.h"
- #include "output/IZ_video.h"
- #include "memory/IZ_pool.h"
- #include "net/svc/IZ_wsclient.h"
-
- typedef enum {
- IZ_APP_RUN_RESULT_OK,
- IZ_APP_RUN_SDL_INIT_ERROR,
- IZ_APP_RUN_VIDEO_INIT_ERROR,
- IZ_APP_RUN_INPUT_INIT_ERROR,
- IZ_APP_RUN_POOL_INIT_ERROR,
- IZ_APP_RUN_NETWORKING_ERROR,
- } IZ_AppRunResult;
-
- typedef struct {
- IZ_InputState input_state;
- IZ_VideoState video_state;
- IZ_Pool pool;
-
- IZ_WSClientState client;
- SDL_Thread* client_thread;
- u64 ticks;
- } IZ_App;
-
- typedef struct {
- u8 player_index: 3;
- u8 player_state: 5;
- u16 action_set;
- } IZ_AppPlayerActionSyncMessage;
-
- typedef struct {
- u8 player_index: 3;
- f32 x;
- f32 y;
- f32 right;
- f32 up;
- } IZ_AppPlayerState;
-
- typedef enum {
- IZ_MESSAGE_KIND_ACTION_SYNC = 0,
- IZ_MESSAGE_KIND_STATE_SYNC = 1,
- } IZ_MessageKind;
-
- typedef struct {
- u8 message_kind; // player
- u64 client_elapsed_time; // for synchronization
- } IZ_AppMessageHeader;
-
- typedef struct {
- u8 player_actions_count;
- IZ_AppPlayerActionSyncMessage player_actions[];
- } IZ_AppPlayerActionSection;
-
- typedef struct {
- IZ_AppMessageHeader header;
- IZ_AppPlayerActionSection player_actions;
- } IZ_AppActionSyncMessage;
-
- typedef struct {
- IZ_AppMessageHeader header;
- IZ_AppPlayerState player_state[IZ_PLAYERS];
- IZ_AppPlayerActionSection player_actions;
- } IZ_AppStateSyncMessage;
-
- IZ_ProcedureResult IZ_AppRun(IZ_App*, u8, const char**);
-
- #endif
|