minor updates
add fruit class update simple sprites include variant type
This commit is contained in:
+34
-16
@@ -21,30 +21,48 @@ void update_player_system(entt::registry& registry,float dt){
|
||||
auto view = registry.view<const Player, const Position, Velocity>();
|
||||
|
||||
// Constants for fine-tuning game feel
|
||||
const float GRAVITY = 900.0f; // Constant downward pull (pixels/sec^2)
|
||||
const float JUMP_FORCE = -350.0f; // Negative force to burst UPWARD
|
||||
// const float GRAVITY = 900.0f; // Constant downward pull (pixels/sec^2)
|
||||
// const float JUMP_FORCE = -350.0f; // Negative force to burst UPWARD
|
||||
|
||||
for (entt::entity entity : view){
|
||||
const Position& pos = view.get<Position>(entity);
|
||||
Velocity& vel = view.get<Velocity>(entity);
|
||||
const float SPEED = 350;
|
||||
|
||||
if (pos.x < -50 && vel.dx < 0){
|
||||
vel.dx *= -1;
|
||||
} else if (pos.x > (GetScreenWidth()-250) && vel.dx > 0){
|
||||
vel.dx *= -1;
|
||||
if (IsKeyPressed(KEY_W)){
|
||||
if (vel.dy > 0)
|
||||
continue;
|
||||
vel.dx = 0;
|
||||
vel.dy = -SPEED;
|
||||
|
||||
} else if (IsKeyPressed(KEY_S)){
|
||||
if (vel.dy < 0)
|
||||
continue;
|
||||
vel.dx = 0;
|
||||
vel.dy = SPEED;
|
||||
} else if (IsKeyPressed(KEY_A)){
|
||||
if (vel.dx > 0)
|
||||
continue;
|
||||
vel.dx = -SPEED;
|
||||
vel.dy = 0;
|
||||
} else if (IsKeyPressed(KEY_D)){
|
||||
if (vel.dx < 0)
|
||||
continue;
|
||||
vel.dx = SPEED;
|
||||
vel.dy = 0;
|
||||
}
|
||||
|
||||
if (IsKeyPressed(KEY_SPACE)){
|
||||
vel.dy = JUMP_FORCE;
|
||||
}
|
||||
vel.dy += GRAVITY * dt;
|
||||
// if (pos.x < -50 && vel.dx < 0){
|
||||
// vel.dx *= -1;
|
||||
// } else if (pos.x > (GetScreenWidth()-250) && vel.dx > 0){
|
||||
// vel.dx *= -1;
|
||||
// }
|
||||
|
||||
// if (IsKeyPressed(KEY_SPACE)){
|
||||
// vel.dy = JUMP_FORCE;
|
||||
// }
|
||||
// vel.dy += GRAVITY * dt;
|
||||
}
|
||||
|
||||
view.each([dt,GRAVITY,JUMP_FORCE](entt::entity entity,const Position &position, auto &velocity){
|
||||
if (position.x > 100 && position.x < 120){
|
||||
velocity.dx += 20;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user