From a74cec10c2bb142759bab5893fcb27737c4ee389 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sat, 1 Jan 2022 21:21:15 +0100 Subject: [PATCH] Add debug key --- window.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/window.c b/window.c index c26d78d..81d5c70 100644 --- a/window.c +++ b/window.c @@ -33,6 +33,9 @@ static float _cubeSize = 4.f; /* Variable d'état pour activer/désactiver la synchronisation verticale */ static int _use_vsync = 1; +/* Variable d'état pour activer/désactiver le debug */ +static int _debug = 0; + /* Grille de positions où il y aura des cubes * 0 -> Vide * 1 -> Mur @@ -190,9 +193,11 @@ void idle(void) { _herosA.z += vitesse * dt; /* Affichage Debug */ - printf("\n==== Héros A ====\n li = %d, col = %d, pos = %d\n", (int)(zA + .5f), (int)(xA + .5f), _herosA.position); - printf("zA=%f xA=%f\n", zA, xA); - printf("d=%d h=%d g=%d b=%d\n", coorDroiteA, coorHautA, coorGaucheA, coorBasA); + if(_debug) { + printf("\n==== Héros A ====\n li = %d, col = %d, pos = %d\n", (int)(zA + .5f), (int)(xA + .5f), _herosA.position); + printf("zA=%f xA=%f\n", zA, xA); + printf("d=%d h=%d g=%d b=%d\n", coorDroiteA, coorHautA, coorGaucheA, coorBasA); + } /* Anti-collision entre joueurs */ if(_herosA.position != coorJoueurA) { @@ -234,9 +239,11 @@ void idle(void) { _herosB.z += vitesse * dt; /* Affichage Debug */ - printf("==== Héros B ====\n li = %d, col = %d, pos = %d\n=================\n", (int)(zB + .5f), (int)(xB + .5f), _herosB.position); - printf("zA=%f xA=%f\n", zB, xB); - printf("d=%d h=%d g=%d b=%d\n", coorDroiteB, coorHautB, coorGaucheB, coorBasB); + if(_debug) { + printf("==== Héros B ====\n li = %d, col = %d, pos = %d\n=================\n", (int)(zB + .5f), (int)(xB + .5f), _herosB.position); + printf("zA=%f xA=%f\n", zB, xB); + printf("d=%d h=%d g=%d b=%d\n", coorDroiteB, coorHautB, coorGaucheB, coorBasB); + } /* Anti-collision entre joueurs */ if(_herosB.position != coorJoueurB) { @@ -321,6 +328,10 @@ void keyd(int keycode) { SDL_GL_SetSwapInterval(0); break; + case GL4DK_h: + _debug = !_debug; + break; + /* Héros A */ case GL4DK_RIGHT: _vkeyboard[VK_RIGHT] = 1;