Commit Graph

275 Commits (a8e0d99870260d83e08e9865d48e04703a3c8fa5)
 

Author SHA1 Message Date
En Yi 340d507f14 Implement assets and assets management
Internal Changelog:
- Use string-int mapping for assets tracking
- static alloc assets (so there is a hard limit for now)
- Add simple assets test code
- Implement functions to load in assets
- Current assets:
    - Texture + Sprites
    - Sound
    - Font
2023-03-11 16:02:47 +08:00
En Yi 92cb1855ba Increase player hitbox size 2023-03-06 20:42:30 +08:00
En Yi ddcb71ed50 Temp fix for 'crate super jump'
Changelog:
- Override jump height instead to adding to it
- This is pretty fun exploit though
2023-03-04 11:32:02 +08:00
En Yi 0a5eb36c34 Refactor bbox edge checking as a function 2023-03-04 10:46:22 +08:00
En Yi 8ae647994a Improve collision resolution for velocity
Changelog:
- Dont zero velocity on detected collision
- Velocity is zerod post-movement by checking the edges. This is in
  contrast with zeroing acceleration pre-movement
2023-03-04 10:24:25 +08:00
En Yi 45972d6416 Slow down player when crouching
Changelog:
- Add friction coefficient to transform component and its update system
2023-03-04 09:36:26 +08:00
En Yi 8d94943547 (Temporary) Fix corner collision issue
Changelog:
- When player move diagonally into a corner, collision is missing.
  This is because collision is resolved one-by-one and will not
  move the player if the new position still causes collision. In this
  literal corner case, player will not be moved as the player collide
  with both solids and resolving in either direction would still result
  in collision in the new position, unless both is resolved at the same
  time.
  Temporary 'fix' this by not checking the new position. No real idea
  on how to solve this for now.
2023-02-28 20:56:54 +08:00
En Yi c8ea03359c Prevent crate bashing at the corner
Changelog:
- Allow two hitboxes in hitbox component
- Create a cross-shaped hitboxes for player
2023-02-28 20:54:48 +08:00
En Yi 22b4190947 Refactor collision function signature 2023-02-25 11:54:43 +08:00
En Yi df66b7d9a3 Fix regression in lower velocity in water
Changelog:
- Revert jumped check for short hopping. Without it, the check will pass
  when player is in water
2023-02-23 20:53:12 +08:00
En Yi 95c4b98879 Remove some questionable code
Changelog:
- Don't shorten overlap, that is already done on position after
  movement update
- Don't extend tile when updating tile coord
2023-02-18 15:27:04 +08:00
En Yi a8567e2666 Implement hitbox and hurtbox system
Changelog:
- Add new components: hitbox and hurtbox
- Update player and crates with hitbox and hurtbox
- Add printing of mempool stats
- FIX CRITICAL BUG: use entity idx when removing from component map
    - Previously, it incorrectly uses the component idx
- Check for entity aliveness before removal and collision checks
- KWOWN ISSUE: Player can get stopped by metal crates when walking on
  them
2023-02-16 22:44:05 +08:00
En Yi b06d25f328 Implement metal crates
Changelog:
- Collision functions now accepts the entity idx to exclude
- Fix tile update system to enter ent idx as both key and value to
  tile's entities set
- Re-Introduce regression:
    - Player can walk across crates without them
    - This is re-introduce by ground check only checking for solid bbox
    - Without this, metal crates will sink into crates as they are not
      considered on ground
    - To properly solve this, need a hitbox on the player, which
      requires a new component
2023-02-15 22:35:11 +08:00
En Yi cf38949956 Fix jump spam and recovery
Changelog:
- Hold to jump is removed. Need to release jump action to recover jump
- Fix jump recovery issue when interacting with crates and ground
2023-02-14 23:05:31 +08:00
En Yi 399c78c200 Implement basic scene switching
Changelog:
- Add confirm and exit actions
    - Exit action used in editor scene
    - Confirm action for menu scene
- Hardcode scene switching in editor and menu scene
- Implement scene change function
    - Scene is not resetted on switch
- Incorporate scene switchin into main function
2023-02-13 23:05:24 +08:00
En Yi 1612b4f648 Refactor and prepare for scene changing
Changelog:
- Rename scene.* to engine.* as the game engine is tied to the
  base scene struct
- Combine *_impl.h into a single header
- Rename scene implementation source code file
- Add GameEngine struct and SceneState enum
2023-02-12 23:30:55 +08:00
En Yi c5937694e9 Implement keyboard controls in UI
Changelog:
- Add one more button for testing
- Add up and down actions
- Seperate out mouse mode and keyboard mode
    - Enter mouse mode by moving mode
    - Enter keyboard mode by keyboard input
- May need an action to detect mouse movement
- Add logic to cycle menu options
2023-02-12 14:51:47 +08:00
En Yi e2eb787a8b Move buttons into menu scene data 2023-02-12 12:14:57 +08:00
En Yi 9106899c8a Remove unused components 2023-02-11 22:12:17 +08:00
En Yi 9d959bad07 Add simple button for menu testing
Changelog:
- Incorporate raygui
    - raygui works but I would prefer to separate out detection logic
      and rendering. So, adapt the original code for this
- ECS is not suitable for raygui (at least at this scale)
    - It is more trouble than it is worth
- Implement simple menu test scene with two buttons
    - They do nothing
2023-02-11 20:51:01 +08:00
En Yi 68e8f7bf1c Allow jumping in one tile gaps
Changelog:
- With the change in bbox shifting, jumping in gaps is possible
2023-02-04 22:52:04 +08:00
En Yi 8606b595ab Add scene test for 16 pixels size tiles
Changelog:
- Add new compile profile for 16 pixels size tilemap
- Make game scene init less hardcoded
2023-02-04 22:31:28 +08:00
En Yi e465b0c1d4 Zero out accel for contacts in y-direction 2023-02-04 17:37:07 +08:00
En Yi e4018f1ad6 Fix edge case in handling horizontal movement
Changelog:
- Zero out acceleration when colliding with solid tile or strong entities
- This is to prevent continuous overlap after a single collision
  horizontally, similar to the gravity handling
2023-02-04 17:22:01 +08:00
En Yi 0165016a7c Refactor collision event to be LevelSceneData 2023-02-04 16:17:15 +08:00
En Yi c2bf930059 Fix player collision with crates
Changelog:
- Check for collision before moving
- Refactor out collision check and move function
- Remove anchor check when shifting bbox as it is unneccesary
- Collision checking will check for tiles and entities
2023-02-04 16:00:37 +08:00
En Yi c5c9b84154 Fix bbox shifting when resizing
Changelog:
- Check for collision before shifting bbox
- This fix the odd bbox shifting when exiting water
- Hack a way to force crouch when exiting water
2023-02-04 12:24:50 +08:00
En Yi 2e9fadb79f Rework forcing crouch on ground
Changelog:
- Change to check the player 'head' for collision to force crouch
2023-02-02 23:11:19 +08:00
En Yi dc24f17925 Fix jumping issue when exitting water
Changelog:
- Jump is not recovered when exiting water on ground. Fix by doing a
  ground check to recover a jump when exiting water
- Disable crouching when not on ground
- Slightly refactor crouch handling
2023-02-01 21:02:43 +08:00
En Yi e2ae30e45e Prepare for menu scene implementation
Changelog:
- Add components:
  - selectable : indicate an entity is selectable
  - selection : indicate an entity has a list of choices
- Add menu scene implementation and test
- Reduce repetition in CMakeLists in specifying libraries
2023-01-31 21:17:11 +08:00
En Yi 896a23fb5c Improve crate bashing
Changelog:
- Use fragile property to destroy the crates
2023-01-30 20:51:53 +08:00
En Yi 5ddb9f00ca Fix bugs related to entity with water
Changelog:
- Fix edge case where jumps are not recovered consistently when
  exitting out of water and immediately landing
- Fix friction not applied to crates (and other entities)
2023-01-21 15:38:24 +08:00
En Yi 0966c3ce29 Allow modular jump on crate bounce 2023-01-21 11:36:47 +08:00
En Yi 87b2db4ea4 Refactor AABB functions 2023-01-21 11:12:06 +08:00
En Yi 9223dcc0e9 Refactor out game systems for scene 2023-01-21 10:44:02 +08:00
En Yi e1cbce2703 Make a directory for ECS
Changelog:
- Move Entity and Component files into a dedicated folder
- This is for clean up
2023-01-21 09:38:14 +08:00
En Yi 53f281d31d Add crate bounce and destroying
Changelog:
- Add map to collect collision events
- Resolve collision events after the solid entity resolving
- Bounce player on collision with crates and destroy crates
- Add fragile field under bbox component. This makes it such that an
  entity can push others away (solid) but still apply gravity (fragile)
    - Ground check requires solid and not fragile bbox
    - This basically allow player to 'pass through' crates as crates
      are fragile but solid
2023-01-19 20:43:41 +08:00
En Yi fa58a3239c Improve collision and render functions
Changelog:
- Render entity after tile, display numbers after entity
- Add array to avoid re-checking collision against the same entity
- Increase maximum entity
2023-01-17 19:30:08 +08:00
En Yi a485922d5d Fix crouch regression on low ceiling
Changelog:
- Fix crouch not holding when ceiling is too low for uncrouch
  - This is due to a removal of the check for low ceiling. However,
    the current state of the crouch action needs to be stored.
    So, use second bit of the is_crouch for this in player state.
- Remove bit fields in player state. Optimise later if need be
- Draw entities over tiles, and gridlines over entities
  - This is to prevent water covering the entities
  - rework this in the future maybe
2023-01-15 00:14:24 +08:00
En Yi 6fc2317647 Add entity<->entity collision checks
Changelog:
- Add solid field in bbox component
- Ground check now checks for solid entities
- Reset acceleration after movement update
- Crates are considered solid
- Print info on spawning entities and spawned entities
2023-01-13 21:13:39 +08:00
En Yi 0b342bb9be Implement Crates
Changelog:
- Add new component: container
- Add function to spawn a crate
- Refactor player spawning into level scene init
- Modify tile collision to work on bbox components
- Add actions to switch entity to spawn
- Update spawn system to spawn a crate
2023-01-10 21:24:50 +08:00
En Yi af080dbdc8 Add compile target without Address Sanitizer
Changelog:
- This is to check static memory usage
2023-01-10 20:22:47 +08:00
En Yi 85915d363c Refactor movement states
Changelog:
- Refactor ground and water state as a separate component
- Refactor upthrust and gravity calc. as a separate system targetting
  the new component
- General modification to use the new component
2023-01-09 21:00:30 +08:00
En Yi 68bb9f941c Move fields to player state component
Changelog:
- Move level scene data related to player to playerstate component
- Update system related to player state to use the playerstate
  component
2023-01-05 21:55:25 +08:00
En Yi 25870309c0 Update Entity Manager component management
Changelog:
- Store entity idx for component map as key. This allows reference
  to the entity for related components in a system
- Modify systems to iterate over components instead following the
  above change. This follows closer to the intended ECS architecture
2023-01-05 21:09:06 +08:00
En Yi 3c02068ca6 Fix jump not decremented in air
Changelog:
- Remove jumps when transition from ground to air as well
- Use half size at approriate places
2023-01-03 22:41:54 +08:00
En Yi 0169a90ee8 Generalise movement update system
Changelog:
- Apply gravity and upthrust to all entities
- Refactor out state transition update check as a separate system
2023-01-03 21:58:06 +08:00
En Yi b2a5e29ce4 Rework water, ground, and air state transition
Changelog:
- Move ground and water states into CTransform
- Update state in movement update system
- Use 2 bits to check state transition for water and ground
2023-01-03 21:16:52 +08:00
En Yi 1ba786a91e Re-add back TileComponent
Changelog:
- Remember the purpose of this component, which is to assist
  updating which tiles is containing the entity
2023-01-03 19:41:07 +08:00
En Yi 5b3da5c94f Improve and fix up mempool
Changelog:
- Fix incorrect queue size init in mempool
- Replace map with boolean array for use list which is much simpler
- Remove unused component mempool
2022-12-30 17:51:05 +08:00