diff options
author | BoredGuy <osome3717@gmail.com> | 2025-08-07 10:10:18 +0300 |
---|---|---|
committer | BoredGuy <osome3717@gmail.com> | 2025-08-07 10:10:18 +0300 |
commit | 251be1ac2d808dfd0fca5c0eb37398357ca7bb20 (patch) | |
tree | 4bc7ccdaee4773b1ef55ce734a40c528384d4efe /src/player.c | |
parent | 2b95f565e8b88841d20f79205ac600cc14e28458 (diff) |
Huge Commit
- Added (static)sprites
- Removed variable fps (removes wierd camera jitter)
Also I'm becoming increasingly more anti-VSync
Diffstat (limited to 'src/player.c')
-rw-r--r-- | src/player.c | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/src/player.c b/src/player.c index 6426db7..67f971f 100644 --- a/src/player.c +++ b/src/player.c @@ -1,13 +1,29 @@ +#include <stdlib.h> #include <math.h> #include "constants.h" #include "game.h" #include "player.h" #include "physics.h" +#include "assets.h" extern Game game; #define PLAYER_SPEED 300.0f +const Rectangle shadowDestRect = (Rectangle) { + .x = 0, + .y = 100, + .width = 100, + .height = 40 +}; + +const Rectangle physicsCollider = (Rectangle) { + .x = 0, + .y = 0, + .width = 100, + .height = 100 +}; + void UpdatePlayer(Entity* player, float deltaTime) { player->velocity = (Vector2) {0.0f, 0.0f}; @@ -31,7 +47,7 @@ void UpdatePlayer(Entity* player, float deltaTime) { MoveAndSlide(player, deltaTime); game.camera.target = - (Vector2) {fmax(WINDOW_WIDTH / 2.0f, player->position.x), 0.0f}; + (Vector2) {fmaxf(WINDOW_WIDTH / 2.0f, player->position.x), 0.0f}; } void AddPlayer(float xpos, float ypos) { @@ -39,13 +55,26 @@ void AddPlayer(float xpos, float ypos) { player.type = Player_Entity; player.position = (Vector2) {xpos, ypos}; - player.flags |= (ENTITY_PHYSICS_ACTIVE); + player.flags |= (ENTITY_PHYSICS_ACTIVE | ENTITY_VISIBLE); - player.physicsCollider = (Rectangle) {0, 0, 100, 100}; + player.physicsCollider = physicsCollider; #ifdef BEATEMUP_DEBUG player.physicsColliderColor = RED; #endif - + + Asset* shadowTexture = GetMatchingAssetWithType("human-shadow", Texture_Asset); + + if (shadowTexture == NULL) { + TraceLog(LOG_ERROR, "Failed to find texture asset human-shadow, exitting!"); + exit(EXIT_FAILURE); + } + + AddSpriteToEntity(&player, (Sprite){ + .texture = shadowTexture->texture, + .layer = Foreground_Layer, + .destRect = shadowDestRect + }); + AddEntity(&player); } |