add score
This commit is contained in:
+2
-2
@@ -16,8 +16,8 @@ float accu = 0;
|
|||||||
void cinematic_staticRender(void) {
|
void cinematic_staticRender(void) {
|
||||||
RenderObject_t AdamesLegend;
|
RenderObject_t AdamesLegend;
|
||||||
strcpy(AdamesLegend.name, "Adame's Legend");
|
strcpy(AdamesLegend.name, "Adame's Legend");
|
||||||
SDL_Color black = {255, 255, 255, 255};
|
SDL_Color white = {255, 255, 255, 255};
|
||||||
text_renderText(&AdamesLegend, 8, 0.8f, black, "./assets/fonts/Quinquefive.ttf", 40, "Adame est l'eleve modele de Polytech,\n Membre de plusieurs associations il est connu de tous.\n Lors de l'edition 21.2 de la Nantarena,\n Adame s'est retrouve a engeuler des joueurs pour leur demander de mettre leur putain de masque.\n\n L'edition finie, Adame a kidnappe l'ensemble des joueurs qui forcaient pour leur apprendre a respecter l'autorite a coup de coup de pied au cul.");
|
text_renderText(&AdamesLegend, 8, 0.8f, white, "./assets/fonts/Quinquefive.ttf", 40, "Adame est l'eleve modele de Polytech,\n Membre de plusieurs associations il est connu de tous.\n Lors de l'edition 21.2 de la Nantarena,\n Adame s'est retrouve a engeuler des joueurs pour leur demander de mettre leur putain de masque.\n\n L'edition finie, Adame a kidnappe l'ensemble des joueurs qui forcaient pour leur apprendre a respecter l'autorite a coup de coup de pied au cul.");
|
||||||
scene_addRenderObject(&cinematicScene, AdamesLegend, 10, 80);
|
scene_addRenderObject(&cinematicScene, AdamesLegend, 10, 80);
|
||||||
|
|
||||||
music = Mix_LoadMUS("./assets/music/chinese rap.mp3");
|
music = Mix_LoadMUS("./assets/music/chinese rap.mp3");
|
||||||
|
|||||||
+32
-8
@@ -3,6 +3,7 @@
|
|||||||
#include <SDL2/SDL_mixer.h>
|
#include <SDL2/SDL_mixer.h>
|
||||||
#include <SDL2/SDL_surface.h>
|
#include <SDL2/SDL_surface.h>
|
||||||
#include "scaller.h"
|
#include "scaller.h"
|
||||||
|
#include "text.h"
|
||||||
|
|
||||||
#define SPEED 1.f/10000000000
|
#define SPEED 1.f/10000000000
|
||||||
#define GRAVITY 10000.f
|
#define GRAVITY 10000.f
|
||||||
@@ -24,6 +25,8 @@ static float personPositionY = startPersonPositionY;
|
|||||||
static const float personVelocityX = 200;
|
static const float personVelocityX = 200;
|
||||||
static float personVelocityY = 0;
|
static float personVelocityY = 0;
|
||||||
|
|
||||||
|
float jetons = 0.f;
|
||||||
|
|
||||||
|
|
||||||
static void playMusic(){
|
static void playMusic(){
|
||||||
music = Mix_LoadMUS("./assets/music/jojo arab.mp3");
|
music = Mix_LoadMUS("./assets/music/jojo arab.mp3");
|
||||||
@@ -32,12 +35,12 @@ static void playMusic(){
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Mix_PlayMusic(music, 0) != 0){
|
// if(Mix_PlayMusic(music, 0) != 0){
|
||||||
printf("Music sound could not be played!\n"
|
// printf("Music sound could not be played!\n"
|
||||||
"SDL_Error: %s\n", Mix_GetError());
|
// "SDL_Error: %s\n", Mix_GetError());
|
||||||
Mix_FreeMusic(music);
|
// Mix_FreeMusic(music);
|
||||||
running = false;
|
// running = false;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
int game_staticRender(void){
|
int game_staticRender(void){
|
||||||
@@ -93,19 +96,29 @@ int game_render([[maybe_unused]] float delta){
|
|||||||
person.surface = personSurface;
|
person.surface = personSurface;
|
||||||
person.width = 0.25f;
|
person.width = 0.25f;
|
||||||
scaller(person.surface, 0.05f, &person.width, &person.height);
|
scaller(person.surface, 0.05f, &person.width, &person.height);
|
||||||
// if(!crashed && deltaAccu >= SPEED && isSpaceKeypressed){
|
|
||||||
if(!crashed && isSpaceKeypressed){
|
if(!crashed && isSpaceKeypressed){
|
||||||
personPositionX += personVelocityX * delta;
|
const float distance = personVelocityX * delta;
|
||||||
|
personPositionX += distance;
|
||||||
gameScene.x = personPositionX - startPersonPositionX;
|
gameScene.x = personPositionX - startPersonPositionX;
|
||||||
|
|
||||||
personVelocityY += GRAVITY * delta;
|
personVelocityY += GRAVITY * delta;
|
||||||
|
|
||||||
personPositionY += personVelocityY * delta;
|
personPositionY += personVelocityY * delta;
|
||||||
if(personPositionY + CAMERA_HEIGHT * person.height >= CAMERA_HEIGHT - 2) crashed = true;
|
if(personPositionY + CAMERA_HEIGHT * person.height >= CAMERA_HEIGHT - 2) crashed = true;
|
||||||
|
|
||||||
|
jetons += distance;
|
||||||
}
|
}
|
||||||
menuObjects[menuObjectsSize] = scene_addRenderObject(&gameScene, person, personPositionX, personPositionY);
|
menuObjects[menuObjectsSize] = scene_addRenderObject(&gameScene, person, personPositionX, personPositionY);
|
||||||
++menuObjectsSize;
|
++menuObjectsSize;
|
||||||
|
|
||||||
|
|
||||||
|
RenderObject_t scoreText;
|
||||||
|
strcpy(scoreText.name, "scoreText");
|
||||||
|
SDL_Color black = {0, 0, 0, 255};
|
||||||
|
text_renderText(&scoreText, 50, 0.5f, black, "./assets/fonts/Quinquefive.ttf", 40, "jetons: %d", (unsigned)jetons);
|
||||||
|
menuObjects[menuObjectsSize] = scene_addRenderObject(&gameScene, scoreText, gameScene.x + 2, 0);
|
||||||
|
++menuObjectsSize;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,5 +130,16 @@ void game_remove(void){
|
|||||||
|
|
||||||
|
|
||||||
void game_handleSpaceKeyInput(void){
|
void game_handleSpaceKeyInput(void){
|
||||||
|
if(crashed){
|
||||||
|
crashed = false;
|
||||||
|
personPositionX = startPersonPositionX;
|
||||||
|
personPositionY = startPersonPositionY;
|
||||||
|
personVelocityY = 0;
|
||||||
|
isSpaceKeypressed = false;
|
||||||
|
gameScene.x = 0;
|
||||||
|
gameScene.y = 0;
|
||||||
|
}
|
||||||
|
else{
|
||||||
isSpaceKeypressed = true;
|
isSpaceKeypressed = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user