WIP: Reorganize the codebase, splitting game, render and input logic #3
Draft
Avery
wants to merge 7 commits from Avery/MineClone:master into master
Loading…
Reference in new issue
There is no content yet.
Delete Branch 'Avery/MineClone:master'
Deleting a branch is permanent. It CANNOT be undone. Continue?
PR marked as WIP since I am very much learning as I go and I expect that this first attempt needs a few time back and forth between reviews and fixes before it can be merged.
In this version, the game logic is driven by the state of the game, making it essentially a state machine. While currently there is only states for loading and InWorld, once a main menu and such is implemented, those will get their own states in the state machine, thus being able to render their own things and handle their own input. I imagine a valid and sensible flow of states could look something like this:
For further details on the reorg, see
2f15842ca4.- The state of the game is now tracked using a simple state machine, where the main struct representing the game is `Game` and its state a generic implementing `GameState` on that struct, the following states exist: - `Unstarted`: Nothing has been done yet - `RenderAvailable`: The very basic things for rendering are available (sdl context, entry, instance, device, cmdbuf, surface, etc) - `LoadingWorld`: We are loading into a world, the only thing that can be done here currently is add things to be rendered (Components) of which only the `Cube` is available, with the skybox being automaticall added. - `InWorld`: We have loaded a world and can (theoretically) render things and move about - The render logic now lives in `render/` and is split both by phase, as well as components and the swapchain having their own modules - The input logic now lives in input and constits of one trait that should be implemented for states that should handle input, and is currently capable of handling mouse movenent, key presses and keys that should be held down (ex, movement keys) - The game logic lives in `game/` and is/will be responsible for driving both the input and render modules Note: the current commit is broken, as our surface is lost when returning from `Game<Unstarted>::init_render`- `VK_ERROR_SURFACE_LOST_KHR` was caused by the sdl window being dropped, it is now kept in gamestate to prevent that - `VK_ERROR_OUT_OF_POOL_MEMORY` was caused by the descriptor pool having a hardcodes size for the number of descriptor sets instead of that number depending on the required number of sets Note: We are still broken, a window opens and controls seem to work fine, but nothing is shown in the window