diff options
| author | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2024-08-24 19:11:26 -0700 |
|---|---|---|
| committer | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2024-08-24 19:16:22 -0700 |
| commit | a0a2068b66204d7d06eb3c3b4aa61b28469121f6 (patch) | |
| tree | e9706970af1ce8b4d12df9c0a3f64fa17ca74b97 /static/src/event.ts | |
| parent | b144ad5df76e458297bd6dc030cad4af0f344901 (diff) | |
| download | kennel.hatecomputers.club-a0a2068b66204d7d06eb3c3b4aa61b28469121f6.tar.gz kennel.hatecomputers.club-a0a2068b66204d7d06eb3c3b4aa61b28469121f6.zip | |
improve event parsing and begin sending events from the client
Diffstat (limited to 'static/src/event.ts')
| -rw-r--r-- | static/src/event.ts | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/static/src/event.ts b/static/src/event.ts new file mode 100644 index 0000000..cd50122 --- /dev/null +++ b/static/src/event.ts @@ -0,0 +1,28 @@ +export enum EventType { + INITIAL_STATE = "INITIAL_STATE", + SET_CONTROLLABLE = "SET_CONTROLLABLE", + ENTITY_BORN = "ENTITY_BORN", + ENTITY_DEATH = "ENTITY_DEATH", + ENTITY_POSITION_UPDATE = "ENTITY_POSITION_UPDATE", +} + +export interface Event { + event_type: EventType; + data: any; +} + +export interface InitialStateEvent extends Event { + event_type: EventType.INITIAL_STATE; + data: { + world: { width: number; height: number }; + entities: any[]; + }; +} + +export interface SetControllableEvent extends Event { + event_type: EventType.SET_CONTROLLABLE; + data: { + id: string; + client_id: string; + }; +} |
