supercasiobros/src/main.c

98 lines
1.7 KiB
C
Raw Normal View History

2019-11-16 11:44:09 +01:00
#include <gint/display.h>
#include <gint/keyboard.h>
#include <gint/timer.h>
2020-01-06 20:56:10 +01:00
#include <liblog.h>
2019-11-16 11:44:09 +01:00
2019-11-16 12:02:30 +01:00
#include "world.h"
2019-11-20 15:33:34 +01:00
#include "mario.h"
#include "level.h"
#include "score.h"
2019-12-03 19:53:30 +01:00
#include "ennemi.h"
2019-11-16 12:02:30 +01:00
2019-11-20 18:31:20 +01:00
#include <gint/exc.h>
#include <gint/keyboard.h>
#include <gint/defs/attributes.h>
#include <gint/clock.h>
2019-12-03 19:53:30 +01:00
#include <gint/std/stdio.h>
2019-11-20 18:31:20 +01:00
extern image_t img_error;
GNORETURN void system_error(uint32_t code)
{
timer_stop(0);
2020-01-06 20:56:10 +01:00
dimage(0,0,&img_error);
dupdate();
while(1) getkey();
2019-11-20 18:31:20 +01:00
}
2020-01-06 20:56:10 +01:00
int frame_id;
2019-11-16 11:44:09 +01:00
int callback(volatile void *arg)
{
2020-01-06 20:56:10 +01:00
volatile int *has_ticked = arg;
*has_ticked = 1;
return 0;
2019-11-16 11:44:09 +01:00
}
int main(void)
{
2020-01-06 20:56:10 +01:00
extern font_t font_mario;
dfont(&font_mario);
//gint_panic_set(system_error);
ll_set_panic();
volatile int has_ticked = 1;
2019-11-16 11:44:09 +01:00
2020-01-06 20:56:10 +01:00
timer_setup(0, timer_delay(0, 50000), timer_Po_4, callback, &has_ticked);
timer_start(0);
set_level(0);
int current_level=0;
while(global_quit==0)
{
if (has_ticked)
{
2020-01-06 20:56:10 +01:00
has_ticked=0;
frame_id++;
2019-12-08 16:34:32 +01:00
//mario_move();
2020-01-06 20:56:10 +01:00
world_move();
dclear(C_WHITE);
world_draw(mario.p.x,mario.p.y);
score_display();
2019-12-03 19:53:30 +01:00
2020-01-06 20:56:10 +01:00
dupdate();
if (mario_dead==1)
{
mario_dead=0;
finish_level=0;
2020-01-06 20:56:10 +01:00
}
if (finish_level==0)
{
lifes--;
mario_smaller();
set_level(current_level);
extern image_t img_new_level;
dimage(0,0,&img_new_level);
char lvl[4];
get_lvl_id(current_level, lvl);
dtext(57,28, lvl, C_WHITE, C_BLACK);
sprintf(lvl, "%d", lifes);
dtext(65,54, lvl, C_WHITE, C_BLACK);
dupdate();
sleep_ms(3,1000);
sleep_ms(3,1000);
sleep_ms(3,1000);
dclear(C_BLACK);
}
if (finish_level>=1)
{
current_level+=finish_level;
set_level(current_level);
}
}
else
sleep_ms(3,1);
}
2019-11-16 11:44:09 +01:00
2020-01-06 20:56:10 +01:00
timer_stop(0);
}