Commit Graph

439 Commits (979533092ef2edd949675db16eb8a4ae5cf5a361)
 

Author SHA1 Message Date
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
En Yi f7057bd56c Implement jumps in water
Changelog:
- Map space to jumping
- Allow jumps in water but lowered speed and with cooldown
- Update out<->in water transition logic and jumps handling
  - Out->in water: if player center is in water
  - In->out water: if player bbox is not in water
- Apply upthrust conditionally in water
2022-12-29 11:21:10 +08:00
En Yi b5da3f216c Implement anchoring for bbox shifting
Changelog:
- Add function to calculate offset needed to maintain anchor when
  changing bbox size
- Simplify down bbox changing for player
- Some minor fix from last commit
2022-12-28 17:36:07 +08:00
En Yi c6ed46c6e7 Refactor out bounding box handling
Changelog:
- Make bbox handling a separate system
- Simplify crouch handling
- Remove grid update system as it is not useful
  - As there is too many factors influencing the grid positioning,
    it is not useful to pre-store the grids to check, might as
    well compute it during checks
  - Remove tilecoords component
2022-12-28 10:54:06 +08:00
En Yi 64466128bc Implement water tiles and movement
Changelog:
- Adjust Gravity and movement accelaration
- Replace friction with acceleration instead of fractions of velocity
- Add upthrust in water
- Cut movement acceleration in water
2022-12-27 13:16:05 +08:00
En Yi a057835e65 Refactor some constants
Changelog:
- Define constants and use them in scene_impl
- Simplify jump handling when transit from ground->air
- Add some comments
2022-12-22 23:53:18 +08:00
En Yi 68586cd1d2 Add crouching to player
Changelog:
- Add player state component to keep track of crouching
- Add crouch key handling
- Crouch mechanics:
  - Reduce vertical bbox, slightly stretch horizontally
  - Offset position to be on ground
  - Reverse for un-crouching
  - Can jump out of a crouch, reverting the bbox
  - Dont allow un-crouch if there is something overhead (maybe should
    check directly overhead, instead of a full overhead?)
  - Above also apply for jump out of crouch
2022-12-21 23:40:10 +08:00
En Yi bf94a71f9d Refactor some systems
Changelog:
- Just break down bigger system so that they are manageable
- Move collision helper functions
2022-12-18 15:45:22 +08:00
En Yi 2c17b44b40 Add system to toggle blocks for testing
Changelog:
- Add system to toggle block
- Show the number of entities on blocks too
2022-12-18 14:34:50 +08:00
En Yi a4f4e2b170 Properly implement jump system
Changelog:
- Add Jump component
- Implement single jump and short hop
2022-12-17 15:45:41 +08:00
En Yi e665664316 Add simple jumping and gravity
Changelog:
- Combine player collision handling with screen bounce
- Add simple single jump
- Remove ceilf and just remove the -1 to achieve the same effect in
  broad-phase grid check
- Clip out small velocities
- Adjust general movement and friction
2022-12-17 12:59:51 +08:00
En Yi df0e0b39c8 Fix bug on collision system
Changelog:
- Fix missing grid check in broad-phase collision check due to
  float truncation. Use ceilf to fix this
- Cover a potential edge case of equal prev overlap. In this case,
  use min overlap.
- Recompute acceleration for player every start of frame.
- Add gravity for testing
2022-12-17 10:58:37 +08:00
En Yi 15a5f7c180 Implement narrow-phase collision detection
Changelog:
- Implement AABB collision detection and resolution
  - Resolve based on previous overlap
- Fix off-by-one error in broad-phase grid collision detection
- Update drawing function
2022-12-16 14:55:26 +08:00
En Yi 0daa45f7a1 Add simple friction 2022-12-15 23:09:29 +08:00
En Yi aa2125c8f6 Improve board-phase collision
Changelog:
- Rework tile movement update logic to be general
- Increase tilemap and player size for testing
2022-12-15 22:46:25 +08:00
En Yi 03b602de40 Implement broad-phase collision system
Changelog:
- Implement grid system
- Update screen bounce scene test
- Add grid movement update system
- Add component to track occupied grid tiles
2022-12-15 16:24:13 +08:00
En Yi 905f0d70a6 Small optimisation for key handling
Changelog:
- Use a single queue to handle pressed keys
- Remove unused printf for key presses
2022-12-13 00:10:40 +08:00
En Yi 3e6a53b097 Fix incorrect player input processing
Changelog:
- Store player dir input in LevelScene Data instead of pointer,
  to avoid use-after-free (non-fatal as mempool is used, but can cause
  unintended behaviour)
- Only process player movement in system update. This is done in the
  movement update system
- Normalise before apply acceleration, duh
2022-12-12 20:29:51 +08:00
En Yi 3a99dafcd4 Implement key controls to scene
Changelog:
- Add double buffer to handle key presses and release
- Add more actions
- Update action mapping of level scene
- Implement action function for level scene
- Remove action queue for Scene struct. This is handled by raylib
  and the game engine
- Update scene struct with action function field
2022-12-11 14:32:26 +08:00
En Yi b05dfe6fde Improve scene testing
Internal Changelog:
- Implement scene boundary bounce system (subject to change)
- Add tilemap in preparation for collision system
- Allow early exit of scene testing
2022-12-11 10:34:06 +08:00
En Yi e20b020829 Rewrite mempools to be scalable
Changelog:
- Rewrite the Mempool Struct to be generic enough
- Static alloc for components mempool and entities mempool
- Component mempool now uses the component enum as index
- Update all mempool functions to work with the new struct
2022-12-05 13:02:34 +08:00
En Yi b392e462b7 Implement test scene
Internal Changelog:
- Update BBox component to use Vector2
- Add new CTransform component
- Implement level scene movement system and render system
- Implement scene test procedure
2022-12-05 12:20:00 +08:00
En Yi 6c03078db9 Implement Scene and Level Scene
Changelog:
- Add actions and assets headers, not implemented and not used
- move original main to entManager_test
- Add proper main to create window and display nothing
- Implement scene base class and level scene
- Add a simple level scene test
- Update CMakeLists to compile main and tests
2022-12-03 13:46:24 +08:00
En Yi 4a926f8c53 Implement tag on entities
Internal Changelog:
- Use data store similar to component map
- Add init and free for entities tag
- Use enum instead of char for tag
- Switch to use clang for compilation
- Add -Wall for compilation
2022-11-26 23:27:45 +08:00
En Yi f90ef7eee4 Adjust function parameters input 2022-11-26 20:49:16 +08:00
En Yi 17aae0617c First Commit of HATPC remake
Internal Changelog:
- Implement Basic ECS
- Tag system not yet implemented
- Use SC for common data structures
2022-11-26 18:11:51 +08:00