API
This is part of a series on how this game was implemented technically, as part of the Game Jam it was developed for. It is recommended to read them roughly in-order as later blog entries may refer to earlier ones.
Technical:
- State Machine
- Pathfinding/Movement
- Isometric Rendering
- API
- Control Sources
- AI
- Networking
- Fog of War
- Bit Packing
- Palette Shifting
Other:
----
API layer
To ensure the code doesn't devolve into too much spaghetti, the game is split logically into 4 main components:
- [GAME] = holds the actual characters, movement grid, attack grid, etc
- [API] = mutates the GAME state, has functions for select Idle (x,y), select Move (destination x,y, path), select Target (target x,y)
- [UI] = given a sate, handles user input (by calling the api function) and draws to the screen
- splash screen
- select characters
- select map
- state idle
- state movement
- state targeting
- [components] = generic game components that are used by the UI states
- Renderer = draws & loads sprites/images
- Network = sends packs
- Isometric = does transforms on grid coordinates
- Audio = plays sound
- Text = renders text
- Script = shows a cutscene
- Animator* = draws an animation
* the animation class is unique in that it works asynchronously. It uses promises with async/await.
Layout
The below diagram shows roughly how these components all work together
The user only interacts with a UI component, directed by the main update/draw loop
These then filter down through the API before eventually getting to the actual game state.
By moving up/down UI layers, the player can see menus or do different in-game actions, without needing to worry about how the game state is managed. Additionally, animations and cutscenes can be triggered anywhere, and will intercept the update() loop, and we can be sure the game state is never accidentally affected downstream.
------
diagram Update loop switch (current component) draw() update() ui_splash.draw() │ │ ui_splash.update(mouse input) │ │ ┌─────────────┐ ┌────────────────────┐ ├─────┼─────── unless Animation running, then: │ │ │ │ │ │ │ │ ◄────┤ │ │ │ play anim │ │ GAME │ │ API │ │ │ play script │ │ │ │ │ │ │ │ └─────────────┘ └────────────────────┘ │ │ │ ▲ │ │ │ │ ┌──────────────┐ ┌─────────────────────┐ │ │ │ │ │ │ │ ├───────────────┤ ui splash │ │ Renderer │ │ │ │ │ │ │ │ │ └────────┬─────┘ │ Audio │ │ │ │ │ │ │ │ ┌────────▼─────┐ │ Network │ │ │ │ │ │ │ │ ├───────────────┤ ui character │ │ Isometric │ │ │ │ │ │ │ │ │ └────────┬─────┘ │ Animations─────────┼───┘ │ │ │ │ │ │ ... │ │ Script ────────────┼───┘ │ ┌────────▼─────┐ │ │ │ │ │ │ Text │ └───────────────┤ ui target │ │ │ │ │ │ │ └──────────────┘ └─────────────────────┘
Geefest-Tactics
Game created for Geekfest Game Jam 2022
Status | Released |
Author | stales |
Genre | Strategy |
Tags | Strategy RPG, Tactical, Tactical RPG, Turn-based Strategy |
More posts
- Scrapped IdeasJul 08, 2022
- PortraitsJul 08, 2022
- Palette ShiftingJul 08, 2022
- Bit PackingJul 08, 2022
- Fog of WarJul 08, 2022
- NetworkingJul 08, 2022
- AIJul 08, 2022
- Control SourcesJul 08, 2022
- Isometric RenderingJul 08, 2022
Leave a comment
Log in with itch.io to leave a comment.