Odyssee/project/src/main.c

84 lines
1.5 KiB
C

/*
Projet name .......: Odyssée
Version ...........: - dev -
Last modification .: 11 june 2021
code and assets provided with licence :
GNU General Public Licence v3.0
*/
#include <gint/display.h>
#include <gint/gray.h>
#include <gint/keyboard.h>
#include <gint/timer.h>
#include <gint/clock.h>
#include <gint/std/stdlib.h>
#include "core.h"
#include "display_engine.h"
// title_screen : display the title screen with particule effect
void title_screen(void);
void main_loop(void);
int main(void)
{
extern font_t font_odyssee;
dfont(&font_odyssee);
dgray(DGRAY_ON);
title_screen();
main_loop();
dgray(DGRAY_OFF);
dupdate();
return 1;
}
void title_screen(void)
{
extern const bopti_image_t img_title;
dclear(C_WHITE);
dimage(0, 0, &img_title);
dupdate();
getkey();
}
void main_loop(void)
{
extern const struct map map_world;
int key = 0;
struct player player = {DOWN, 0};
struct game game = {&map_world, 0, 0, &player, 0, 0};
static volatile int tick = 0;
int t = timer_configure(TIMER_ANY, ENGINE_TICK*1000, GINT_CALL(callback_tick, &tick));
if (t >= 0) timer_start(t);
while (key != KEY_EXIT)
{
while (!tick) sleep();
tick = 0;
dclear(C_WHITE);
next_frame(&game);
draw_map(&game);
draw_player(&game);
dupdate();
key = rtc_key();
analyze_input(&game, key);
}
if (t >= 0) timer_stop(t);
}