fix acceleration for the quadrillionth time

This commit is contained in:
2026-06-17 11:41:54 -04:00
parent b5b2142a62
commit 7250e9c834
4 changed files with 12 additions and 17 deletions

View File

@@ -14,15 +14,13 @@ void UpdatePlayerControls(void)
return; return;
} }
if(curhorvel==0.0f){ if(curhorvel==0.0f){
curhorvel=10.0f*scale; curhorvel=65.5f*scale;
} }
// if a key pressed, push player to the left // if a key pressed, push player to the left
if (IsKeyDown(KEY_A)) if (IsKeyDown(KEY_A))
{ {
if(curhorvel<PMV){ if(curhorvel<MAX_PLAYER_SPEED){
for(int i=0; i<PLAYER_SPEED_FACTOR;i++){ curhorvel=curhorvel*PLAYER_SPEED_FACTOR;
curhorvel=curhorvel*curhorvel;
}
} }
ApplyForce( ApplyForce(
player, player,
@@ -32,10 +30,8 @@ void UpdatePlayerControls(void)
// if d key pressed, push player to the right // if d key pressed, push player to the right
else if (IsKeyDown(KEY_D)) else if (IsKeyDown(KEY_D))
{ {
if(curhorvel<=PMV){ if(curhorvel<=MAX_PLAYER_SPEED){
for(int i=0; i<PLAYER_SPEED_FACTOR;i++){ curhorvel=curhorvel*PLAYER_SPEED_FACTOR;
curhorvel=curhorvel*curhorvel;
}
} }
ApplyForce( ApplyForce(
player, player,
@@ -43,7 +39,7 @@ void UpdatePlayerControls(void)
); );
} }
else{ else{
curhorvel=10.0f*scale; curhorvel=65.5f*scale;
} }
// if sspace key pressed (and player isn't already jumping), push player // if sspace key pressed (and player isn't already jumping), push player
if (IsGrounded(player) && if (IsGrounded(player) &&

View File

@@ -6,14 +6,13 @@
const float scale = 43.7445319335f; const float scale = 43.7445319335f;
const float g = 9.81f * scale; const float g = 9.81f * scale;
const float PMV = 10000.0*scale; //Player Max Velocity const float PLAYER_SPEED_FACTOR =1.1f; //1.1 is good
const int PLAYER_SPEED_FACTOR =2; const float JUMP_FORCE = 450.0f*scale;
const float JUMP_FORCE = 300.0f*scale;
const float AIR_DRAG = 0.999f; const float AIR_DRAG = 0.999f;
const float GROUND_FRICTION = 1200.0f; const float GROUND_FRICTION = 27.432f*scale;
const float MAX_PLAYER_SPEED = 300.0f; const float MAX_PLAYER_SPEED = 10.0f*scale;
const float BOUNCE = 0.45f; const float BOUNCE = 0.45f;

View File

@@ -12,9 +12,9 @@ extern bool isSimulating;
extern float simTime; extern float simTime;
extern const float PMV; extern const float MAX_PLAYER_SPEED;
extern const int PLAYER_SPEED_FACTOR; extern const float PLAYER_SPEED_FACTOR;
void ApplyForce(Entity *e, Vector2 force); void ApplyForce(Entity *e, Vector2 force);
bool IsGrounded(Entity *e); bool IsGrounded(Entity *e);

BIN
wrldbox

Binary file not shown.