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

2
.gitignore vendored
View File

@@ -2,3 +2,5 @@
*.img *.img
*.code-workspace *.code-workspace
*.zip *.zip
dino
*.code-workspace

18
.vscode/c_cpp_properties.json vendored Normal file
View File

@@ -0,0 +1,18 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/../kolibrios-nextgen/programs/develop/ktcc/trunk/libc.obj",
"/home/coder/Documents/Programming_projects/kolibrios-nextgen/programs/develop/ktcc/trunk/libc.obj/include"
],
"defines": [],
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
"cppStandard": "c++14",
"intelliSenseMode": "linux-clang-x64"
}
],
"version": 4
}

View File

@@ -1,5 +1,5 @@
KTCC_DIR = ../../develop/ktcc/trunk KTCC_DIR = ../kolibrios-nextgen/programs/develop/ktcc/trunk
KLIBC = ../../develop/ktcc/trunk/libc.obj KLIBC = $(KTCC_DIR)/libc.obj
NAME = dino NAME = dino
@@ -7,7 +7,7 @@ KTCC = $(KTCC_DIR)/bin/kos32-tcc
KPACK = kpack KPACK = kpack
SRC = $(wildcard *.c) SRC = $(wildcard *.c)
FLAGS= -B$(KTCC_DIR)/bin -I $(KLIBC)/include FLAGS= -B$(KTCC_DIR)/bin -I $(KLIBC)/include -Wall -stack=20480
LIBS = -limg LIBS = -limg
all: $(SRC) all: $(SRC)

BIN
dino

Binary file not shown.

View File

@@ -77,14 +77,14 @@ bool distanceMeterUpdate(int deltaTime, int _distance) {
bool playSound = false; bool playSound = false;
int distance = _distance; int distance = _distance;
if (!distanceMeter.achievement) { if (!distanceMeter.achievement) {
distance = distanceMeterGetActualDistance(_distance); distance = distanceMeterGetActualDistance(distance);
// check if score has gone beyond the initial digit count. // check if score has gone beyond the initial digit count.
if (distance > distanceMeter.maxScore && distanceMeter.maxScoreUnits == DM_MAX_DISTANCE_UNITS) { if (distance > distanceMeter.maxScore && distanceMeter.maxScoreUnits == DM_MAX_DISTANCE_UNITS) {
distanceMeter.maxScoreUnits++; distanceMeter.maxScoreUnits++;
distanceMeter.maxScore = distanceMeter.maxScore * 10 + 9; distanceMeter.maxScore = distanceMeter.maxScore * 10 + 9;
} }
// else { // else {
// this.distance was in original but i didsnt see any usage of this field // NOTE this.distance was in original but i didsnt see any usage of this field
// } // }
if (distance > 0) { if (distance > 0) {

3247
err.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,6 @@
#include "graphics.h" #include "graphics.h"
#include "sprites.h" #include "sprites.h"
#include <assert.h>
static ksys_colors_table_t sys_color_table; static ksys_colors_table_t sys_color_table;
static ksys_pos_t win_pos; static ksys_pos_t win_pos;
@@ -24,14 +25,75 @@ void graphicsInit() {
} }
debug_printf("spriteAtlas->Type = %d\n", spriteAtlas->Type); debug_printf("spriteAtlas->Type = %d\n", spriteAtlas->Type);
screenImage = img_create(DEFAULT_WIDTH, 200, IMAGE_BPP32); screenImage = img_create(DEFAULT_WIDTH, 200, IMAGE_BPP32);
// asm_inline("emms"); // doenst need bec. libimg functions used here does not use mmx (=> does not currept fpu state)
} }
// void save_fpu_state(void *fpustate) {
// __asm__("fsave %0" : "=m" (*fpustate) : : "memory");
// }
// void restore_fpu_state(const void *fpustate) {
// __asm__("fnsave %0" : : "m" (*fpustate));
// }
void graphicsBlitAtlasImage(int atlasX, int atlasY, int destX, int destY, int w, int h, bool center) { void graphicsBlitAtlasImage(int atlasX, int atlasY, int destX, int destY, int w, int h, bool center) {
// debug_printf("start graphicsBlitAtlasImage %d %d %d %d %d %d %x %x\n", atlasX, atlasY, destX, destY, w, h, screenImage, spriteAtlas); // debug_printf("start graphicsBlitAtlasImage ax = %d ay = %d dx = %d dy = %d w = %d h = %d %x %x\n", atlasX, atlasY, destX, destY, w, h, screenImage, spriteAtlas);
if (destX < 0 || destY < 0) {
// // asm_inline("int $3");
// if (destX < 0 || destY < 0) {
// return;
// }
// // assert(destX + w <= screenImage->Width && destY + h <= screenImage->Height);
// if (destX + w > screenImage->Width || destY + h > screenImage->Height) {
// return;
// }
int screen_width = (int)screenImage->Width;
int screen_height = (int)screenImage->Height;
if (destX >= screen_width) {
//debug_printf("dX>w!\n");
return; return;
} }
if (destY >= screen_height) {
//debug_printf("dY>h!\n");
return;
}
if (destX < 0) {
destX = 0;
w = destX + w;
}
if (destX + w > screen_width) {
w = screen_width - destX;
}
if (destY < 0) {
destY = 0;
h = destY + h;
}
if (destY + h > screen_height) {
h = screen_height - destY;
}
//printf("start graphicsBlitAtlasImage ax = %d ay = %d dx = %d dy = %d w = %d h = %d %x %x\n\n", atlasX, atlasY, destX, destY, w, h, screenImage, spriteAtlas);
// assert(destX + w <= screen_width && destY + h <= screen_height);
// assert(destX >= 0 && destY >= 0);
// asm_inline("int $3");
/*unsigned char buf[512];
save_fpu_state(buf);
img_blend(screenImage, spriteAtlas, destX, destY, atlasX, atlasY, w, h); img_blend(screenImage, spriteAtlas, destX, destY, atlasX, atlasY, w, h);
restore_fpu_state(buf);*/
img_blend(screenImage, spriteAtlas, destX, destY, atlasX, atlasY, w, h);
asm_inline("emms");
// debug_printf("end graphicsBlitAtlasImage\n\n"); // debug_printf("end graphicsBlitAtlasImage\n\n");
} }

View File

@@ -16,11 +16,19 @@ void horizonInit(int dim_width, double gapCoefficient) {
void horizonUpdate(int deltaTime, double currentSpeed, bool updateObstacles, bool showNightMode) { void horizonUpdate(int deltaTime, double currentSpeed, bool updateObstacles, bool showNightMode) {
//horizon.runningTime += deltaTime; //horizon.runningTime += deltaTime;
debug_printf("h 00 rs = %lf\n", currentSpeed);
horizonLineUpdate(deltaTime, currentSpeed); horizonLineUpdate(deltaTime, currentSpeed);
debug_printf("h 0 rs = %lf\n", currentSpeed);
// if (currentSpeed != currentSpeed) {
// currentSpeed = 6.0;
// }
// horizon.nightMode.update(showNightMode); // horizon.nightMode.update(showNightMode);
horizonUpdateClouds(deltaTime, currentSpeed); horizonUpdateClouds(deltaTime, currentSpeed);
debug_printf("h 1\n");
if (updateObstacles) { if (updateObstacles) {
debug_printf("h 02\n");
horizonUpdateObstacles(deltaTime, currentSpeed); horizonUpdateObstacles(deltaTime, currentSpeed);
debug_printf("h 2\n");
} }
} }
@@ -62,6 +70,7 @@ void horizonUpdateObstacles(int deltaTime, double currentSpeed) {
// Obstacles, move to Horizon layer // Obstacles, move to Horizon layer
Node* obNode = horizon.obstacles->head; Node* obNode = horizon.obstacles->head;
while (obNode != NULL) { while (obNode != NULL) {
debug_printf("obNode = 0x%x, currentSpeed = %lf\n", obNode, currentSpeed);
Node* obNodeNext = obNode->next; Node* obNodeNext = obNode->next;
Obstacle* ob = obNode->data; Obstacle* ob = obNode->data;
obstacleUpdate(ob, deltaTime, currentSpeed); obstacleUpdate(ob, deltaTime, currentSpeed);
@@ -76,17 +85,25 @@ void horizonUpdateObstacles(int deltaTime, double currentSpeed) {
obNode = obNodeNext; obNode = obNodeNext;
} }
debug_printf("hu 1\n");
if (ulist_size(horizon.obstacles) > 0) { if (ulist_size(horizon.obstacles) > 0) {
Obstacle *lastObstacle = horizon.obstacles->tail->data; Obstacle *lastObstacle = horizon.obstacles->tail->data;
debug_printf("hu 02\n");
if (lastObstacle && !lastObstacle->followingObstacleCreated && obstacleIsVisible(lastObstacle) && (lastObstacle->xPos + lastObstacle->width + lastObstacle->gap) < horizon.dim_width) { if (lastObstacle && !lastObstacle->followingObstacleCreated && obstacleIsVisible(lastObstacle) && (lastObstacle->xPos + lastObstacle->width + lastObstacle->gap) < horizon.dim_width) {
debug_printf("hu 02+\n");
horizonAddNewObstacle(currentSpeed); horizonAddNewObstacle(currentSpeed);
debug_printf("hu 02++\n");
lastObstacle->followingObstacleCreated = true; lastObstacle->followingObstacleCreated = true;
} }
debug_printf("hu 2\n");
} }
else { else {
// Create new obstacles. // Create new obstacles.
horizonAddNewObstacle(currentSpeed); horizonAddNewObstacle(currentSpeed);
debug_printf("hu 3\n");
} }
} }
@@ -100,6 +117,7 @@ void horizonAddNewObstacle(double currentSpeed) {
horizonAddNewObstacle(currentSpeed); horizonAddNewObstacle(currentSpeed);
} }
else { else {
debug_printf("han 0\n");
Obstacle* ob = malloc(sizeof(Obstacle)); Obstacle* ob = malloc(sizeof(Obstacle));
obstacleInit(ob, otc, horizon.dim_width, horizon.gapCoefficient, currentSpeed, otc->width); obstacleInit(ob, otc, horizon.dim_width, horizon.gapCoefficient, currentSpeed, otc->width);
ulist_push_back(horizon.obstacles, ob); ulist_push_back(horizon.obstacles, ob);
@@ -107,6 +125,7 @@ void horizonAddNewObstacle(double currentSpeed) {
if (ulist_size(horizon.obstacleHistory) > 1) { if (ulist_size(horizon.obstacleHistory) > 1) {
ulist_splice(horizon.obstacleHistory, RUNNER_MAX_OBSTACLE_DUPLICATION); ulist_splice(horizon.obstacleHistory, RUNNER_MAX_OBSTACLE_DUPLICATION);
} }
debug_printf("han 1\n");
} }
} }
@@ -114,11 +133,13 @@ bool horizonDuplicateObstacleCheck(ObstacleType nextObstacleType) {
//printf("horizonDuplicateObstacleCheck(%d)\n", nextObstacleType); //printf("horizonDuplicateObstacleCheck(%d)\n", nextObstacleType);
int duplicateCount = 0; int duplicateCount = 0;
Node* ohNode = horizon.obstacleHistory->head; Node* ohNode = horizon.obstacleHistory->head;
debug_printf("hd 0\n");
while (ohNode != NULL) { while (ohNode != NULL) {
//printf("%d\n", *(int*)ohNode->data); //printf("%d\n", *(int*)ohNode->data);
duplicateCount = *(int*)ohNode->data == nextObstacleType ? duplicateCount + 1 : 0; duplicateCount = *(int*)ohNode->data == nextObstacleType ? duplicateCount + 1 : 0;
ohNode = ohNode->next; ohNode = ohNode->next;
} }
debug_printf("hd 1\n");
//printf("duplicateCount = %d\n\n", duplicateCount); //printf("duplicateCount = %d\n\n", duplicateCount);
return duplicateCount >= RUNNER_MAX_OBSTACLE_DUPLICATION; return duplicateCount >= RUNNER_MAX_OBSTACLE_DUPLICATION;
} }

View File

@@ -39,14 +39,21 @@ void horizonLineUpdateXPos(int pos, int increment) {
} }
void horizonLineUpdate(int deltaTime, double speed) { void horizonLineUpdate(int deltaTime, double speed) {
debug_printf("hlu0 = %lf\n", speed);
int increment = floor(speed * (FPS / 1000.0) * deltaTime); int increment = floor(speed * (FPS / 1000.0) * deltaTime);
debug_printf("hlu1 = %lf\n", speed);
if (horizonLine.xPos[0] <= 0) { if (horizonLine.xPos[0] <= 0) {
horizonLineUpdateXPos(0, increment); horizonLineUpdateXPos(0, increment);
} }
else { else {
horizonLineUpdateXPos(1, increment); horizonLineUpdateXPos(1, increment);
} }
// asm_inline("int $3");
int dsddds = rand() % 1000;
double jopa = 0.34243;
debug_printf("%d %lf hlu3 = %lf\n", jopa, dsddds, speed);
horizonLineDraw(); horizonLineDraw();
debug_printf("%d %lf hlu4 = %lf\n", jopa, dsddds, speed);
} }
void horizonLineReset() { void horizonLineReset() {

14
main.c
View File

@@ -16,8 +16,6 @@
#include "trex.h" #include "trex.h"
#include "runner.h" #include "runner.h"
#pragma warning(disable:4996)
uint8_t keyboard_layout[128]; uint8_t keyboard_layout[128];
int main(int argc, char* args[]) { int main(int argc, char* args[]) {
@@ -27,14 +25,13 @@ int main(int argc, char* args[]) {
runnerInit(); runnerInit();
_ksys_debug_puts("3333333"); _ksys_debug_puts("privet!! 123");
_ksys_debug_puts("xABCDEFuuit56\n\n"); //_ksys_debug_puts("xABCDEFuuit56\n\n");
_ksys_set_event_mask(0xC0000027); // ! _ksys_set_event_mask(0xC0000027); // !
_ksys_set_key_input_mode(KSYS_KEY_INPUT_MODE_SCANC); _ksys_set_key_input_mode(KSYS_KEY_INPUT_MODE_SCANC);
_ksys_keyboard_layout(KSYS_KEYBOARD_LAYOUT_NORMAL, keyboard_layout); _ksys_keyboard_layout(KSYS_KEYBOARD_LAYOUT_NORMAL, keyboard_layout);
uint32_t kos_event;
int ext_code = 0; int ext_code = 0;
uint8_t old_mode = 0; uint8_t old_mode = 0;
@@ -42,7 +39,7 @@ int main(int argc, char* args[]) {
while (quit == false) { while (quit == false) {
int frameStartTime = getTimeStamp(); int frameStartTime = getTimeStamp();
//printf("frameStartTime = %d\n", frameStartTime); //printf("frameStartTime = %d\n", frameStartTime);
kos_event = _ksys_check_event(); uint32_t kos_event = _ksys_check_event();
switch (kos_event) { switch (kos_event) {
case KSYS_EVENT_BUTTON: case KSYS_EVENT_BUTTON:
switch (_ksys_get_button()){ switch (_ksys_get_button()){
@@ -77,9 +74,11 @@ int main(int argc, char* args[]) {
if (scancode < 128) { // KEYDOWN if (scancode < 128) { // KEYDOWN
//debug_printf("Keydown: key = 0x%x, scancode = 0x%x, code = 0x%x (%u) state = 0x%x\n", key.val, scancode, code, code, key.state); //debug_printf("Keydown: key = 0x%x, scancode = 0x%x, code = 0x%x (%u) state = 0x%x\n", key.val, scancode, code, code, key.state);
//debug_printf("keydown c = %u\n", key.code);
runnerOnKeyDown(code); runnerOnKeyDown(code);
} else { // KEYUP } else { // KEYUP
//debug_printf("Keyup: key = 0x%x, scancode = 0x%x, code = 0x%x (%u) state = 0x%x\n", key.val, scancode, code, code, key.state); //debug_printf("Keyup: key = 0x%x, scancode = 0x%x, code = 0x%x (%u) state = 0x%x\n", key.val, scancode, code, code, key.state);
//debug_printf("keyup c = %u\n", key.code);
runnerOnKeyUp(code); runnerOnKeyUp(code);
} }
} }
@@ -93,13 +92,16 @@ int main(int argc, char* args[]) {
// runnerOnKeyUp(event.key.keysym.sym & 0xFF); // runnerOnKeyUp(event.key.keysym.sym & 0xFF);
// break; // break;
case KSYS_EVENT_REDRAW: case KSYS_EVENT_REDRAW:
//debug_printf("graphicsRender\n");
graphicsRender(); graphicsRender();
break; break;
default: default:
break; break;
} }
if (runner.nextUpdateScheduled) { if (runner.nextUpdateScheduled) {
//printf("runner update! %u\n", getTimeStamp()); //printf("runner update! %u\n", getTimeStamp());
//debug_printf("runnerUpdate\n");
runnerUpdate(); runnerUpdate();
} }
else { else {

1
misc.c
View File

@@ -1,5 +1,4 @@
#include "misc.h" #include "misc.h"
#pragma warning(disable:4996)
int getRandomNumber(int _min, int _max) { int getRandomNumber(int _min, int _max) {
return rand() % (_max - _min + 1) + _min; return rand() % (_max - _min + 1) + _min;

View File

@@ -63,7 +63,8 @@ int obstacleSpritePosX[3] = { ATLAS_CACTUS_SMALL_X, ATLAS_CACTUS_LARGE_X, ATLAS_
int obstacleSpritePosY[3] = { ATLAS_CACTUS_SMALL_Y, ATLAS_CACTUS_LARGE_Y, ATLAS_PTERODACTYL_Y}; int obstacleSpritePosY[3] = { ATLAS_CACTUS_SMALL_Y, ATLAS_CACTUS_LARGE_Y, ATLAS_PTERODACTYL_Y};
void obstacleInit(Obstacle* ob, ObstacleTypeConfig *otc, int dim_width, double gapCoefficient, double speed, int opt_xOffset) { void obstacleInit(Obstacle* ob, const ObstacleTypeConfig *otc, int dim_width, double gapCoefficient, double speed, int opt_xOffset) {
debug_printf("oi 0\n");
ob->typeConfig = *otc; ob->typeConfig = *otc;
ob->gapCoefficient = gapCoefficient; ob->gapCoefficient = gapCoefficient;
ob->size = getRandomNumber(1, OBSTACLE_MAX_OBSTACLE_LENGTH); ob->size = getRandomNumber(1, OBSTACLE_MAX_OBSTACLE_LENGTH);
@@ -71,6 +72,8 @@ void obstacleInit(Obstacle* ob, ObstacleTypeConfig *otc, int dim_width, double g
ob->xPos = dim_width + opt_xOffset; ob->xPos = dim_width + opt_xOffset;
ob->yPos = 0; ob->yPos = 0;
debug_printf("oi 1\n");
// For animated obstacles // For animated obstacles
ob->currentFrame = 0; ob->currentFrame = 0;
ob->timer = 0; ob->timer = 0;
@@ -89,8 +92,12 @@ void obstacleInit(Obstacle* ob, ObstacleTypeConfig *otc, int dim_width, double g
ob->yPos = ob->typeConfig.yPos; ob->yPos = ob->typeConfig.yPos;
} }
debug_printf("oi 2\n");
obstacleDraw(ob); obstacleDraw(ob);
debug_printf("oi 3\n");
// Make collision box adjustments, // Make collision box adjustments,
// Central box is adjusted to the size as one box. // Central box is adjusted to the size as one box.
// ____ ______ ________ // ____ ______ ________
@@ -119,12 +126,16 @@ void obstacleDraw(const Obstacle *ob) {
if (ob->currentFrame > 0) { if (ob->currentFrame > 0) {
sourceX += sourceWidth*ob->currentFrame; sourceX += sourceWidth*ob->currentFrame;
} }
//debug_printf("od ax=%u, ay=%u, dx=%u, dy=%u, w=%u, h=%u\n", sourceX, obstacleSpritePosY[ob->typeConfig.type], ob->xPos, ob->yPos, sourceWidth*ob->size, sourceHeight);
graphicsBlitAtlasImage(sourceX, obstacleSpritePosY[ob->typeConfig.type], ob->xPos, ob->yPos, sourceWidth*ob->size, sourceHeight, false); graphicsBlitAtlasImage(sourceX, obstacleSpritePosY[ob->typeConfig.type], ob->xPos, ob->yPos, sourceWidth*ob->size, sourceHeight, false);
//debug_printf("od 1\n");
} }
void obstacleUpdate(Obstacle *ob, int deltaTime, double speed) { void obstacleUpdate(Obstacle *ob, int deltaTime, double speed) {
if (!ob->remove) { if (!ob->remove) {
ob->xPos -= floor(((speed + ob->typeConfig.speedOffset)*FPS/1000.)*deltaTime); double dx = floor(((speed + ob->typeConfig.speedOffset)*FPS/1000.)*deltaTime);
debug_printf("sp = %lf, ots = %lf, dx = %d, xpos = %d\n", speed, ob->typeConfig.speedOffset, (int)dx, ob->xPos - dx);
ob->xPos -= dx;//floor(((speed + ob->typeConfig.speedOffset)*FPS/1000.)*deltaTime);
} }
// Update frames // Update frames
if (ob->typeConfig.numFrames > 1) { if (ob->typeConfig.numFrames > 1) {

View File

@@ -58,7 +58,7 @@ typedef struct {
extern ObstacleTypeConfig obstacleTypeConfigs[3]; extern ObstacleTypeConfig obstacleTypeConfigs[3];
void obstacleInit(Obstacle *ob, ObstacleTypeConfig *otc, int dim_width, double gapCoefficient, double speed, int opt_xOffset); void obstacleInit(Obstacle *ob, const ObstacleTypeConfig *otc, int dim_width, double gapCoefficient, double speed, int opt_xOffset);
void obstacleDraw(const Obstacle* ob); void obstacleDraw(const Obstacle* ob);
void obstacleUpdate(Obstacle* ob, int deltaTime, double speed); void obstacleUpdate(Obstacle* ob, int deltaTime, double speed);
int obstacleGetGap(const Obstacle* ob, double gapCoefficient, double speed); int obstacleGetGap(const Obstacle* ob, double gapCoefficient, double speed);

View File

@@ -1 +0,0 @@
qemu-system-i386 -fda kolibri.img -boot a -m 512 -usbdevice tablet -drive file=fat:rw:.

1
run.sh Executable file
View File

@@ -0,0 +1 @@
qemu-system-i386 -fda kolibri.img -enable-kvm -boot a -m 512 -usbdevice tablet -drive file=fat:rw:.

View File

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

View File

@@ -27,10 +27,10 @@
#define RUNNER_MAX_CLOUDS 6 #define RUNNER_MAX_CLOUDS 6
#define RUNNER_MAX_OBSTACLE_LENGTH 3 #define RUNNER_MAX_OBSTACLE_LENGTH 3
#define RUNNER_MAX_OBSTACLE_DUPLICATION 2 #define RUNNER_MAX_OBSTACLE_DUPLICATION 2
#define RUNNER_MAX_SPEED 13 #define RUNNER_MAX_SPEED 13.0
#define RUNNER_MIN_JUMP_HEIGHT 35 #define RUNNER_MIN_JUMP_HEIGHT 35
#define RUNNER_MOBILE_SPEED_COEFFICIENT 1.2 #define RUNNER_MOBILE_SPEED_COEFFICIENT 1.2
#define RUNNER_SPEED 6 #define RUNNER_SPEED 6.0
#define RUNNER_SPEED_DROP_COEFFICIENT 3 #define RUNNER_SPEED_DROP_COEFFICIENT 3
#define RUNNER_KEYCODE_JUMP_1 82 #define RUNNER_KEYCODE_JUMP_1 82
@@ -46,6 +46,7 @@ typedef struct {
int time; int time;
int runningTime; int runningTime;
double msPerFrame; double msPerFrame;
double azazzaza; //
double currentSpeed; double currentSpeed;
// Ulist* obstacles; // Ulist* obstacles;
bool activated; bool activated;