fixed doubles becoming nan (was fpu corruption), some render fixes

This commit is contained in:
rgimad
2025-01-05 21:11:58 +03:00
parent 2173fc2774
commit b5dbcecfac
17 changed files with 3410 additions and 24 deletions

View File

@@ -1,12 +1,14 @@
#include "runner.h"
int aaaaaaa[10000];
Runner runner;
int bbbbbb[10000];
void runnerInit() {
runner.distanceRan = 0;
runner.highestScore = 0;
runner.time = 0;
runner.msPerFrame = 1000 / FPS;
runner.msPerFrame = 1000.0 / FPS;
runner.currentSpeed = RUNNER_SPEED;
runner.activated = false;
runner.playing = false;
@@ -63,7 +65,8 @@ void runnerOnKeyDown(int key) {
// Speed drop, activated only when jump key is not pressed.
trexSetSpeedDrop();
}
else if (!trex.jumping && !trex.ducking) {
//else if (!trex.jumping &&!trex.ducking) {
else if (!trex.ducking) {
// Duck
trexSetDuck(true);
}
@@ -109,10 +112,14 @@ void runnerUpdate() {
//printf("runnerUpdate() %d\n", getTimeStamp());
runnerClearCanvas();
debug_printf("t 0\n");
if (trex.jumping) {
trexUpdateJump(deltaTime);
}
debug_printf("t 1\n");
runner.runningTime += deltaTime;
bool hasObstacles = runner.runningTime > RUNNER_CLEAR_TIME;
@@ -124,16 +131,22 @@ void runnerUpdate() {
// The horizon doesn't move until the intro is over.
if (runner.playingIntro) {
debug_printf("t 02 rs = %lf\n", runner.currentSpeed);
horizonUpdate(0, runner.currentSpeed, hasObstacles, false);
debug_printf("t 2\n");
}
else {
deltaTime = !runner.activated ? 0 : deltaTime;
debug_printf("t 03 rs = %lf\n", runner.currentSpeed);
horizonUpdate(deltaTime, runner.currentSpeed, hasObstacles, runner.inverted);
debug_printf("t 3\n");
}
// Check for collisions.
bool collision = hasObstacles && runnerCheckForCollision(horizon.obstacles->head->data);
debug_printf("t 4\n");
if (!collision) {
runner.distanceRan += runner.currentSpeed * deltaTime / runner.msPerFrame;
@@ -143,10 +156,13 @@ void runnerUpdate() {
}
else {
runnerGameOver();
debug_printf("t 5\n");
}
bool playAchievementSound = distanceMeterUpdate(deltaTime, (int)ceil(runner.distanceRan));
debug_printf("t 6\n");
if (playAchievementSound) {
//this.playSound(this.soundFx.SCORE); // TODO
}