Merge branch 'master' of ssh.marcbarbier.fr:Marc/gamejam-polytech
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 = EMPTY_RENDER_OBJECT;
|
RenderObject_t AdamesLegend = EMPTY_RENDER_OBJECT;
|
||||||
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");
|
||||||
|
|||||||
+50
-12
@@ -4,12 +4,11 @@
|
|||||||
#include <SDL2/SDL_surface.h>
|
#include <SDL2/SDL_surface.h>
|
||||||
#include "scaller.h"
|
#include "scaller.h"
|
||||||
#include "scene.h"
|
#include "scene.h"
|
||||||
|
#include "text.h"
|
||||||
|
|
||||||
#define SPEED 1.f/10000000000
|
#define SPEED 1.f/10000000000
|
||||||
#define GRAVITY 10000.f
|
#define GRAVITY 10000.f
|
||||||
|
|
||||||
static RenderId_t menuObjects[10];
|
|
||||||
static unsigned menuObjectsSize = 0;
|
|
||||||
static Mix_Music * music;
|
static Mix_Music * music;
|
||||||
|
|
||||||
Scene_t gameScene;
|
Scene_t gameScene;
|
||||||
@@ -25,8 +24,12 @@ 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 RenderObject_t person;
|
static RenderObject_t person;
|
||||||
static RenderId_t personId;
|
static RenderId_t personId;
|
||||||
|
RenderObject_t scoreText;
|
||||||
|
static RenderId_t scoreTextId = -1;
|
||||||
|
|
||||||
static void playMusic(){
|
static void playMusic(){
|
||||||
music = Mix_LoadMUS("./assets/music/jojo arab.mp3");
|
music = Mix_LoadMUS("./assets/music/jojo arab.mp3");
|
||||||
@@ -35,12 +38,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){
|
||||||
@@ -81,6 +84,13 @@ int game_staticRender(void){
|
|||||||
scaller(person.surface, 0.05f, &person.width, &person.height);
|
scaller(person.surface, 0.05f, &person.width, &person.height);
|
||||||
personId = scene_addRenderObject(&gameScene, person, personPositionX, personPositionY);
|
personId = scene_addRenderObject(&gameScene, person, personPositionX, personPositionY);
|
||||||
|
|
||||||
|
scoreText = EMPTY_RENDER_OBJECT;
|
||||||
|
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);
|
||||||
|
scoreTextId = scene_addRenderObject(&gameScene, scoreText, gameScene.x + 2, 0);
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,34 +98,62 @@ int game_render([[maybe_unused]] float delta){
|
|||||||
//for(unsigned i = 0; i < menuObjectsSize; ++i){
|
//for(unsigned i = 0; i < menuObjectsSize; ++i){
|
||||||
// scene_removeRenderObject(&gameScene, menuObjects[i]);
|
// scene_removeRenderObject(&gameScene, menuObjects[i]);
|
||||||
//}
|
//}
|
||||||
menuObjectsSize = 0;
|
// if(scoreTextId > 0)
|
||||||
|
// scene_removeRenderObject(&gameScene, scoreTextId);
|
||||||
|
|
||||||
|
|
||||||
deltaAccu += delta;
|
deltaAccu += delta;
|
||||||
|
|
||||||
|
|
||||||
// if(!crashed && deltaAccu >= SPEED && isSpaceKeypressed){
|
// 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;
|
jetons += distance;
|
||||||
|
scene_moveRenderObject(&gameScene, scoreTextId, gameScene.x + 2, 0);
|
||||||
|
|
||||||
|
if(personPositionY + CAMERA_HEIGHT * person.height >= CAMERA_HEIGHT - 2){
|
||||||
|
crashed = true;
|
||||||
|
scene_removeRenderObject(&gameScene, scoreTextId);
|
||||||
|
SDL_Color black = {0, 0, 0, 255};
|
||||||
|
text_renderText(&scoreText, 50, 0.5f, black, "./assets/fonts/Quinquefive.ttf", 40, "jetons: %d", (unsigned)jetons);
|
||||||
|
scoreTextId = scene_addRenderObject(&gameScene, scoreText, gameScene.x + 2, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scene_moveRenderObject(&gameScene, personId, personPositionX, personPositionY);
|
scene_moveRenderObject(&gameScene, personId, personPositionX, personPositionY);
|
||||||
|
|
||||||
|
|
||||||
|
// scoreTextId = scene_addRenderObject(&gameScene, scoreText, gameScene.x + 2, 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void game_remove(void){
|
void game_remove(void){
|
||||||
scene_free(&gameScene);
|
scene_free(&gameScene);
|
||||||
Mix_FreeMusic(music);
|
Mix_FreeMusic(music);
|
||||||
menuObjectsSize = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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;
|
||||||
|
scene_moveRenderObject(&gameScene, scoreTextId, gameScene.x + 2, 0);
|
||||||
|
}
|
||||||
|
else{
|
||||||
isSpaceKeypressed = true;
|
isSpaceKeypressed = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user