Compare commits

..

No commits in common. "master" and "master" have entirely different histories.

35 changed files with 162 additions and 182 deletions

3
.gitignore vendored
View File

@ -9,6 +9,3 @@ generated/
# fxlink screenshots
fxlink-*.png
# pictures
pictures/

View File

@ -46,8 +46,7 @@ add_custom_command(
editor/levels/16.lvl
editor/levels/17.lvl
editor/levels/18.lvl
editor/levels/19.lvl
editor/levels/20.lvl)
editor/levels/19.lvl)
set(SOURCES
src/collide.c

Binary file not shown.

Before

Width:  |  Height:  |  Size: 250 B

After

Width:  |  Height:  |  Size: 247 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1010 B

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

@ -51,7 +51,7 @@ def place():
if gravityid==7: levelgr = font.render("",1,(0,120,120))
timeapp = font.render("A="+str(app),1,(255,230,0))
timedisa = font.render("D="+str(disa)+" LOCK : "+str(lock),1,(255,180,0))
nbswitchfont = font.render("Nb="+str(nbswitchmax),1,(255,230,0))
nbswitchfont = font.render("Nb="+str(nbswitch),1,(255,230,0))
for a in range(14):
for b in range(25):
pygame.draw.rect(fenetre,(255,255,255),((52*b, 52*a), (52, 52)))

View File

@ -13,18 +13,17 @@ Pour ouvrir (python3 + pygame):
- S baisser temps avant apparition blocs +
- R augmenter temps avant disparition blocs - (temps affiché en haut à gauche)
- F baisser temps avant disparition blocs -
- T augmenter le nombre de switch possibles dans le niveau (nécessite le bloc d'activation)
- G baisser le nombre de switch possibles dans le niveau
- SHIFT changer le sens de la gravité par défaut (gravité affichée en haut à gauche)
- TAB Afficher le design des blocs non activé
- A supprime le bloc bloqué dans la main.
- N pour reset la pièce en entier
Click gauche : tourner parmis les blocs
Click droit : supprimer le bloc
Click gauche : tourner parmis les blocs dans le sens horaire
Click droit : tourner parmis les blocs dans le sens anti-horaire
Click molette centrale sur un bloc : bloquer ce bloc dans la main, permet de placer plusieurs fois le même bloc rapidement. (bloc bloqué affiché en haut)
Click gauche après molette : placer le bloc
Click droit après molette : supprimer le bloc
## Sauvegarde :
@ -32,4 +31,4 @@ L'éditeur sauvegarde automatiquement les niveaux à chaques actions.
`$ ./build.sh` pour construire l'application depuis ces niveaux.
Tituya
by Tituya

View File

@ -1,4 +1,4 @@
111111rrrrriiiiiii11000111000000000000000000000001100000000000000000000000110e0000b00z000l00S000000111111aaaaaaa11111111111111ddd1ddddddd1mmm1000000011ddd111111111mmm1000000011ddd111111111ccc101BB00011ddd1ddddddd1ccc10i00000111111aaaaaaa111110i000001100000000000030010i0000011000000000000300h0i1BBB111s000K00000k0300h0i0000011111111ddd1111111111000116
11111111111111111111000111000000000000000000000001100000000000000000000000110e00000b0000l000S000000111111aaaaaaa11111111111111ddd1ddddddd1mmm1000000011ddd111111111mmm1000000011ddd111111111ccc101BB00011ddd1ddddddd1ccc10i00000111111aaaaaaa111110i000001100000000000030010i0000011000000000000300h0i1BBB111s000K00000k0300h0i0000011111111ddd1111111111000116
6
9
20
1

View File

@ -1,4 +1,4 @@
dddddddddddddddddddddddddBBBBBBBBBBBBBBBBBBBBBBBBB100001kk10011111dt0a000011000010010010000d11a00001100001BB100100000000000013000000000010001110000000300000000001aaaaaa0000000111111000001000000001111110dd00000001000000001000110000000a001BBBd00a0100013000000000010001000010003300s000000010K0100001e003aaBBBBBBBBBBBBBBBBBBBaaaaddddddddddddddddddddddddd6
11111111t133111111100011111111111133311111110K01111100000100111111111000111110s00010i11111100000001111d110K10i11111d000000011111110K10i1111a001BBBBB11110000010i111d0a010000011110000010i11a03011d0ddd1111001ddd0i1d0a0d110000011110000000i0a30111100e00111100000k0130ad11110aa001111dd000001031111111ddd11111111111B1001111111aaa11111111111010011111110001116
13
10
1

View File

@ -1,4 +1,4 @@
00000ddddddd100000000000011111111111111111110011111000000dd1111ddd0K10000b1100111000000100000100000110000100000010000010010011000k111dd101dd00d10000011000110000001000001BBBB011000100011dd1000001dddd01100010ddd1dd1d00dd1011001133310ddd1dd1BBBBB1t00001100000ddd1dd1000001ddd1111s0000ddd1dd10000011111111BBB111aaaaa110001111111100000000000e10000000000006
1ddddddddddd11dddddddddd11dddddddddd00000dd3aaa11i1dd111100000000000030000i1dd000000000001110003000i1d000001111100K000003000i1d00000S00k0000000003aBB110s000100000ddd011103atl11111331ddddddddddddddd1111ddd001dddddddd11d0S0ddd11ddd00d1dd11d000300000dd11ddd000000000000300000dd11dddaaa00000000d3S00e0dd11dddddd00S0d111d3d000ddd11ddddddddddddddddddddddd16
13
10
1

View File

@ -1,4 +1,4 @@
1111111111111ddd11iK1d00100000d111000000011it1d00000000d100000000011i31110011100d13331110e011ihhh11100000d100011111111i00000000000d100000011111i00111011100d1000000000011000s111111111000000000011dd0001hk001111i00Sddd001dddd00hh0000001i000111000aad1ddhddd0000000001110000001111111dd0000000111000000001111111dd000011110000000001111111111111111ddd13100017
1111111111010001dd11111110000001000013331001000000000000100t01000h0010000001111iB111111000h0013311111e00ik11d111000300300000d10ddi011d0010003003000s0d10aai01000010001hh1hh11111000i01h1h1100010010000011dd0i000000h00010010001a11aa01dd0dd110001001000h0110001dd1d1110S0100100010110000S0S0001ddd100h0001Kd100000S0S001111100h00011111111dddd10h00011111111116
13
10
1

4
editor/levels/13.lvl Normal file → Executable file
View File

@ -1,4 +1,4 @@
1333111111111111iiii11111i000d1iii1iiii000000d0001i0000iiii1iiii000000d0e0ii000000001iii1000000d000ii000000001iid1aaa0000000ii00S000000000000a000S000i1t000K00000S0000i1rr1iid111iiii1ii1rrr1iiid000000i10k00000000000000000i000i10000000000000000000i000i1333rrii11iiiirriii11000i100000000000000000000000i10s0000000000000000000S011333iiirriirriii111iiii116
8
11111111111111111111111111ddddddddd0S00ddddddddddd1ddddaaaaa000000ddddddddd1ddd00S000000e0ddd0dddddd1dd000000ddddddd00000dddd1daaaa00dd11100S00S000ddd10000000d00000000000S00dd10K000h0d00001100000000dd1111000ddd000000S0d0h00dd1ddd000dd000dd000ddd000dd1dddhhdd000ddddddddd000dd1ddb00S0000100000dd0000dd1dtb00000011s000000000ddd111111d11111111111111dddd6
13
10
1

View File

@ -1,4 +1,4 @@
1111111111010001dd11111110000001000013331001000000000000100t01000h0010000001111iB111111000h0013311111e00ik11d111000300300000d10ddi011d0010003003000s0d10aai01000010001hh1hh11111000i01h1h1100010010000011dd0i000000h00010010001a11aa01dd0dd110001001000h0110001dd1d1110S0100100010110000S0S0001ddd100h0001Kd100000S0S001111100h00011111111dddd10h00011111111116
1111111111111ddd11iK1d00100000d111000000011it1d00000000d100000000011i31110011100d13331110e011ihhh11100000d100011111111i00000000000d100000011111i00111011100d1000000000011000s111111111000000000011dd0001hk001111i00Sddd001dddd00hh0000001i000111000aad1ddhddd0000000001110000001111111dd0000000111000000001111111dd000011110000000001111111111111111ddd13100017
13
10
1

View File

@ -1,4 +1,4 @@
11111111111111111111111111ddddddddd0S00ddddddddddd1ddddaaaaa000000ddddddddd1ddd00S000000e0ddd0dddddd1dd000000ddddddd00000dddd1daaaa00dd11100S00S000ddd10000000d00000000000S00dd10K000h0d00001100000000dd1111000ddd000000S0d0h00dd1ddd000dd000dd000ddd000dd1dddhhdd000ddddddddd000dd1ddb00S0000100000dd0000dd1dtb00000011s000000000ddd111111d11111111111111dddd6
13
10
i011100dd1111dddm111ddmd1i01d1000000010S0011100S01i01d100000001000000000001i01d1cc111001hh1c11111001i01ddddddi00i000bddd00001i01dd1133i00i000lddd000K1100000000i00i00001d110011300000000i00100331d100003300000010i001s03t1d1000031111100hki0011111ddd1BB1110S01hh11100m0000aaa0000110001001d100m000000000001100e1001d100m0aaa000aaa0110d11001111111ddddddddd116
4
7
1

View File

@ -1,4 +1,4 @@
11111111t133111111100011111111111133311111110K01111100000100111111111000111110s00010i11111100000001111d11zz10i11111d000000011111110010i1111a001BBBBB11110000010i111d0a010000011110000010i11a03011d0ddd1111001ddd0i1d0a0d110000011110000000i0a30111100e001111K0000k0130ad11110aa001111d0000001031111111ddd11111111111B1001111111aaa11111111111010011111110001116
13
11111dddd100d110111111331000000000000d1d0000dd10s0111d00000000K1d10000d11111ddddd11ddhh1dddd000dddd11100Sh00dd00000dd00000001i0000000dd000000d0000S001i01100d0dd00d000dd0000001i0d00Sd0dd00dd10ddhh00l01i0ddddd0dd00ddi0d00000001iBBBdd0011aaddi0d0S00d0011000dd000300ddi0d0000d00110mmdd000d00ddi0dd00dd0011emtdddddd00ddi0ddddddkk1111111111100111Bdddd110016
14
10
10
1

6
editor/levels/18.lvl Executable file → Normal file
View File

@ -1,4 +1,4 @@
i011100dd1111dddm111ddmd1i01d1000000010S0011100S01i01d100000001000000000001i01d1cc111001hh1c11111001i01ddddddi00i000bddd00001i01dd1133i00i000lddd000K1100000000i00i00001d110011300000000i00100331d100003300000010i001s03t1d1000031111100hki0011111ddd1BB1110S01hh11100m0000aaa0000110001001d100m000000000001100e1001d100m0aaa000aaa0110d11001111111ddddddddd116
4
7
111111110011ddd111111111110000001000S000S0d000000110000001000000000d0000s0111mmm101aaa000000d00BBB31100m01010a0000000d00B0Bb1100m01h10a00dKdhi0i0BBB011d0m01h10a00d0d00i00B0B011d0001h10000dSd00i00d00011d00d1h10000ddd00iBBd0t01h000d101dddd11100000d000h1000d1011111111331111111130000100000ddd000000100003000110000000000000k10e00111111110011111ddd11111116
8
10
1

4
editor/levels/19.lvl Executable file → Normal file
View File

@ -1,4 +1,4 @@
11111dddd100d110111111331000000000000d1d0000dd10s0111d00000000K1d10000d11111ddddd11ddhh1dddd000dddd11100Sh00dd00000dd00000001i0000000dd000000d0000S001i01100d0dd00d000dd0000001i0d00Sd0dd00dd10ddhh00l01i0ddddd0dd00ddi0d00000001iBBBdd0011aaddi0d0S00d0011000dd000300ddi0d0000d00110mmdd000d00ddi0dd00dd0011emtdddddd00ddi0ddddddkk1111111111100111Bdddd110016
14
1333111111111111iiii11111i000d1iii1iiii000000d0001i0000iiii1iiii000000d0e0ii000000001iii1000000d000ii000000001iid1aaa0000000ii00S000000000000a000S000i10000K00000S0000i1rr1iid111iiii1ii1rrr1iiid000000i10k00000000000000000i000i10000000000000000000i000i1333rrii11iiiirriii11000i100000000000000000000000i10s0000000000000000000S011333iiirriirriii111iiii116
8
10
1

6
editor/levels/2.lvl Normal file → Executable file
View File

@ -1,4 +1,4 @@
1111d1d1111111111111111111e01010111100000s01d000d1100001011110001ddd1d000d11d00000111100011111d0k0d11d0d0000001000000000000011d0d0d0000100000000000001111ddd11001000000t0000001100000000011111dd1dd1133110000000001000aaad1111001100111dd111000000d000000110000000003000d00d000000110000000003000d00000d00011000d000003000d00K00d000111111111111111111111111117
8
10
1dddddd100111111111111111000000000011111000000000000000000l01100c00000000001aaaaaaa111100c00000000011dddddddddd1001aaaaaaaaa11cccccccccc1001ddddddddd1000000000001331000000aa000000000000s10e1k0000000001ccccccccc111111111113311100000000011001000000000110000000001100b0000000001100000000011t0b00000000011000K0000011111aaaaaaaaa1111111110011111ddddddddd16
13
2
1

View File

@ -1,4 +0,0 @@
111111110011ddd111111111110000001000S000S0d000000110000001000000000d0000s0111mmm101aaa000000d00BBB31100m01010a0000000d00B0Bb1100m01h10a00dKdhi0i0BBB011d0m01h10a00d0d00i00B0B011d0001h10000dSd00i00d00011d00d1h10000ddd00iBBd0t01h000d101dddd11100000d000h1000d1011111111331111111130000100000ddd000000100003000110000000000000k10e00111111110011111ddd11111116
8
10
1

View File

@ -1,4 +1,4 @@
1dddddd1001111111111111110000000000111110000000000000000l0001100c00000000001aaaaaaa111100c00000000011dddddddddd1001aaaaaaaaa11cccccccccc1001ddddddddd1000000000001331000000aa000000000000s10e1k0000000001ccccccccc111111111113311100000000011001000000000110000000001100b0000000001100000000011t0b00000000011000K0000011111aaaaaaaaa1111111110011111ddddddddd16
11001111111001111111111111000111dddd000000000100013000111dddd00000000010003300000000dd11111000010e03100000000dd03a01000011111111110000dd03a01000000001100s1dd00ddt3a0100000000110001dd00dd1110100000000110001dd0Kdd00001ddd000ddd10001dd00dd00001111100ddd10001dd00dd00001000000ddd30001dd0000000010k000000330001dd0000000010000000031d001111111001111111111117
13
2
10
1

View File

@ -1,4 +1,4 @@
11001111111001111111111111000111dddd000000000100013000111dddd00000000010003300000000dd11111000010e03100000000dd03a01000011111111110000dd03a01000000001100s1dd00ddt3a0100000000110001dd00dd1110100000000110001dd0Kdd00001ddd000ddd10001dd00dd00001111100ddd10001dd00dd00001000000ddd30001dd0000000010k000000330001dd0000000010000000031d001111111001111111111117
000000000000000000000000000000000000000000000000t000000000000000000000000000011dd111111111111111110000100000100000010000001000011cc001s0000d00000001000010000e111dd0100000dd100001001111000d0000000dd100001000001000111d000ddd1000010000000000000000ddd1000011111111111d111B11111000000000000000000000000000000000000000000000000000000000000000000000000000006
13
10
6
1

View File

@ -1,4 +1,4 @@
000000000000000000000000000000000000000000000000t000000000000000000000000000011dd111111111111111110000100000100000010000001000011cc001s0000d00000001000010000e111dd0100000dd100001001111000d0000000dd100001000001000111d000ddd1000010000000000000000ddd1000011111111111d111B11111000000000000000000000000000000000000000000000000000000000000000000000000000006
13
6
10001011111011111111111111000101dd10001111dddd11110000101dd10001000000000001111101dd1aaa1000ccccddd110s00010013331000000000011dddd110010001mmmdd00000100000000010e010t0dd00000011111100011111d1dddddd1111k00000001d000111001111111111111101d00000000000111000010000100000000000000010K010000100011100000011110001000010001110000dd11110001011111011111111111117
5
9
1

View File

@ -1,4 +1,4 @@
1ddddddddddd11dddddddddd11dddddddddd00000dd3aaa11i1dd111100000000000030000i1dd000000000001110003000i1d000001111100K000003000i1d00000S00k0000000003aBB110s000100000ddd011103atl11111331ddddddddddddddd1111ddd001dddddddd11d0S0ddd11ddd00d1dd11d000300000dd11ddd000000000000300000dd11dddaaa00000000d3S00e0dd11dddddd00S0d111d3d000ddd11ddddddddddddddddddddddd16
dddddddddddddddddddddddddBBBBBBBBBBBBBBBBBBBBBBBBB100001kk10011111dt0a000011000010010010000d11a00001100001BB100100000000000013000000000010001110000000300000000001aaaaaa0000000111111000001000000001111110dd00000001000000001000110000000a001BBBd00a0100013000000000010001000010003300s000000010K0100001e003aaBBBBBBBBBBBBBBBBBBBaaaaddddddddddddddddddddddddd6
13
10
1

View File

@ -1,4 +1,4 @@
10001011111011111111111111000101dd10001111dddd11110000101dd10001000000000001111101dd1aaa1000ccccddd110s00010013331000000000011dddd110010001mmmdd00000100000000010e010t0dd00000011111100011111d1dddddd1111k00000001d000111001111111111111001d00000000000111000010000100000000000000010K010000100011100000011110001000010001110000dd11110001011111011111111111117
5
9
00000ddddddd100000000000011111111111111111110011111000000dd1111ddd0K10000b1100111000000100000100000110000100000010000010010011000k111dd101dd00d10000011000110000001000001BBBB011000100011dd1000001dddd01100010ddd1dd1d00dd1011001133310ddd1dd1BBBBB1t00001100000ddd1dd1000001ddd1111s0000ddd1dd10000011111111BBB111aaaaa110001111111100000000000e10000000000006
13
10
1

View File

@ -1,8 +1,6 @@
#pragma once
char collide(int x, int y, char level[], char block);
char collide_gravity(int x, int y, char level[], char gravity, char block);
char collide_solid_gravity(int x, int y, char level[], char gravity);
char collide_solid(int x, int y, char level[]);
char collide_dead(int x, int y, char level[]);
char collide_point(int x, int y, char level[], char block);

3
include/menu.h Normal file → Executable file
View File

@ -5,5 +5,4 @@ enum MenuPause { MenuContinue, MenuBack };
enum MenuCode start_menu();
char level_selection(int *id_level);
enum MenuPause pause_menu(char level[], int id_level, int coin,
int death_count);
enum MenuPause pause_menu(char level[], int id_level, int coin, int death_count);

View File

@ -1,6 +1,6 @@
#pragma once
void set_level(int id_level, char level[], int *startx, int *starty,
char *gravity, int *appear, int *disappear, int *nbswitch);
void set_level(int id_level, char level[], int *startx, int *starty, char *gravity,
int *appear, int *disappear, int *nbswitch);
void set_gravity(int id_level, char *default_gravity);
void del_level(char level[]);

View File

@ -2,5 +2,4 @@
int round(float num);
int round_sup(float num);
int rand_range(int low, int high);
int sign(float x);
int rand_range(int low, int high);

View File

@ -7,27 +7,20 @@
char collide(int x, int y, char level[],
char block) // detect if player is in a block
{
if(collide_point(x, y, level, block) ||
collide_point(x + PLAYER_HEIGHT, y, level, block) ||
collide_point(x, y + PLAYER_HEIGHT, level, block) ||
collide_point(x + PLAYER_HEIGHT, y + PLAYER_HEIGHT, level, block))
if ((level[(int)(x / TILE_HEIGHT) +
(int)((y + PLAYER_HEIGHT) / TILE_HEIGHT) * LEVEL_WIDTH] ==
block ||
level[(int)((x + PLAYER_HEIGHT) / TILE_HEIGHT) +
(int)((y + PLAYER_HEIGHT) / TILE_HEIGHT) * LEVEL_WIDTH] ==
block ||
level[(int)(x / TILE_HEIGHT) +
(int)((y / TILE_HEIGHT) * LEVEL_WIDTH)] == block ||
level[(int)((x + PLAYER_HEIGHT) / TILE_HEIGHT) +
(int)((y / TILE_HEIGHT) * LEVEL_WIDTH)] == block))
return 1;
return 0;
}
char collide_gravity(int x, int y, char level[], char gravity, char block) {
if(gravity == 1) {
if(collide_point(x, y + PLAYER_HEIGHT, level, block) ||
collide_point(x + PLAYER_HEIGHT, y + PLAYER_HEIGHT, level, block))
return 1;
} else {
if(collide_point(x, y, level, block) ||
collide_point(x + PLAYER_HEIGHT, y, level, block))
return 1;
}
return 0;
}
char collide_solid(int x, int y, char level[])
{
return collide(x, y, level, '1') || collide(x, y, level, '3') ||
@ -37,15 +30,6 @@ char collide_solid(int x, int y, char level[])
collide(x, y, level, 'r');
}
char collide_solid_gravity(int x, int y, char level[], char gravity)
{
return collide_gravity(x, y, level, gravity, '1') || collide_gravity(x, y, level, gravity, '3') ||
collide_gravity(x, y, level, gravity, '4') || collide_gravity(x, y, level, gravity, 'c') ||
collide_gravity(x, y, level, gravity, 'C') || collide_gravity(x, y, level, gravity, 'B') ||
collide_gravity(x, y, level, gravity, 'i') || collide_gravity(x, y, level, gravity, 'H') ||
collide_gravity(x, y, level, gravity, 'r');
}
char collide_dead(int x, int y, char level[])
{
return collide_point(x + DEAD_COLLISION, y + DEAD_COLLISION, level,

View File

@ -6,8 +6,9 @@ void mod_accel_and_fric(float *acceleration, float *friction, int x, int y,
{
*acceleration = HACCELERATION;
*friction = HFRICTION;
if (!mod_ice(acceleration, friction, x, y, level) &&
!mod_rough(acceleration, friction, x, y, level))
if(!mod_rough(acceleration, friction, x, y, level))
mod_solid(acceleration, friction, x, y, level);
if(!mod_ice(acceleration, friction, x, y, level))
mod_solid(acceleration, friction, x, y, level);
}
@ -24,8 +25,8 @@ int mod_ice(float *acceleration, float *friction, int x, int y, char level[])
int mod_rough(float *acceleration, float *friction, int x, int y, char level[])
{
if (collide(x, y - 1, level, 'r') || collide(x, y + 1, level, 'r')) {
*friction *= 3.0;
*acceleration *= 2.0;
*friction *= 3;
*acceleration *= 2;
return 1;
}
return 0;

View File

@ -1,27 +1,27 @@
/*
* @author : Tituya x KikooDX
*/
* @author : Tituya x KikooDX
*/
#include <gint/clock.h>
#include <gint/display.h>
#include <gint/gint.h>
#include <gint/keyboard.h>
#include <gint/rtc.h>
#include <gint/std/stdlib.h>
#include <gint/std/string.h>
#include <gint/timer.h>
#include <gint/std/stdlib.h>
#include <gint/rtc.h>
#include <gint/usb-ff-bulk.h>
#include "collide.h"
#include "define.h"
#include "drawlevel.h"
#include "friction.h"
#include "menu.h"
#include "replace.h"
#include "save.h"
#include "setlevel.h"
#include "times.h"
#include "util.h"
#include "friction.h"
#define VACCELERATION 0.2
#define MAX_VSPD 9.0
@ -30,10 +30,9 @@ static void startmenu_launcher();
static int callback(volatile int *frame_elapsed);
static void game(int *id_level, char mode, char *type);
int main(void)
{
int main(void) {
/* open USB for fxlink screenshots */
usb_interface_t const *interfaces[] = {&usb_ff_bulk, NULL};
usb_interface_t const *interfaces[] = { &usb_ff_bulk, NULL };
usb_open(interfaces, GINT_CALL_NULL);
gint_world_switch(GINT_CALL(restore));
@ -47,32 +46,29 @@ int main(void)
return 0;
}
static void startmenu_launcher()
{
static void startmenu_launcher() {
char type = 1;
int menu_run = 1;
int id_level = 1;
while (menu_run) {
while(menu_run) {
const enum MenuCode valeur = start_menu(&type);
switch (valeur) {
case MenuLevelSel: {
if (id_level == 0)
switch(valeur) {
case MenuLevelSel: {
int doIRun = level_selection(&id_level);
if(doIRun)
game(&id_level, 1, &type);
} break;
case MenuAllMode: {
id_level = 1;
int doIRun = level_selection(&id_level);
if (doIRun)
game(&id_level, 0, &type);
} break;
case MenuTutorial: {
id_level = 0;
game(&id_level, 1, &type);
} break;
case MenuAllMode: {
id_level = 1;
game(&id_level, 0, &type);
} break;
case MenuTutorial: {
id_level = 0;
game(&id_level, 1, &type);
} break;
case MenuExit: {
menu_run = 0;
} break;
} break;
case MenuExit: {
menu_run = 0;
} break;
}
}
}
@ -120,8 +116,7 @@ static void game(int *id_level, char mode, char *type)
float friction;
float acceleration;
/*KikooDX level*/
if (*id_level == 16 && *type != 3)
if (*id_level == 10 && *type != 3)
*type = 2;
else if (*type != 3)
*type = 1;
@ -170,6 +165,7 @@ static void game(int *id_level, char mode, char *type)
coin);
if (check_nbswitch)
draw_nbswitch(nbswitch);
dprint(330, 0, C_RED, "%d", (int)(hspd*100));
dupdate();
if (keydown(KEY_VARS) && usb_is_open())
usb_fxlink_screenshot(1);
@ -184,23 +180,28 @@ static void game(int *id_level, char mode, char *type)
// right and left movement + collision
int signe = (keydown(KEY_RIGHT) - keydown(KEY_LEFT));
mod_accel_and_fric(&acceleration, &friction, player_x, player_y,
level);
hspd *= (1 - friction);
mod_accel_and_fric(&acceleration, &friction, player_x, player_y, level);
hspd *= 1 - friction;
hspd += signe * acceleration;
/* speed reminder */
/* TODO
* Please note than `hrem` should be reset after horizontal collision
* with a wall, death or level change. This is necessary to avoid
* cross-level jank/garbage data to be carreid that would ultimatly
* introduce inconsistancies. I didn't do it myself 'cause I couldn't
* find were to do this.
* -- KikooDX */
const float spd_n_rem_x = hspd + hrem;
const int spd_x = (int)spd_n_rem_x;
hrem = spd_n_rem_x - (float)spd_x;
player_x += spd_x;
while (collide_solid(player_x, player_y, level)) {
player_x -= sign(spd_x);
hspd = 0;
hrem = 0;
}
if (!collide_solid(player_x + round(hspd) + signe * 1,
player_y, level))
player_x += round(hspd);
else if (!collide_solid(player_x + signe * 1, player_y,
level))
player_x += signe;
if (player_x >= 388)
player_x = -4;
if (player_x < -9)
@ -208,8 +209,10 @@ static void game(int *id_level, char mode, char *type)
// Action key
if (keydown(KEY_SHIFT) && !check && nbswitch > 0 &&
(collide_solid_gravity(player_x, player_y - 1, level, gravity) ||
collide_solid_gravity(player_x, player_y + 1, level, gravity))) {
((collide_solid(player_x, player_y - 1, level) &&
gravity == -1) ||
(collide_solid(player_x, player_y + 1, level) &&
gravity))) {
vspd = 1;
if (gravity == -1)
gravity = 1;
@ -266,7 +269,7 @@ static void game(int *id_level, char mode, char *type)
}
// Collide with the end
if (collide_end(player_x, player_y, level)) {
// if all mode
//if all mode
if (!mode) {
*id_level += 1;
check_coin = 0;
@ -277,21 +280,21 @@ static void game(int *id_level, char mode, char *type)
hrem = 0.00;
set_level(*id_level, level, &start_x, &start_y,
&gravity, &appear, &disappear,
&nbswitch);
&gravity, &appear, &disappear, &nbswitch);
player_x = start_x;
player_y = start_y;
if (*id_level == 10 && *type == 1)
*type = 2;
*type = 2;
else if (*type != 3)
*type = 1;
// End of all mode
//End of all mode
if (*id_level == LEVEL_MAX + 1) {
timer_stop(timer);
game_loop = 0;
}
} else {
}
else {
game_loop = 0;
}
hasReachedEnd = 1;
@ -398,6 +401,7 @@ static void game(int *id_level, char mode, char *type)
// Appear block
collide_replace(player_x, player_y, level, 'h', 'y');
// Appear block
if (!collide(player_x, player_y, level, 'y') && double_check) {
for (int i = 0; level[i] != '\0'; i++) {
if (level[i] == 'y' || level[i] == 'h') {
@ -436,28 +440,26 @@ static void game(int *id_level, char mode, char *type)
// Pause menu
if (keydown_any(KEY_EXIT, KEY_MENU, 0)) {
timer_pause(timer);
const enum MenuPause valeur =
pause_menu(level, *id_level, coin, death_count);
switch (valeur) {
case MenuContinue: {
timer_start(timer);
check = 1; // prevent for switch when back to
// the level
} break;
case MenuBack: {
game_loop = 0;
hasReachedEnd = 0;
} break;
const enum MenuPause valeur = pause_menu(level, *id_level, coin, death_count);
switch(valeur) {
case MenuContinue: {
timer_start(timer);
check = 1; //prevent for switch when back to the level
} break;
case MenuBack: {
game_loop = 0;
hasReachedEnd = 0;
} break;
}
}
}
timer_stop(timer);
// when a level is quit
// if level selection
//if level selection
if (mode == 1 && *id_level != 0) {
if (hasReachedEnd) {
if(hasReachedEnd) {
float framefloat = framelevel;
draw_end(framelevel, *id_level, 0);
savetime(framefloat, *id_level);
@ -465,9 +467,9 @@ static void game(int *id_level, char mode, char *type)
}
int doIRun = level_selection(id_level);
if (doIRun)
if(doIRun)
game(id_level, 1, type);
} else if (mode == 0 && hasReachedEnd == 1) {
} else if(mode == 0 && hasReachedEnd == 1) {
draw_end((int)frame, LEVEL_MAX, 2);
sleep_ms(7000);
}

View File

@ -1,5 +1,6 @@
#include "menu.h"
#include "define.h"
#include "util.h"
#include "drawlevel.h"
#include "save.h"
#include "setlevel.h"
@ -22,8 +23,8 @@ enum MenuCode start_menu(char *type)
int start_x;
int start_y;
set_level(rand_range(1, LEVEL_MAX), level, &start_x, &start_y, NULL,
NULL, NULL, NULL);
set_level(rand_range(1,LEVEL_MAX), level, &start_x, &start_y, NULL,
NULL, NULL, NULL);
while (menu_loop) {
clearevents();
dclear(C_WHITE);
@ -79,12 +80,12 @@ char level_selection(int *id_level)
*id_level = LEVEL_MAX;
if (keydown(KEY_RIGHT) || keydown(KEY_LEFT))
sto = loadtime(*id_level - 1);
set_level(*id_level, level, &start_x, &start_y, NULL, NULL,
NULL, NULL);
set_level(*id_level, level, &start_x, &start_y, NULL,
NULL, NULL, NULL);
draw_level(level);
dimage(0, 0, &img_speedrun);
if (sto != 0)
check_medal(round(sto * 0.01 * FPS), *id_level, 335, 15);
check_medal(round(sto * 0.01 * FPS), *id_level, 335, 8);
dtext(190, 45, C_BLACK, "Time : ");
dprint(80, 20, C_BLACK, "Level : %d", *id_level);
if (sto != 0)
@ -93,7 +94,7 @@ char level_selection(int *id_level)
dprint(202, 60, C_RED, "/");
draw_time(*id_level);
dupdate();
if (keydown_any(KEY_SHIFT, KEY_EXE, 0)) {
if (!check) {
del_level(level);
@ -113,11 +114,10 @@ char level_selection(int *id_level)
return 0;
}
enum MenuPause pause_menu(char level[], int id_level, int coin, int death_count)
{
enum MenuPause pause_menu(char level[], int id_level, int coin, int death_count) {
extern bopti_image_t img_speedrun;
extern bopti_image_t img_coin;
char menu_loop = 1;
char selected = 0;
@ -136,11 +136,14 @@ enum MenuPause pause_menu(char level[], int id_level, int coin, int death_count)
selected = 1;
dtext(32, Y_POS, C_BLACK, "CONTINUE");
dtext(32, Y_POS + 12, C_BLACK, "BACK");
dtext(16, Y_POS + (selected * 12), C_BLACK, ">");
dprint(174, 45, C_BLACK, "LEVEL : %d", id_level);
dimage(320,3,&img_coin);
dprint(335, 7, C_RGB(255, 178, 0), " : %d", coin);
dprint(311, 21, C_RGB(150, 16, 16), "DEATH : %d", death_count);
dtext(16, Y_POS + (selected * 12), C_BLACK,
">");
dprint(176, 45, C_BLACK, "LEVEL : %d",
id_level);
dprint(320, 3, C_RGB(255, 178, 0), "COIN : %d",
coin);
dprint(311, 17, C_RGB(150, 16, 16),
"DEATH : %d", death_count);
draw_time(id_level);
dupdate();
if (keydown_any(KEY_SHIFT, KEY_EXE, 0)) {

View File

@ -7,7 +7,7 @@
int retcode;
int times[LEVEL_MAX];
static const uint16_t *filepath = u"\\\\fls0\\AST3C.sav";
static const uint16_t *filepath = u"\\\\fls0\\AST3.sav";
/* savefile() write the time of all the player's times in the savefile.
* savefile() is long to execute. That's why it must be call once per

View File

@ -1,10 +1,14 @@
#include "util.h"
#include <gint/std/stdlib.h>
int round(float num) { return (num < 0) ? (num - 0.5) : (num + 0.5); }
int round(float num) {
return (num < 0) ? (num - 0.5) : (num + 0.5);
}
int round_sup(float num) { return (int)(num + 1); }
int round_sup(float num) {
return (int)(num+1);
}
int rand_range(int low, int high) { return (rand() % (high - low)) + low; }
int sign(float x) { return 1 * (x > 0) - 1 * (x < 0); }
int rand_range(int low, int high) {
return (rand() % (high - low)) + low;
}

View File

@ -1,20 +1,19 @@
6.13
8.25
8.86
3.52
5.91
8.76
5.80
3.52
3.58
7.08
6.23
8.82
7.82
8.62
6.81
7.65
9.62
8.35
6.93
6.04
6.23
10.78
5.39
6.24
17.95
8.35
7.45
10.53
17.95
9.54
6.93