HATPC/engine
En Yi 41f3656ba1 Integrate Level Selection scene transition
Internal Changelog:
- Changing scene now return the scene to change into
- Set the level pack and selected level
2024-07-08 18:18:48 +08:00
..
sc Separate out engine from scenes 2023-10-13 21:26:42 +08:00
AABB.c Fix regression in AABB collision 2023-11-16 00:03:26 +08:00
AABB.h Separate out engine from scenes 2023-10-13 21:26:42 +08:00
CMakeLists.txt Add scene hierachy feature 2024-06-27 21:36:55 +08:00
EC.h Allow multi-rows sprites framing 2024-05-06 21:18:03 +08:00
README.md Add scene hierachy feature 2024-06-27 21:36:55 +08:00
actions.h Add button to toggle solid tilemap 2024-05-11 15:53:39 +08:00
assets.c Allow multi-rows sprites framing 2024-05-06 21:18:03 +08:00
assets.h Integrate 'pro' version of sprite drawing 2024-05-01 12:23:31 +08:00
collisions.c Rework the offset collision checking 2024-04-22 22:42:32 +08:00
collisions.h Add neighbour solid counts 2024-05-06 22:04:53 +08:00
engine.c Integrate Level Selection scene transition 2024-07-08 18:18:48 +08:00
engine.h Integrate Level Selection scene transition 2024-07-08 18:18:48 +08:00
engine_conf.h Continue plan data struct for scene management 2024-06-20 21:41:14 +08:00
entManager.c Change to manual init for entity tag map 2023-11-11 11:14:22 +08:00
gui.c Encapsulate scroll area as UI component 2024-07-08 18:02:56 +08:00
gui.h Encapsulate scroll area as UI component 2024-07-08 18:02:56 +08:00
mempool.c Add function to get number of free entities 2024-04-22 22:52:59 +08:00
mempool.h Add function to get number of free entities 2024-04-22 22:52:59 +08:00
particle_sys.c Use float for timing in particle system 2024-04-24 21:47:58 +08:00
particle_sys.h Use float for timing in particle system 2024-04-24 21:47:58 +08:00
raygui.h Integrate scroll bar to level select 2024-07-08 12:40:27 +08:00
rres.c Use unsigned int for rres Id as per the struct 2023-11-11 13:04:24 +08:00
rres.h Use unsigned int for rres Id as per the struct 2023-11-11 13:04:24 +08:00

README.md

I suppose need to write these down to remind myself

Scene Management

The engine provides a generic Scene struct that should be embedded in a another struct, which provide scene-specific data.

As such, the engine will manage pointers to Scene struct. When using the engine, it is expected to provide the a pointer to the embedded Scene struct to the engine for scene management. All scenes should be declared upfront and an array of the Scene pointers should be provided.

What is a scene?

A scene is a data struct containing these major fields:

  1. Entity Manager
  2. Input-Action Map
  3. Systems
  4. Particle System
  5. plus other fields

These fields exists to perform the scene update loop of:

  1. Input handling
  2. Scene Update
  3. Scene Rendering

Scene State

In this implementation, there will always be a 'root' scene at any given time. The program ends if there is no 'root' scene. A scene change/transition occurs when this 'root' scene is changed to another scene.

A scene has an active state and a render state.

  • Active: Should it run its scene update procedures?
  • Render: Should it be render? Hence, it is possible to have a scene updated but hidden, or a paused scene (not updated but rendered).

There is also a 'focused' scene. This is the scene to intercept inputs and run its action update procedure. There can only be at most one such scene. Two or more scenes are not allowed to receive inputs in this implementation. It is possible to have zero focused scene.

Scene Hierachy

A scene can have multiple children scenes but can have only one parent scene. This implemented as a intrusive linked-list.

The implementation assumes a single-threaded environment for simplicity. The scene update travesal logic is as such:

  1. The current scene first
  2. If the scene has a child scene, traverse that child first.
  3. If the scene has a next scene, traverse there then.
  4. Repeat from (1) until no possible scene is traversable