Merge branch 'master' of ssh.marcbarbier.fr:Marc/gamejam-polytech
This commit is contained in:
+1
-1
@@ -17,7 +17,7 @@ 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 white = {255, 255, 255, 255};
|
SDL_Color white = {255, 255, 255, 255};
|
||||||
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.");
|
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.\n\n Press space to continue");
|
||||||
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");
|
||||||
|
|||||||
+100
-4
@@ -3,13 +3,14 @@
|
|||||||
#include <SDL2/SDL_image.h>
|
#include <SDL2/SDL_image.h>
|
||||||
#include <SDL2/SDL_mixer.h>
|
#include <SDL2/SDL_mixer.h>
|
||||||
#include <SDL2/SDL_surface.h>
|
#include <SDL2/SDL_surface.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "scaller.h"
|
#include "scaller.h"
|
||||||
#include "scene.h"
|
#include "scene.h"
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
|
|
||||||
#define SLIDER_SPEED 1.f/500
|
#define SLIDER_SPEED 1.f/5000
|
||||||
#define GRAVITY 10000.f
|
#define GRAVITY 10000.f
|
||||||
|
|
||||||
static Mix_Music * music;
|
static Mix_Music * music;
|
||||||
@@ -39,15 +40,26 @@ static RenderId_t pressSpaceShadowId;
|
|||||||
static RenderId_t pressSpaceTextId;
|
static RenderId_t pressSpaceTextId;
|
||||||
|
|
||||||
#define VICTIME_COUNT 4
|
#define VICTIME_COUNT 4
|
||||||
|
#define VICTIME_SIZE 0.5f
|
||||||
RenderId_t victims[VICTIME_COUNT];
|
RenderId_t victims[VICTIME_COUNT];
|
||||||
|
|
||||||
|
#define ADAME_KEYFRAMES 7
|
||||||
|
RenderId_t adame[ADAME_KEYFRAMES];
|
||||||
|
static float adame_accu = 0;
|
||||||
|
static int adame_id;
|
||||||
|
static bool kicked = false;
|
||||||
|
#define ADAME_SPEED 1.f/250
|
||||||
|
#define ADAME_SIZE 2.5f
|
||||||
|
#define ADAME_Y round(CAMERA_HEIGHT * 0.30f)
|
||||||
|
#define ADAME_X round(CAMERA_WIDTH * 0.01f)
|
||||||
|
|
||||||
static RenderObject_t strengthBar;
|
static RenderObject_t strengthBar;
|
||||||
static RenderId_t strengthBarId;
|
static RenderId_t strengthBarId;
|
||||||
static float strength = 0.f;
|
static float strength = 0.f;
|
||||||
static bool increaseStrength = true;
|
static bool increaseStrength = true;
|
||||||
|
|
||||||
|
|
||||||
static float adameStrength = 1.f; // this value is not const as it will be possible to improve the strenght of Adame.
|
static float adameStrength = 2.f; // this value is not const as it will be possible to improve the strenght of Adame.
|
||||||
|
|
||||||
static RenderObject_t strengthBarSlider;
|
static RenderObject_t strengthBarSlider;
|
||||||
static float strengthBarSliderDistance = 0.f;
|
static float strengthBarSliderDistance = 0.f;
|
||||||
@@ -57,6 +69,7 @@ static bool increaseStrengthBarSlider = true;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void playMusic(){
|
static void playMusic(){
|
||||||
music = Mix_LoadMUS("./assets/music/jojo arab.mp3");
|
music = Mix_LoadMUS("./assets/music/jojo arab.mp3");
|
||||||
if(music == NULL) {
|
if(music == NULL) {
|
||||||
@@ -140,9 +153,74 @@ int game_staticRender(void){
|
|||||||
scaller(person4.surface, 0.5f, &person4.width, &person4.height);
|
scaller(person4.surface, 0.5f, &person4.width, &person4.height);
|
||||||
victims[3] = scene_addRenderObject(&gameScene, person4, 0, CAMERA_HEIGHT * 2);
|
victims[3] = scene_addRenderObject(&gameScene, person4, 0, CAMERA_HEIGHT * 2);
|
||||||
|
|
||||||
|
SDL_Surface* adame1 = IMG_Load("./assets/img/adame_1.png");
|
||||||
|
RenderObject_t adameObject1 = EMPTY_RENDER_OBJECT;
|
||||||
|
strcpy(adameObject1.name, "adameObject1");
|
||||||
|
adameObject1.z = 9;
|
||||||
|
adameObject1.surface = adame1;
|
||||||
|
adameObject1.width = 0.25f;
|
||||||
|
scaller(adameObject1.surface, ADAME_SIZE, &adameObject1.width, &adameObject1.height);
|
||||||
|
adame[0] = scene_addRenderObject(&gameScene, adameObject1, 0, CAMERA_HEIGHT * 2);
|
||||||
|
|
||||||
|
SDL_Surface* adame2 = IMG_Load("./assets/img/adame_2.png");
|
||||||
|
RenderObject_t adameObject2 = EMPTY_RENDER_OBJECT;
|
||||||
|
strcpy(adameObject2.name, "adameObject2");
|
||||||
|
adameObject2.z = 9;
|
||||||
|
adameObject2.surface = adame2;
|
||||||
|
adameObject2.width = 0.25f;
|
||||||
|
scaller(adameObject2.surface, ADAME_SIZE, &adameObject2.width, &adameObject2.height);
|
||||||
|
adame[1] = scene_addRenderObject(&gameScene, adameObject2, 0, CAMERA_HEIGHT * 2);
|
||||||
|
|
||||||
|
SDL_Surface* adame3 = IMG_Load("./assets/img/adame_3.png");
|
||||||
|
RenderObject_t adameObject3 = EMPTY_RENDER_OBJECT;
|
||||||
|
strcpy(adameObject3.name, "adameObject3");
|
||||||
|
adameObject3.z = 9;
|
||||||
|
adameObject3.surface = adame3;
|
||||||
|
adameObject3.width = 0.25f;
|
||||||
|
scaller(adameObject3.surface, ADAME_SIZE, &adameObject3.width, &adameObject3.height);
|
||||||
|
adame[2] = scene_addRenderObject(&gameScene, adameObject3, 0, CAMERA_HEIGHT * 2);
|
||||||
|
|
||||||
|
SDL_Surface* adame4 = IMG_Load("./assets/img/adame_4.png");
|
||||||
|
RenderObject_t adameObject4 = EMPTY_RENDER_OBJECT;
|
||||||
|
strcpy(adameObject4.name, "adameObject4");
|
||||||
|
adameObject4.z = 9;
|
||||||
|
adameObject4.surface = adame4;
|
||||||
|
adameObject4.width = 0.25f;
|
||||||
|
scaller(adameObject4.surface, ADAME_SIZE, &adameObject4.width, &adameObject4.height);
|
||||||
|
adame[3] = scene_addRenderObject(&gameScene, adameObject4, 0, CAMERA_HEIGHT * 2);
|
||||||
|
|
||||||
|
SDL_Surface* adame5 = IMG_Load("./assets/img/adame_5.png");
|
||||||
|
RenderObject_t adameObject5 = EMPTY_RENDER_OBJECT;
|
||||||
|
strcpy(adameObject5.name, "adameObject5");
|
||||||
|
adameObject5.z = 9;
|
||||||
|
adameObject5.surface = adame5;
|
||||||
|
adameObject5.width = 0.25f;
|
||||||
|
scaller(adameObject5.surface, ADAME_SIZE, &adameObject5.width, &adameObject5.height);
|
||||||
|
adame[4] = scene_addRenderObject(&gameScene, adameObject5, 0, CAMERA_HEIGHT * 2);
|
||||||
|
|
||||||
|
SDL_Surface* adame6 = IMG_Load("./assets/img/adame_6.png");
|
||||||
|
RenderObject_t adameObject6 = EMPTY_RENDER_OBJECT;
|
||||||
|
strcpy(adameObject6.name, "adameObject6");
|
||||||
|
adameObject6.z = 9;
|
||||||
|
adameObject6.surface = adame6;
|
||||||
|
adameObject6.width = 0.25f;
|
||||||
|
scaller(adameObject6.surface, ADAME_SIZE, &adameObject6.width, &adameObject6.height);
|
||||||
|
adame[5] = scene_addRenderObject(&gameScene, adameObject6, 0, CAMERA_HEIGHT * 2);
|
||||||
|
|
||||||
|
SDL_Surface* adame7 = IMG_Load("./assets/img/adame_7.png");
|
||||||
|
RenderObject_t person7 = EMPTY_RENDER_OBJECT;
|
||||||
|
strcpy(person7.name, "person7");
|
||||||
|
person7.z = 9;
|
||||||
|
person7.surface = adame7;
|
||||||
|
person7.width = 0.25f;
|
||||||
|
scaller(person7.surface, ADAME_SIZE, &person7.width, &person7.height);
|
||||||
|
adame[6] = scene_addRenderObject(&gameScene, person7, 0, CAMERA_HEIGHT * 2);
|
||||||
|
|
||||||
|
|
||||||
|
adame_id = 0;
|
||||||
victimHeight = person1.height;
|
victimHeight = person1.height;
|
||||||
personId = victims[rand() % 4];
|
personId = victims[rand() % 4];
|
||||||
|
scene_moveRenderObject(&gameScene, adame[0], ADAME_X, ADAME_Y);
|
||||||
|
|
||||||
scoreText = EMPTY_RENDER_OBJECT;
|
scoreText = EMPTY_RENDER_OBJECT;
|
||||||
strcpy(scoreText.name, "scoreText");
|
strcpy(scoreText.name, "scoreText");
|
||||||
@@ -195,7 +273,6 @@ int game_render([[maybe_unused]] float delta){
|
|||||||
// increaseStrength = true;
|
// increaseStrength = true;
|
||||||
// else
|
// else
|
||||||
// strength -= 0.1;
|
// strength -= 0.1;
|
||||||
|
|
||||||
if(increaseStrengthBarSlider && strengthBarSliderDistance >= 0.50f)
|
if(increaseStrengthBarSlider && strengthBarSliderDistance >= 0.50f)
|
||||||
increaseStrengthBarSlider = false;
|
increaseStrengthBarSlider = false;
|
||||||
else if(increaseStrengthBarSlider){
|
else if(increaseStrengthBarSlider){
|
||||||
@@ -211,8 +288,26 @@ int game_render([[maybe_unused]] float delta){
|
|||||||
|
|
||||||
deltaAccu = 0;
|
deltaAccu = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(strength != 0 && !kicked && isSpaceKeypressed) {
|
||||||
|
adame_accu += delta;
|
||||||
|
printf("%f\n", adame_accu);
|
||||||
|
if(adame_accu >= ADAME_SPEED / strength) {
|
||||||
|
scene_moveRenderObject(&gameScene, adame[adame_id], 0, CAMERA_HEIGHT * 2);
|
||||||
|
if(adame_id == 6) {
|
||||||
|
scene_moveRenderObject(&gameScene, adame[0], ADAME_X, ADAME_Y);
|
||||||
|
adame_id = 0;
|
||||||
|
kicked = true;
|
||||||
|
} else {
|
||||||
|
adame_id++;
|
||||||
|
scene_moveRenderObject(&gameScene, adame[adame_id], ADAME_X, ADAME_Y);
|
||||||
|
adame_accu = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if(!crashed && deltaAccu >= SPEED && isSpaceKeypressed){
|
// if(!crashed && deltaAccu >= SPEED && isSpaceKeypressed){
|
||||||
if(!crashed && isSpaceKeypressed){
|
if(!crashed && kicked){
|
||||||
const float distance = personVelocityX * delta;
|
const float distance = personVelocityX * delta;
|
||||||
personPositionX += distance;
|
personPositionX += distance;
|
||||||
gameScene.x = personPositionX - startPersonPositionX;
|
gameScene.x = personPositionX - startPersonPositionX;
|
||||||
@@ -261,6 +356,7 @@ void game_handleSpaceKeyInput(void){
|
|||||||
scene_moveRenderObject(&gameScene, strengthBarId, 0.30f * CAMERA_WIDTH, 0.9 * CAMERA_HEIGHT);
|
scene_moveRenderObject(&gameScene, strengthBarId, 0.30f * CAMERA_WIDTH, 0.9 * CAMERA_HEIGHT);
|
||||||
scene_moveRenderObject(&gameScene, personId, 0, CAMERA_HEIGHT * 2);
|
scene_moveRenderObject(&gameScene, personId, 0, CAMERA_HEIGHT * 2);
|
||||||
personId = victims[rand() % 4];
|
personId = victims[rand() % 4];
|
||||||
|
kicked=false;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
isSpaceKeypressed = true;
|
isSpaceKeypressed = true;
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ void scene_render(const Scene_t * scene) {
|
|||||||
MonitorSize_t monitorSize = renderer_getMonitorSize();
|
MonitorSize_t monitorSize = renderer_getMonitorSize();
|
||||||
|
|
||||||
for(int i = 0; i < scene->objectCount; i++) {
|
for(int i = 0; i < scene->objectCount; i++) {
|
||||||
// printf("Rendering %d, %s\n", scene->objects[i].id, scene->objects[i].renderObj.name);
|
|
||||||
const SceneObject_t * object = &scene->objects[i];
|
const SceneObject_t * object = &scene->objects[i];
|
||||||
float x = (object->x - scene->x) / CAMERA_WIDTH;
|
float x = (object->x - scene->x) / CAMERA_WIDTH;
|
||||||
float y = (object->y - scene->y) / CAMERA_HEIGHT;
|
float y = (object->y - scene->y) / CAMERA_HEIGHT;
|
||||||
|
|||||||
Reference in New Issue
Block a user