main menu

This commit is contained in:
2023-01-21 14:53:10 +01:00
parent ea300fc007
commit aa8457b46d
6 changed files with 70 additions and 30 deletions
+11 -14
View File
@@ -10,7 +10,7 @@
#include <unistd.h>
#include "scaller.h"
long timecode;
clock_t timecode;
long iter;
Mix_Music *prout;
@@ -25,15 +25,15 @@ static void space(void) {
}
static void game_main(void) {
long delta = time(NULL) - timecode;
float delta = ((float)(clock() - timecode)) / CLOCKS_PER_SEC;
//main game code
if(iter == 0) {
menu_render();
menu_staticRender();
RenderObject_t text;
SDL_Color white = {255, 255, 255, 255};
TTF_Init();
if(text_renderText(&text, 0.1f, 0.1f, 1000, 1, white, "./assets/fonts/arial.ttf", 25, "Hello World") < 0){
if(text_renderText(&text, 0.1f, 0.1f, 1000, 0.7f, white, "./assets/fonts/Quinquefive.ttf", 25, "Hello World") < 0){
printf("error");
exit(1);
}
@@ -41,13 +41,8 @@ static void game_main(void) {
SDL_Surface* img = IMG_Load("./assets/img/pp.png");
RenderObject_t duck = {
<<<<<<< HEAD
0.25,
0.25,
=======
0.5,
0.5,
>>>>>>> 781f4ba7beb2793dbdb38f1f2ca35f8a5fb52da3
0,
0.50,
0.50,
@@ -57,20 +52,22 @@ static void game_main(void) {
scaller(duck.surface, 1, &duck.width, &duck.height);
placer(duck.surface, 1, &duck.x, &duck.y);
renderer_renderObject(text);
renderer_renderObject(duck);
// renderer_renderObject(text);
// renderer_renderObject(duck);
input_listen(SDL_SCANCODE_SPACE, space);
}
menu_render(delta);
//update time
timecode = time(NULL);
timecode = clock();
iter++;
}
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());
@@ -84,7 +81,7 @@ int main(void) {
}
iter = 0;
timecode = time(NULL);
timecode = clock();
Mix_Init(MIX_INIT_MP3);
renderer_main(game_main);