Merge branch 'master' of ssh.marcbarbier.fr:Marc/gamejam-polytech
This commit is contained in:
+1
-1
@@ -22,7 +22,7 @@ void cinematic_staticRender(void) {
|
||||
|
||||
music = Mix_LoadMUS("./assets/music/chinese rap.mp3");
|
||||
if(music == NULL) {
|
||||
fprintf(stderr, "Prout not found!\n");
|
||||
fprintf(stderr, "Chinese rap not found!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
+54
-12
@@ -3,6 +3,8 @@
|
||||
#include <SDL2/SDL_image.h>
|
||||
#include <SDL2/SDL_mixer.h>
|
||||
#include <SDL2/SDL_surface.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include "scaller.h"
|
||||
#include "scene.h"
|
||||
#include "text.h"
|
||||
@@ -17,7 +19,7 @@ Scene_t gameScene;
|
||||
static bool isSpaceKeypressed = false;
|
||||
static float deltaAccu = 0;
|
||||
static bool crashed = false;
|
||||
static const float startPersonPositionX = CAMERA_WIDTH * 0.23f;
|
||||
static const float startPersonPositionX = CAMERA_WIDTH * 0.18f;
|
||||
static const float startPersonPositionY = CAMERA_HEIGHT * 0.4f;
|
||||
static float personPositionX = startPersonPositionX;
|
||||
static float personPositionY = startPersonPositionY;
|
||||
@@ -28,10 +30,14 @@ static float personVelocityY = 0;
|
||||
|
||||
float jetons = 0.f;
|
||||
|
||||
static RenderObject_t person;
|
||||
static RenderId_t personId;
|
||||
RenderObject_t scoreText;
|
||||
static RenderId_t scoreTextId = -1;
|
||||
static int victimHeight;
|
||||
|
||||
|
||||
#define VICTIME_COUNT 4
|
||||
RenderId_t victims[VICTIME_COUNT];
|
||||
|
||||
static RenderObject_t strengthBar;
|
||||
static RenderId_t strengthBarId;
|
||||
@@ -52,7 +58,7 @@ static bool increaseStrengthBarSlider = true;
|
||||
static void playMusic(){
|
||||
music = Mix_LoadMUS("./assets/music/jojo arab.mp3");
|
||||
if(music == NULL) {
|
||||
fprintf(stderr, "Prout not found!\n");
|
||||
fprintf(stderr, "Jojo arab not found!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -66,6 +72,7 @@ static void playMusic(){
|
||||
|
||||
int game_staticRender(void){
|
||||
playMusic();
|
||||
srand(time(NULL));
|
||||
|
||||
MonitorSize_t size = renderer_getMonitorSize();
|
||||
float aspectRatio = (float)size.width / size.height;
|
||||
@@ -94,13 +101,46 @@ int game_staticRender(void){
|
||||
building.height = 1;
|
||||
scene_addRenderObject(&gameScene, building, 0, 0);
|
||||
|
||||
SDL_Surface* personSurface = IMG_Load("./assets/img/person.png");
|
||||
strcpy(person.name, "person");
|
||||
person.z = 9;
|
||||
person.surface = personSurface;
|
||||
person.width = 0.25f;
|
||||
scaller(person.surface, 0.05f, &person.width, &person.height);
|
||||
personId = scene_addRenderObject(&gameScene, person, personPositionX, personPositionY);
|
||||
|
||||
SDL_Surface* victim1 = IMG_Load("./assets/img/victim_1.png");
|
||||
RenderObject_t person1 = EMPTY_RENDER_OBJECT;
|
||||
strcpy(person1.name, "person1");
|
||||
person1.z = 9;
|
||||
person1.surface = victim1;
|
||||
person1.width = 0.25f;
|
||||
scaller(person1.surface, 0.5f, &person1.width, &person1.height);
|
||||
victims[0] = scene_addRenderObject(&gameScene, person1, 0, CAMERA_HEIGHT * 2);
|
||||
|
||||
SDL_Surface* victim2 = IMG_Load("./assets/img/victim_2.png");
|
||||
RenderObject_t person2 = EMPTY_RENDER_OBJECT;
|
||||
strcpy(person2.name, "person2");
|
||||
person2.z = 9;
|
||||
person2.surface = victim2;
|
||||
person2.width = 0.25f;
|
||||
scaller(person2.surface, 0.5f, &person2.width, &person2.height);
|
||||
victims[1] = scene_addRenderObject(&gameScene, person2, 0, CAMERA_HEIGHT * 2);
|
||||
|
||||
SDL_Surface* victim3 = IMG_Load("./assets/img/victim_3.png");
|
||||
RenderObject_t person3 = EMPTY_RENDER_OBJECT;
|
||||
strcpy(person3.name, "person3");
|
||||
person3.z = 9;
|
||||
person3.surface = victim3;
|
||||
person3.width = 0.25f;
|
||||
scaller(person3.surface, 0.5f, &person3.width, &person3.height);
|
||||
victims[2] = scene_addRenderObject(&gameScene, person3, 0, CAMERA_HEIGHT * 2);
|
||||
|
||||
SDL_Surface* victim4 = IMG_Load("./assets/img/victim_4.png");
|
||||
RenderObject_t person4 = EMPTY_RENDER_OBJECT;
|
||||
strcpy(person4.name, "person4");
|
||||
person4.z = 9;
|
||||
person4.surface = victim4;
|
||||
person4.width = 0.25f;
|
||||
scaller(person4.surface, 0.5f, &person4.width, &person4.height);
|
||||
victims[3] = scene_addRenderObject(&gameScene, person4, 0, CAMERA_HEIGHT * 2);
|
||||
|
||||
|
||||
victimHeight = person1.height;
|
||||
personId = victims[rand() % 4];
|
||||
|
||||
scoreText = EMPTY_RENDER_OBJECT;
|
||||
strcpy(scoreText.name, "scoreText");
|
||||
@@ -169,7 +209,7 @@ int game_render([[maybe_unused]] float delta){
|
||||
jetons += distance;
|
||||
scene_moveRenderObject(&gameScene, scoreTextId, gameScene.x + 2, 0);
|
||||
|
||||
if(personPositionY + CAMERA_HEIGHT * person.height >= CAMERA_HEIGHT - 2){
|
||||
if(personPositionY + CAMERA_HEIGHT * victimHeight >= CAMERA_HEIGHT - 18){
|
||||
crashed = true;
|
||||
scene_removeRenderObject(&gameScene, scoreTextId);
|
||||
SDL_Color black = {0, 0, 0, 255};
|
||||
@@ -204,7 +244,9 @@ void game_handleSpaceKeyInput(void){
|
||||
gameScene.y = 0;
|
||||
strengthBarSliderDistance = 0.f;
|
||||
scene_moveRenderObject(&gameScene, scoreTextId, gameScene.x + 2, 0);
|
||||
scene_moveRenderObject(&gameScene, strengthBarId, 0.30f * CAMERA_WIDTH, 0.9f * CAMERA_HEIGHT);
|
||||
scene_moveRenderObject(&gameScene, strengthBarId, 0.30f * CAMERA_WIDTH, 0.9 * CAMERA_HEIGHT);
|
||||
scene_moveRenderObject(&gameScene, personId, 0, CAMERA_HEIGHT * 2);
|
||||
personId = victims[rand() % 4];
|
||||
}
|
||||
else{
|
||||
isSpaceKeypressed = true;
|
||||
|
||||
+2
-2
@@ -34,11 +34,11 @@ int menu_staticRender(void){
|
||||
|
||||
music = Mix_LoadMUS("./assets/music/menu.wav");
|
||||
if(music == NULL) {
|
||||
fprintf(stderr, "Prout not found!\n");
|
||||
fprintf(stderr, "Menu music not found!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if(Mix_PlayMusic(music, 0) != 0){
|
||||
if(Mix_PlayMusic(music, -1) != 0){
|
||||
printf("Music sound could not be played!\n"
|
||||
"SDL_Error: %s\n", Mix_GetError());
|
||||
Mix_FreeMusic(music);
|
||||
|
||||
Reference in New Issue
Block a user