Merge branch 'master' of ssh.marcbarbier.fr:Marc/gamejam-polytech

This commit is contained in:
Marc
2023-01-21 15:01:37 +01:00
6 changed files with 69 additions and 41 deletions
+10 -25
View File
@@ -11,13 +11,13 @@
#include <unistd.h>
#include "scaller.h"
long timecode;
clock_t timecode;
long iter;
Mix_Music *prout;
static void space(void) {
printf("space!\n");
if(Mix_PlayMusic(prout, -1) != 0){
if(Mix_PlayMusic(prout, 0) != 0){
printf("Music sound could not be played!\n"
"SDL_Error: %s\n", Mix_GetError());
Mix_FreeMusic(prout);
@@ -28,7 +28,7 @@ static void space(void) {
Scene_t demo;
static void game_setup(void) {
menu_render();
menu_staticRender();
RenderObject_t text;
SDL_Color white = {255, 255, 255, 255};
TTF_Init();
@@ -36,50 +36,35 @@ static void game_setup(void) {
printf("error");
exit(1);
}
SDL_Surface* img = IMG_Load("./assets/img/pp.png");
RenderObject_t duck = {
1,
0.5,
0.5,
0,
img
};
scaller(duck.surface, 1, &duck.width, &duck.height);
scene_addRenderObject(&demo, duck, CAMERA_WIDTH/2, CAMERA_HEIGHT/2);
scene_addRenderObject(&demo, text, CAMERA_WIDTH/2, CAMERA_HEIGHT/2);
input_listen(SDL_SCANCODE_SPACE, space);
}
static void game_loop(void) {
long delta = time(NULL) - timecode;
//main game code
float delta = ((float)(clock() - timecode)) / CLOCKS_PER_SEC;
//update time
timecode = time(NULL);
iter++;
menu_render(delta);
timecode = clock();
}
int main(void) {
TTF_Init();
if(Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 2, 4096) != 0){
printf("Music sound could not be open!\n"
"SDL_Error: %s\n", Mix_GetError());
running = false;
}
prout = Mix_LoadMUS("./assets/music/pet.mp3");
prout = Mix_LoadMUS("./assets/music/jojo arab.mp3");
if(prout == NULL) {
fprintf(stderr, "Prout not found!\n");
exit(1);
}
iter = 0;
timecode = time(NULL);
timecode = clock();
Mix_Init(MIX_INIT_MP3);
renderer_main(game_setup, game_loop);