Commit Graph

102 Commits (4478a512a3a5b8d5eb49fc186ac9d97c2b4788fd)
 

Author SHA1 Message Date
En Yi 4478a512a3 Combine Component, Entity + Manager headers
It has reached a point where it is much easier to combine these three
than to separate them.
2023-05-23 20:37:55 +08:00
En Yi e1a7774bfb Replace component data struct to use array
This will use more memory from the get go. I just prefer to statically
allocate memory.
2023-05-22 21:00:50 +08:00
En Yi b0e1d33ad6 Implement player sprite info loading from file 2023-05-22 20:33:48 +08:00
En Yi 98450d0bba Rework Entity Sprite Component & Add Tile Sprite
Changelog:
- Add tile sprites as part of Level Data
- Render tile sprite if loaded in
- CSprite now stores array of sprite rendering info
    - use current idx to keep track
2023-05-20 18:23:26 +08:00
En Yi 0f485d89f2 Add assets loading from a file
Changelog:
- Add assets_loader functions from a file
- Update scene_test to use loader function
2023-05-20 16:14:39 +08:00
En Yi 57c9eb0216 Fix incorrect usage of s64 map
Changelog:
- Turns out, the map doesnt make a copy of the string for storage.
  Therefore, need to store the name somewhere before inserting into
  the map.
- Add struct for each assets to retain the name.
- Update assets functions to maintain interface
2023-05-20 16:09:00 +08:00
En Yi e9d9ffff20 Refactor implementation of Crate Entity 2023-05-16 22:14:54 +08:00
En Yi 3580209f71 Refactor out implementation of Player Entity 2023-05-16 21:55:59 +08:00
En Yi 7b3685b792 Refactor for better separation of concern
Changelog:
- Separate out engine-specific stuff vs game-specific stuff
2023-05-16 21:09:38 +08:00
En Yi ee4313adbb Add a sprite for player 2023-05-15 20:48:56 +08:00
En Yi bafb32501f Replace mempools free list data struct
Changelog:
- Use circular buffer instead of sc_queue
    - The size is already known beforehand. So circular buffer seems
      to be more appropriate
2023-05-13 15:14:05 +08:00
En Yi 64c3532305 Replace method to get Scene specific data
Changelog:
- Use CONTAINER_OF macros to get scene specific data
- Remove unnecessary scene_data from Scene_t
- Still use pointer to scene specific data as these data could be
  quite heavy on memory
2023-05-07 21:04:24 +08:00
En Yi 49b5a19cad Fix Out of buffer access in tilemap
Others:
- Change HUD BG colour to lightgray
- Use CONTAINER_OF macros to access specific scene data in editor scene
2023-05-07 19:29:35 +08:00
En Yi cd71dae730 Add camera and game viewport
Changelog:
- Add 2D camera to level scene
- Add camera update system to level systems
- Add viewport to draw the level
    - This allows larger level to fit inside the window
- Update mouse handling to account for camera and viewport
2023-05-07 19:15:15 +08:00
En Yi 7c94ecde89 Fix main program crash
Changelog:
- Init asset management and pass into scene inits
2023-05-07 16:27:14 +08:00
En Yi d4dfe01182 Slightly rework scene rendering
Changelog:
- Draw calls are now in rendering function of a scene
    - This is to allow flexibility on how a scene is rendered
- Modify level scene to render level using RenderTexture
    - This is to prepare for camera implementation later
- CloseWindow is called after all de-init functions is called
2023-05-07 16:25:03 +08:00
En Yi 9eb46d0e57 Implement ladder mechanics
Changelog:
- Change ladder to be in player state component
- Add ladder state transition
    - Hold up or down to enter ladder when overlap with ladder
    - On ground, ladder has to be on foot
    - Either jump or exit a ladder to exit ladder state
- Ignore external forces during ladder state
    - Ladder uses velocity instead of acceleration to move player
- Reduce jump speed if not on ground (such as on ladder)
- Make water transparent, finally
2023-05-06 18:39:10 +08:00
En Yi c44696c1f8 Fix ladder spawning solid issue
Changelog:
- Add checks for ladder's solidity when spawning/despawning ladders
- Move crouch state check into player movement system
- Add ladder state for later implementation
2023-05-06 12:19:15 +08:00
En Yi b9a0bfe7b1 Add ladder toggling
Changelog:
Ladder acts as one-way platform on top, not solid otherwise
2023-05-06 11:49:12 +08:00
En Yi d59c902958 Change colour of one-way platform 2023-05-04 13:27:44 +08:00
En Yi b5e7d8846f Add collision handling for one-way tile
Internal Changelog:
- Add ONEWAY handling in check_collision
- All collision check now requires a prev_position check due to the
  one-way tile check. Update relevant function signature
- On ground check now does an edge check instead of using the offset
  check
2023-05-04 12:48:32 +08:00
En Yi 36e84d1b75 Add one way tile
Changelog:
- Add new enums for tile and solidity
- Modify check_collsion_and_move function to account for one way
  collision
  - Also remove the collision value as it is not used
- Add spawning for oneway tile
2023-05-02 21:54:29 +08:00
En Yi dc760bf8db Attempt to apply code style consitency
Squashed commit of the following:

commit 249fb96c63f68913ef632b8d1006e8a2d1c1b6d3
Author: En Yi <en.yi@tutanota.com>
Date:   Sat Apr 15 22:51:08 2023 +0800

    Ensure 120 column width limit

    Changelog:
    - this is just to avoid overly long line of code

commit 4b1ffa8fc89f17418de15f5fc3f0e73040f1d40c
Author: En Yi <en.yi@tutanota.com>
Date:   Sat Apr 15 20:05:07 2023 +0800

    Ensure style consistency in For loop

commit dcb41960407224592f78278313e97c2cc4bf66a5
Author: En Yi <en.yi@tutanota.com>
Date:   Sat Apr 15 17:26:20 2023 +0800

    Ensure consistency in code style

    Internal Changelog:
    - Use char* var instead of char *var. Preference
2023-04-15 22:52:38 +08:00
En Yi 82b8a3b988 Implement simple animation system
Changelog:
- Add sprite map for player
- Add an animation system
- Add a placeholder player sprite transition function
2023-03-18 13:55:55 +08:00
En Yi ac6d93565b Add Sprite Component
Changelog:
- Move Sprite struct into components
- Add asset field in engine
- Update scene test code to add engine for assets
    - This fixes the crash when q is pressed
- Add sprite component to player
- Update render function to draw the sprite
2023-03-13 21:12:37 +08:00
En Yi 1ea1db3c60 Update the test to use the get functions 2023-03-13 20:07:52 +08:00
En Yi d01a6772ec Add convenience scripts
Changelog:
- Add build and run scripts for convenience
- Update lsan suppresion file
2023-03-11 22:50:17 +08:00
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