2019-11-16 11:44:09 +01:00
|
|
|
#include <gint/display.h>
|
|
|
|
#include <gint/keyboard.h>
|
|
|
|
#include <gint/timer.h>
|
|
|
|
|
2019-11-16 12:02:30 +01:00
|
|
|
#include "world.h"
|
2019-11-20 15:33:34 +01:00
|
|
|
#include "mario.h"
|
2019-11-24 14:28:04 +01:00
|
|
|
#include "level.h"
|
2019-11-30 13:57:18 +01:00
|
|
|
#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>
|
2019-11-24 14:28:04 +01:00
|
|
|
#include <gint/clock.h>
|
2019-12-03 19:53:30 +01:00
|
|
|
#include <gint/std/stdio.h>
|
2019-11-24 14:28:04 +01:00
|
|
|
|
2019-11-20 18:31:20 +01:00
|
|
|
extern image_t img_error;
|
|
|
|
GNORETURN void system_error(uint32_t code)
|
|
|
|
{
|
|
|
|
timer_stop(0);
|
|
|
|
dimage(0,0,&img_error);
|
|
|
|
dupdate();
|
|
|
|
while(1) getkey();
|
|
|
|
}
|
|
|
|
|
2019-11-16 11:44:09 +01:00
|
|
|
int callback(volatile void *arg)
|
|
|
|
{
|
|
|
|
volatile int *has_ticked = arg;
|
|
|
|
*has_ticked = 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
2019-11-30 13:57:18 +01:00
|
|
|
extern font_t font_mario;
|
|
|
|
dfont(&font_mario);
|
2019-11-20 18:31:20 +01:00
|
|
|
gint_panic_set(system_error);
|
2019-11-16 11:44:09 +01:00
|
|
|
volatile int has_ticked = 1;
|
|
|
|
|
2019-11-24 11:14:16 +01:00
|
|
|
timer_setup(0, timer_delay(0, 50000), timer_Po_4, callback, &has_ticked);
|
2019-11-16 11:44:09 +01:00
|
|
|
timer_start(0);
|
2019-11-24 14:28:04 +01:00
|
|
|
set_level(0);
|
2019-11-25 19:12:25 +01:00
|
|
|
int current_level=0;
|
2019-11-20 15:33:34 +01:00
|
|
|
while(global_quit==0)
|
2019-11-16 11:44:09 +01:00
|
|
|
{
|
2019-11-24 11:14:16 +01:00
|
|
|
if (has_ticked)
|
|
|
|
{
|
|
|
|
has_ticked=0;
|
2019-12-08 16:34:32 +01:00
|
|
|
//mario_move();
|
|
|
|
|
|
|
|
world_move();
|
2019-11-24 11:14:16 +01:00
|
|
|
dclear(C_WHITE);
|
2019-12-08 16:34:32 +01:00
|
|
|
world_draw(mario.p.x,mario.p.y);
|
2019-11-30 13:57:18 +01:00
|
|
|
score_display();
|
2019-12-03 19:53:30 +01:00
|
|
|
|
2019-11-24 11:14:16 +01:00
|
|
|
dupdate();
|
2019-11-30 13:57:18 +01:00
|
|
|
if (mario_dead==1)
|
2019-11-25 19:12:25 +01:00
|
|
|
{
|
|
|
|
mario_dead=0;
|
2019-11-30 13:57:18 +01:00
|
|
|
end_level=0;
|
2019-12-07 14:32:38 +01:00
|
|
|
|
2019-11-30 13:57:18 +01:00
|
|
|
}
|
|
|
|
if (end_level==0)
|
|
|
|
{
|
|
|
|
lifes--;
|
2019-12-07 14:32:38 +01:00
|
|
|
mario_smaller();
|
2019-11-30 13:57:18 +01:00
|
|
|
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 (end_level>=1)
|
|
|
|
{
|
|
|
|
current_level+=end_level;
|
|
|
|
set_level(current_level);
|
2019-11-25 19:12:25 +01:00
|
|
|
}
|
2019-11-24 11:14:16 +01:00
|
|
|
}
|
2019-11-24 14:28:04 +01:00
|
|
|
else
|
|
|
|
sleep_ms(3,1);
|
2019-11-16 11:44:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
timer_stop(0);
|
2019-11-24 14:28:04 +01:00
|
|
|
}
|
|
|
|
|