add config menu
This commit is contained in:
parent
2dbd89321b
commit
be2090cebd
BIN
SuperCbr.g1a
BIN
SuperCbr.g1a
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 722 B After Width: | Height: | Size: 738 B |
Binary file not shown.
After Width: | Height: | Size: 611 B |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1049
build-fx/map
1049
build-fx/map
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,3 @@
|
|||
build-fx/src/config.c.o: src/config.c src/config.h
|
||||
|
||||
src/config.h:
|
Binary file not shown.
Binary file not shown.
|
@ -1,5 +1,5 @@
|
|||
build-fx/src/keyboard.c.o: src/keyboard.c src/keyboard.h src/mario.h \
|
||||
src/box.h src/score.h
|
||||
src/box.h src/score.h src/config.h
|
||||
|
||||
src/keyboard.h:
|
||||
|
||||
|
@ -8,3 +8,5 @@ src/mario.h:
|
|||
src/box.h:
|
||||
|
||||
src/score.h:
|
||||
|
||||
src/config.h:
|
||||
|
|
Binary file not shown.
|
@ -1,5 +1,5 @@
|
|||
build-fx/src/level.c.o: src/level.c src/level.h src/world.h src/mario.h \
|
||||
src/box.h src/score.h src/ennemi.h src/keyboard.h src/teleporteur.h
|
||||
src/box.h src/score.h src/ennemi.h src/keyboard.h
|
||||
|
||||
src/level.h:
|
||||
|
||||
|
@ -14,5 +14,3 @@ src/score.h:
|
|||
src/ennemi.h:
|
||||
|
||||
src/keyboard.h:
|
||||
|
||||
src/teleporteur.h:
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -1,5 +1,5 @@
|
|||
build-fx/src/mario.c.o: src/mario.c src/mario.h src/box.h src/tile.h \
|
||||
src/world.h src/keyboard.h src/score.h src/bonus.h src/teleporteur.h
|
||||
src/world.h src/keyboard.h src/score.h src/bonus.h
|
||||
|
||||
src/mario.h:
|
||||
|
||||
|
@ -14,5 +14,3 @@ src/keyboard.h:
|
|||
src/score.h:
|
||||
|
||||
src/bonus.h:
|
||||
|
||||
src/teleporteur.h:
|
||||
|
|
Binary file not shown.
|
@ -1,5 +1,5 @@
|
|||
build-fx/src/world.c.o: src/world.c src/world.h src/tile.h src/mario.h \
|
||||
src/box.h src/ennemi.h src/teleporteur.h src/bonus.h
|
||||
src/box.h src/ennemi.h src/bonus.h src/constants.h
|
||||
|
||||
src/world.h:
|
||||
|
||||
|
@ -11,6 +11,6 @@ src/box.h:
|
|||
|
||||
src/ennemi.h:
|
||||
|
||||
src/teleporteur.h:
|
||||
|
||||
src/bonus.h:
|
||||
|
||||
src/constants.h:
|
||||
|
|
Binary file not shown.
|
@ -60,7 +60,7 @@ INCLUDE := -I include
|
|||
# Libraries. Add one -l option for each library you are using, and also
|
||||
# suitable -L options if you have library files in custom folders. To use
|
||||
# fxlib, add libfx.a to the project directory and use "-L . -lfx".
|
||||
LIBS :=
|
||||
LIBS := -llog-fx
|
||||
|
||||
# Base linker flags for the fxSDK, you usually want to keep these.
|
||||
LDFLAGS_FX := -T fx9860g.ld -lgint-fx $(LIBS) -lgint-fx -lgcc
|
||||
|
|
19
src/box.c
19
src/box.c
|
@ -37,7 +37,7 @@ static void move_x(box_t * b)
|
|||
|
||||
int t_vx=((sgn_vx*b->vx+time_id%2)/2)*sgn_vx;
|
||||
sgn_vx=sgn(t_vx);
|
||||
|
||||
|
||||
if (sgn_vx)
|
||||
{
|
||||
for (int i=sgn_vx; i<=sgn_vx*t_vx; i++)
|
||||
|
@ -55,7 +55,7 @@ static void move_x(box_t * b)
|
|||
typetemp=world_get_ctg(b->x+b->w-1+i*sgn_vx,b->y+j);
|
||||
else
|
||||
typetemp=world_get_ctg(b->x+i*sgn_vx,b->y+j);
|
||||
if (/*typetemp==CTG_DEATH ||*/ typetemp==CTG_SOIL)
|
||||
if (/*typetemp==CTG_DEATH ||*/ typetemp==CTG_SOIL)
|
||||
{
|
||||
b->x+=(i-1)*sgn_vx;
|
||||
b->vx=0;
|
||||
|
@ -90,7 +90,7 @@ static void move_y(box_t * b)
|
|||
typetemp=world_get_ctg(b->x+j ,b->y+b->h-1+i);
|
||||
else
|
||||
typetemp=world_get_ctg(b->x+j ,b->y-i);
|
||||
if (/*typetemp==CTG_DEATH ||*/ typetemp==CTG_SOIL)
|
||||
if (/*typetemp==CTG_DEATH ||*/ typetemp==CTG_SOIL)
|
||||
{
|
||||
if (b->vy>0)
|
||||
{
|
||||
|
@ -121,23 +121,20 @@ static void move_y(box_t * b)
|
|||
b->vy=0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
b->y+=b->vy;
|
||||
}
|
||||
//if (b->vy>=-6)
|
||||
b->vy-=b->gravity;
|
||||
//if (b->vy>=-6)
|
||||
b->vy-=b->gravity;
|
||||
|
||||
}
|
||||
|
||||
int box_move(box_t * b)
|
||||
{
|
||||
//velx
|
||||
//velx
|
||||
move_x(b);
|
||||
move_y(b);
|
||||
}
|
||||
|
@ -151,8 +148,8 @@ int box_jump(box_t * b, int height)
|
|||
for (int j=0; j<b->h; j++)
|
||||
{
|
||||
int typetemp=world_get_ctg(b->x+j ,b->y+sgn_vy);
|
||||
if (/*typetemp==CTG_DEATH || */typetemp==CTG_SOIL)
|
||||
sol=1;
|
||||
if (/*typetemp==CTG_DEATH || */typetemp==CTG_SOIL)
|
||||
sol=1;
|
||||
}
|
||||
if (sol)
|
||||
b->vy=height;
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <liblog.h>
|
||||
#include <gint/display.h>
|
||||
#include <gint/keyboard.h>
|
||||
|
||||
extern image_t img_tickbox;
|
||||
|
||||
char loglevels[6][14]={"--all","--information","--warning","--critical","--fatal","--mute"};
|
||||
|
||||
void configmenu()
|
||||
{
|
||||
keyboard_clear();
|
||||
font_t* f=dfont(0);
|
||||
while (1)
|
||||
{
|
||||
dclear(C_WHITE);
|
||||
drect(0,0,128,7,C_BLACK);
|
||||
dtext(0,0,"Configuration Menu : ", C_WHITE, C_NONE);
|
||||
dtext(0,9," > LOG", C_BLACK, C_NONE);
|
||||
dtext(0,17," > LOG", C_BLACK, C_NONE);
|
||||
dtext(40,9,&loglevels[ll_get_level()][0],C_BLACK,C_NONE);
|
||||
dupdate();
|
||||
int key=getkey().key;
|
||||
if (key==KEY_EXIT)
|
||||
break;
|
||||
}
|
||||
keyboard_clear();
|
||||
dfont(f);
|
||||
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
void configmenu();
|
||||
|
||||
#endif
|
|
@ -6,4 +6,6 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
extern bool dark_theme_enable;
|
||||
extern bool is_in_water;
|
||||
extern bool is_in_water;
|
||||
|
||||
extern int frame_id;
|
|
@ -177,6 +177,7 @@ void move_ennemi(ennemi_t *e)
|
|||
else
|
||||
hurt_mario();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (e->type==KOOPA_V_ID)
|
||||
|
@ -212,6 +213,7 @@ void move_ennemi(ennemi_t *e)
|
|||
else
|
||||
hurt_mario();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (e->type==CARAPACE_VERTE)
|
||||
{
|
||||
|
@ -274,6 +276,7 @@ void move_ennemi(ennemi_t *e)
|
|||
hurt_mario();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -287,7 +290,6 @@ void display_ennemi_table()
|
|||
{
|
||||
for (int i=0; i<ennemis_global_size; i++)
|
||||
{
|
||||
move_ennemi(&ennemis_global[i]);
|
||||
display_ennemi(&ennemis_global[i]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <gint/display.h>
|
||||
#include <gint/timer.h>
|
||||
#include <gint/clock.h>
|
||||
#include "config.h"
|
||||
|
||||
mkey_t keys[6]={0};
|
||||
|
||||
|
@ -12,8 +13,15 @@ mkey_t keys[6]={0};
|
|||
|
||||
static int konami[]={KEY_UP,KEY_UP,KEY_DOWN,KEY_DOWN,KEY_LEFT,KEY_RIGHT,KEY_LEFT,KEY_RIGHT,KEY_ALPHA,KEY_SHIFT};
|
||||
|
||||
int menu_pause() // 1 exit, 0 continue
|
||||
void keyboard_clear()
|
||||
{
|
||||
for (int i=0; i<6; i++)
|
||||
keys[i]=0;
|
||||
clearevents();
|
||||
}
|
||||
|
||||
int menu_pause() // 1 exit, 0 continue
|
||||
{
|
||||
extern image_t img_menu_pause;
|
||||
extern image_t img_select_arrow;
|
||||
key_event_t e;
|
||||
|
@ -33,15 +41,22 @@ int menu_pause() // 1 exit, 0 continue
|
|||
while(e.type!=KEYEV_NONE)
|
||||
{
|
||||
if (keydown(KEY_EXE))
|
||||
return choice;
|
||||
if (keydown(KEY_UP))
|
||||
choice=0;
|
||||
if (keydown(KEY_DOWN))
|
||||
choice=1;
|
||||
{
|
||||
if (choice==2)
|
||||
configmenu();
|
||||
else
|
||||
return choice;
|
||||
}
|
||||
if (keydown(KEY_UP) && choice>0)
|
||||
choice--;
|
||||
if (keydown(KEY_DOWN) && choice<2)
|
||||
choice++;
|
||||
if (keydown(KEY_MENU))
|
||||
return 1;
|
||||
if (keydown(KEY_EXIT))
|
||||
return 0;
|
||||
if (keydown(KEY_OPTN))
|
||||
configmenu();
|
||||
if (keydown(KEY_F1))
|
||||
{
|
||||
e=pollevent();
|
||||
|
|
|
@ -15,4 +15,6 @@ extern mkey_t keys[6];
|
|||
|
||||
void update_keyboard();
|
||||
|
||||
void keyboard_clear();
|
||||
|
||||
#endif
|
|
@ -4,7 +4,7 @@
|
|||
#include "score.h"
|
||||
#include "ennemi.h"
|
||||
#include "keyboard.h"
|
||||
#include "teleporteur.h"
|
||||
//#include "teleporteur.h"
|
||||
#include <gint/display.h>
|
||||
#include <gint/std/stdlib.h>
|
||||
#include <gint/keyboard.h>
|
||||
|
@ -290,7 +290,7 @@ void set_level(int n)
|
|||
lvl=(world_t*)&level_0;
|
||||
extern image_t img_lvl0;
|
||||
w_fond=&img_lvl0;
|
||||
w_current_x=226;
|
||||
w_current_x=226;
|
||||
w_current_y=13;
|
||||
mario_x_max=0;
|
||||
mario.p.x=25;
|
||||
|
@ -313,11 +313,6 @@ void set_level(int n)
|
|||
GOOMBA(924,16,-1)
|
||||
};
|
||||
init_ennemies(ennemies0);
|
||||
|
||||
teleporteur_t t={/*464*/20,/*55*/20,1,-1/*MK_LITTLE*/,1704,12*8};
|
||||
teleporteurs=&t;
|
||||
nombre_teleporteurs=1;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
117
src/main.c
117
src/main.c
|
@ -1,6 +1,7 @@
|
|||
#include <gint/display.h>
|
||||
#include <gint/keyboard.h>
|
||||
#include <gint/timer.h>
|
||||
#include <liblog.h>
|
||||
|
||||
#include "world.h"
|
||||
#include "mario.h"
|
||||
|
@ -18,75 +19,79 @@ extern image_t img_error;
|
|||
GNORETURN void system_error(uint32_t code)
|
||||
{
|
||||
timer_stop(0);
|
||||
dimage(0,0,&img_error);
|
||||
dupdate();
|
||||
while(1) getkey();
|
||||
dimage(0,0,&img_error);
|
||||
dupdate();
|
||||
while(1) getkey();
|
||||
}
|
||||
|
||||
int frame_id;
|
||||
int callback(volatile void *arg)
|
||||
{
|
||||
volatile int *has_ticked = arg;
|
||||
*has_ticked = 1;
|
||||
return 0;
|
||||
volatile int *has_ticked = arg;
|
||||
*has_ticked = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
extern font_t font_mario;
|
||||
dfont(&font_mario);
|
||||
gint_panic_set(system_error);
|
||||
volatile int has_ticked = 1;
|
||||
extern font_t font_mario;
|
||||
dfont(&font_mario);
|
||||
//gint_panic_set(system_error);
|
||||
ll_set_panic();
|
||||
volatile int has_ticked = 1;
|
||||
|
||||
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)
|
||||
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)
|
||||
{
|
||||
has_ticked=0;
|
||||
has_ticked=0;
|
||||
frame_id++;
|
||||
//mario_move();
|
||||
|
||||
world_move();
|
||||
dclear(C_WHITE);
|
||||
world_draw(mario.p.x,mario.p.y);
|
||||
score_display();
|
||||
world_move();
|
||||
dclear(C_WHITE);
|
||||
world_draw(mario.p.x,mario.p.y);
|
||||
score_display();
|
||||
|
||||
dupdate();
|
||||
if (mario_dead==1)
|
||||
{
|
||||
mario_dead=0;
|
||||
finish_level=0;
|
||||
dupdate();
|
||||
if (mario_dead==1)
|
||||
{
|
||||
mario_dead=0;
|
||||
finish_level=0;
|
||||
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
timer_stop(0);
|
||||
timer_stop(0);
|
||||
}
|
||||
|
|
15
src/mario.c
15
src/mario.c
|
@ -7,7 +7,6 @@
|
|||
#include "box.h"
|
||||
#include "score.h"
|
||||
#include "bonus.h"
|
||||
#include "teleporteur.h"
|
||||
|
||||
static int sgn(int x)
|
||||
{
|
||||
|
@ -131,12 +130,12 @@ void mario_move()
|
|||
int jump = keys[MK_JUMP1] || keys[MK_JUMP2];
|
||||
if (keys[MK_JUMP1]==2 || keys[MK_JUMP2]==2)
|
||||
{
|
||||
if (mario.p.vx*sgn(mario.p.vx)>=6)
|
||||
if (mario.p.vx*sgn(mario.p.vx)>=6)
|
||||
box_jump(&mario.p, 9);
|
||||
else
|
||||
box_jump(&mario.p, 8);
|
||||
}
|
||||
else if (mario.p.vy>=6 && jump==0)
|
||||
else if (mario.p.vy>=6 && jump==0)
|
||||
mario.p.vy=5;
|
||||
|
||||
int vx=sgn(keys[MK_RIGHT] - keys[MK_LEFT]);
|
||||
|
@ -156,7 +155,7 @@ void mario_move()
|
|||
{
|
||||
if (keys[MK_RUN] && (c1==CTG_SOIL || c2==CTG_SOIL))
|
||||
{
|
||||
if(mario.p.vx*sgn(mario.p.vx)<=8)
|
||||
if(mario.p.vx*sgn(mario.p.vx)<=8)
|
||||
mario.p.vx+=vx;
|
||||
}
|
||||
else
|
||||
|
@ -207,7 +206,7 @@ void mario_move()
|
|||
mario.p.vx=0;
|
||||
mario.p.x=world_get_real_x0(mario.p.x);
|
||||
}
|
||||
teleporteurs_check();
|
||||
//teleporteurs_check();
|
||||
box_move(&mario.p); // <-> + gravity
|
||||
|
||||
if (mario.p.y<0)
|
||||
|
@ -220,13 +219,13 @@ void mario_move()
|
|||
c=(coin_t*)world_get(mario.p.x, mario.p.y);
|
||||
if (c->type==COIN && c->taken==0)
|
||||
{score_add_coin();c->taken=1;}
|
||||
c=(coin_t*)world_get(mario.p.x+mario.p.w-1, mario.p.y);
|
||||
c=(coin_t*)world_get(mario.p.x+mario.p.w-1, mario.p.y);
|
||||
if (c->type==COIN && c->taken==0)
|
||||
{score_add_coin();c->taken=1;}
|
||||
c=(coin_t*)world_get(mario.p.x, mario.p.y+mario.p.h-1);
|
||||
c=(coin_t*)world_get(mario.p.x, mario.p.y+mario.p.h-1);
|
||||
if (c->type==COIN && c->taken==0)
|
||||
{score_add_coin();c->taken=1;}
|
||||
c=(coin_t*)world_get(mario.p.x+mario.p.w-1, mario.p.y+mario.p.h-1);
|
||||
c=(coin_t*)world_get(mario.p.x+mario.p.w-1, mario.p.y+mario.p.h-1);
|
||||
if (c->type==COIN && c->taken==0)
|
||||
{score_add_coin();c->taken=1;}
|
||||
|
||||
|
|
17
src/world.c
17
src/world.c
|
@ -2,9 +2,12 @@
|
|||
#include "tile.h"
|
||||
#include "mario.h"
|
||||
#include "ennemi.h"
|
||||
#include "teleporteur.h"
|
||||
#include <gint/display.h>
|
||||
#include "bonus.h"
|
||||
#include <liblog.h>
|
||||
#include "constants.h"
|
||||
#include "ennemi.h"
|
||||
|
||||
world_t * w_current=0;
|
||||
image_t * w_fond=0;
|
||||
int w_current_x=0;
|
||||
|
@ -210,12 +213,22 @@ void world_draw(int x, int y)
|
|||
|
||||
}
|
||||
//teleporteurs_display();
|
||||
dvline(teleporteurs[0].x-world_get_real_x0(),C_BLACK);
|
||||
//dvline(teleporteurs[0].x-world_get_real_x0(),C_BLACK);
|
||||
}
|
||||
|
||||
void world_move()
|
||||
{
|
||||
ll_sendp(LEVEL_INFO,"\n[I;%d] Refresh wrld",frame_id);
|
||||
for (int i=0; i<ennemis_global_size; i++)
|
||||
{
|
||||
move_ennemi(&ennemis_global[i]);
|
||||
}
|
||||
ll_sendp(LEVEL_INFO,"\n > Moved ennemies");
|
||||
bonus_move();
|
||||
ll_sendp(LEVEL_INFO,"\n > Moved bonus");
|
||||
bullet_move();
|
||||
ll_sendp(LEVEL_INFO,"\n > Moved bullets");
|
||||
mario_move();
|
||||
ll_sendp(LEVEL_INFO,"\n > Moved mario !\n");
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue