cleanup
This commit is contained in:
parent
30734885e4
commit
b2c0eaf30b
3 changed files with 6 additions and 34 deletions
|
|
@ -18,13 +18,11 @@ s16 shotClock;
|
|||
fix32 screenX;
|
||||
|
||||
fix32 playerSpeed;
|
||||
fix32 playerVelX; // Track actual X velocity for momentum
|
||||
fix32 playerVelX;
|
||||
|
||||
static void movePlayer(){
|
||||
// Y-axis stays instant
|
||||
player.vel.y = 0;
|
||||
|
||||
// Determine target X speed based on input
|
||||
fix32 targetVelX = 0;
|
||||
if(ctrl.left || ctrl.right || ctrl.up || ctrl.down){
|
||||
if(ctrl.b){
|
||||
|
|
@ -37,12 +35,10 @@ static void movePlayer(){
|
|||
targetVelX = ctrl.left ? -playerSpeed : playerSpeed;
|
||||
}
|
||||
|
||||
// Y velocity (instant)
|
||||
if(ctrl.up) player.vel.y = -playerSpeed;
|
||||
else if(ctrl.down) player.vel.y = playerSpeed;
|
||||
}
|
||||
|
||||
// Apply acceleration toward target X velocity
|
||||
if(playerVelX < targetVelX){
|
||||
playerVelX += ctrl.b ? PLAYER_ACCEL_FOCUS : PLAYER_ACCEL;
|
||||
if(playerVelX > targetVelX) playerVelX = targetVelX;
|
||||
|
|
@ -53,17 +49,14 @@ static void movePlayer(){
|
|||
|
||||
player.vel.x = playerVelX;
|
||||
|
||||
// Normalize if diagonal
|
||||
if(player.vel.x != 0 && player.vel.y != 0){
|
||||
player.vel.x = fix32Mul(player.vel.x, FIX32(0.707));
|
||||
player.vel.y = fix32Mul(player.vel.y, FIX32(0.707));
|
||||
}
|
||||
|
||||
// Apply movement (always, for momentum to work during deceleration)
|
||||
player.pos.x += player.vel.x;
|
||||
player.pos.y += player.vel.y;
|
||||
|
||||
// Update facing direction when moving horizontally
|
||||
if(ctrl.a){
|
||||
SPR_setHFlip(player.image, player.shotAngle != 0);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue