Odyssee/project/src/main.c

84 lines
1.5 KiB
C
Raw Normal View History

2021-06-30 08:30:02 +02:00
/*
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>
2021-07-04 09:40:38 +02:00
#include <gint/gray.h>
2021-06-30 08:30:02 +02:00
#include <gint/keyboard.h>
#include <gint/timer.h>
#include <gint/clock.h>
#include <gint/std/stdlib.h>
#include "core.h"
2021-07-04 09:40:38 +02:00
#include "display_engine.h"
2021-06-30 08:30:02 +02:00
// title_screen : display the title screen with particule effect
void title_screen(void);
2021-07-04 09:40:38 +02:00
void main_loop(void);
2021-06-30 08:30:02 +02:00
int main(void)
{
extern font_t font_odyssee;
dfont(&font_odyssee);
2021-07-04 09:40:38 +02:00
dgray(DGRAY_ON);
2021-07-16 13:21:42 +02:00
title_screen();
2021-07-04 09:40:38 +02:00
main_loop();
dgray(DGRAY_OFF);
dupdate();
2021-06-30 08:30:02 +02:00
return 1;
}
void title_screen(void)
{
extern const bopti_image_t img_title;
2021-07-16 13:21:42 +02:00
dclear(C_WHITE);
dimage(0, 0, &img_title);
dupdate();
getkey();
2021-07-04 09:40:38 +02:00
}
void main_loop(void)
{
extern const struct map map_world;
2021-07-04 09:40:38 +02:00
int key = 0;
2021-07-17 15:32:47 +02:00
struct player player = {DOWN, 0};
struct game game = {&map_world, 0, 0, &player, 0, 0};
2021-07-16 13:21:42 +02:00
static volatile int tick = 0;
int t = timer_configure(TIMER_ANY, ENGINE_TICK*1000, GINT_CALL(callback_tick, &tick));
2021-07-17 15:32:47 +02:00
if (t >= 0) timer_start(t);
2021-07-04 09:40:38 +02:00
while (key != KEY_EXIT)
{
2021-07-16 13:21:42 +02:00
while (!tick) sleep();
tick = 0;
2021-07-04 09:40:38 +02:00
dclear(C_WHITE);
2021-07-16 13:21:42 +02:00
next_frame(&game);
2021-07-17 15:32:47 +02:00
draw_map(&game);
draw_player(&game);
2021-07-04 09:40:38 +02:00
dupdate();
2021-07-16 13:21:42 +02:00
key = rtc_key();
2021-07-04 09:40:38 +02:00
analyze_input(&game, key);
}
2021-07-16 13:21:42 +02:00
if (t >= 0) timer_stop(t);
2021-06-30 08:30:02 +02:00
}