add running mode

code death animation (80%)
add level displaying before (2 secs) and clear plateforms beteween levels
dev
Milang 3 years ago
parent b003f8bfc6
commit 69aa9ee702
  1. 4
      include/level.h
  2. 1
      include/score.h
  3. 7
      src/keyboard.c
  4. 77
      src/level.c
  5. 67
      src/levelchanger.c
  6. 2
      src/main.c
  7. 6
      src/plateforme.c
  8. 3
      src/score.c

@ -1,7 +1,7 @@
#ifndef LEVEL_H
#define LEVEL_H
void set_level(int n);
void get_lvl_id(int n, char * str);
void set_level(int w, int l);
void get_lvl_id(int w, int l, char * str);
#endif

@ -12,5 +12,6 @@ void score_add(int);
void score_display();
void score_add_coin();
void new_level();
void new_game();
#endif

@ -141,7 +141,12 @@ void update_keyboard()
e=pollevent();
}
if (menu)
mario_dead=menu_pause();
{
int t=menu_pause();
if (t==1)
finish_level=-1;
return;
}
}
int getkey_custom()

@ -32,6 +32,8 @@ void init_level(world_t * lvl)
{
free(w_current);
}
if (0==w_current_y*w_current_y)
return;
int size=sizeof(world_t)*w_current_y*w_current_x;
w_current=malloc(size);
if (w_current==0)
@ -46,6 +48,8 @@ void init_ennemies(ennemi_t * table)
{
free(ennemis_global);
}
if (0==ennemis_global_size)
return;
int size=sizeof(ennemi_t)*ennemis_global_size;
ennemis_global=malloc(size);
if (ennemis_global==0)
@ -59,7 +63,10 @@ static void init_plateformes(plateforme_t * table)
if (plateformes)
{
free(plateformes);
plateformes=0;
}
if (0==table)
return;
int size=sizeof(plateforme_t)*plateforme_table_size;
plateformes=malloc(size);
if (plateformes==0)
@ -93,11 +100,16 @@ static void init_plateformes(plateforme_t * table)
plateforme_table_size=1;
init_plateformes(plateforme0);*/
void set_level(int n)
void set_level(int w, int l)
{
new_level();
if (n==0)
w_current_x=0;
w_current_y=0;
ennemis_global_size=0;
plateforme_table_size=0;
if (w+1==1 && l+1==1)
{
w_current_x=226;
w_current_y=13;
@ -333,28 +345,28 @@ void set_level(int n)
init_level(lvl);
ennemis_global_size=10;
ennemi_t ennemies0[]=
{
GOOMBA(176,16,-1),
GOOMBA(321,16,-1),
GOOMBA(409,16,-1),
GOOMBA(421,16,-1),
GOOMBA(640,80,-1),
GOOMBA(656,80,-1),
GOOMBA(776,16,-1),
GOOMBA(788,16,-1),
KOOPA_V(856,16,-1),
GOOMBA(912,16,-1),
GOOMBA(924,16,-1)
};
init_ennemies(ennemies0);
ennemi_t ennemies0[]=
{
GOOMBA(176,16,-1),
GOOMBA(321,16,-1),
GOOMBA(409,16,-1),
GOOMBA(421,16,-1),
GOOMBA(640,80,-1),
GOOMBA(656,80,-1),
GOOMBA(776,16,-1),
GOOMBA(788,16,-1),
KOOPA_V(856,16,-1),
GOOMBA(912,16,-1),
GOOMBA(924,16,-1)
};
init_ennemies(ennemies0);
plateforme_t plateforme0[]=
{
PLATEFORME_MOVING_H(15,25,16,1,0,60)
};
plateforme_table_size=1;
init_plateformes(plateforme0);
plateforme_t plateforme0[]=
{
PLATEFORME_MOVING_H(15,25,16,1,0,60)
};
plateforme_table_size=1;
init_plateformes(plateforme0);
mario_x_max=0;
@ -362,8 +374,7 @@ void set_level(int n)
mario.p.y=16;
}
if (n==1)
else if (w+1==1 && l+1==2)
{
w_current_x = 280;
w_current_y = 14;
@ -680,20 +691,8 @@ void set_level(int n)
}
}
void get_lvl_id(int n, char * str)
void get_lvl_id(int w, int l, char * str)
{
str[3]='\0';
switch (n)
{
case 0:
str[0]='1';
str[1]='-';
str[2]='1';
return;
case 1:
str[0]='1';
str[1]='-';
str[2]='2';
return;
}
sprintf(str, "%d-%d", w+1, l+1);
}

@ -16,7 +16,7 @@
static void levelchanger(int w)
{
int play_level(int l);
int play_level(int w, int l);
extern image_t img_levelchanger;
@ -47,13 +47,32 @@ static void levelchanger(int w)
{
if (choice==8)
{
play_level(0); // Todo : add score lifes etc...
new_game();
for (int i=0; i<7; i+=0)
{
int a=play_level(w, i);
if (a==0)
lifes--;
if (a==1)
i++;
if (a==-1)
break;
if (lifes==0)
{
extern image_t img_game_over;
dimage(0,0,&img_game_over);
dupdate();
sleep_ms(3,2000);
// TODO: Highscore management
break;
}
}
}
else
{
mario_smaller();
mario_immunity=0;
play_level(choice);
play_level(w, choice);
}
}
@ -154,7 +173,7 @@ int callback(volatile void *arg)
int play_level(int l)
int play_level(int w, int l)
{
volatile int has_ticked = 1;
timer_setup(0, timer_delay(0, 50000), timer_Po_4, callback, &has_ticked);
@ -162,10 +181,23 @@ int play_level(int l)
//int finish_status=0; // FAil
finish_level=0; mario_dead=0;
set_level(l);
set_level(w, l);
if (w_current==0)
return 0;
reset_camera();
extern image_t img_new_level;
dimage(0,0,&img_new_level);
char lvl[4];
get_lvl_id(w, l, 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,2000);
while(global_quit==0)
{
if (has_ticked)
@ -182,18 +214,37 @@ int play_level(int l)
dupdate();
if (mario_dead)
{
for (int i=6; mario.p.y>=0; i--)
{
if (has_ticked)
{
has_ticked=0;
mario.p.y+=i;
dclear(C_WHITE);
world_draw(mario.p.x,mario.p.y);
score_display();
dupdate();
}
else
sleep_ms(3,1);
}
sleep_ms(3,1000);
timer_stop(0);
return 0;
}
if (finish_level)
{
timer_stop(0);
return 1;
// TODO ajouter temps au score etc
return finish_level;
}
}
else
sleep_ms(3,1);
}
}

@ -22,7 +22,7 @@ int main(void)
extern font_t font_mario;
dfont(&font_mario);
//gint_panic_set(system_error);
ll_set_panic();
//ll_set_panic();
int current_level=0;
launch_ui();

@ -90,6 +90,8 @@ void move_plateforme(plateforme_t* p)
void display_plateformes()
{
if (plateformes==0 || plateforme_table_size==0)
return;
plateforme_t * p=0;
for (int i=0; i<plateforme_table_size; i++)
{
@ -102,6 +104,8 @@ void display_plateformes()
void move_plateformes()
{
if (plateformes==0 || plateforme_table_size==0)
return;
plateforme_t * p=0;
for (int i=0; i<plateforme_table_size; i++)
{
@ -112,6 +116,8 @@ void move_plateformes()
int plateforme_check_collide(int x, int y)
{
if (plateformes==0 || plateforme_table_size==0)
return 0;
for (int i=0; i<plateforme_table_size; i++)
{
plateforme_t * p=&plateformes[i];

@ -19,7 +19,7 @@ int time_left=0;
int finish_level=0;
static void new_game()
void new_game()
{
lifes=3;
@ -27,6 +27,7 @@ static void new_game()
score=0;
combo=0;
combo_id=-10;
mario_smaller();
new_level();
}

Loading…
Cancel
Save