2 niveaux + maj temps + image de record

This commit is contained in:
Tituya 2020-08-28 00:36:42 +02:00
parent a45220cacf
commit d7bc0f565b
14 changed files with 76 additions and 30 deletions

BIN
AST3.g3a

Binary file not shown.

BIN
assets-cg/img/new.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

1
editor/levels/14.lvl Normal file
View File

@ -0,0 +1 @@
1111111111111ddd11iK1d00100000d111000000011it1d00000000d100000000011i31110011100d13331110e011ihhh11100000d100011111111i00000000000d100000011111i00111011100d1000000000011000s111111111000000000011dd0001hk001111i00Sddd001dddd00hh0000001i000111000aad1ddhddd0000000001110000001111111dd0000000111000000001111111dd000011110000000001111111111111111ddd13100017

4
editor/levels/15.lvl Normal file
View File

@ -0,0 +1,4 @@
i011100dd1111dddm111ddmd1i01d1000000010S0011100S01i01d100000001000000000001i01d1cc111001hh1c11111001i01ddddddi00i000bddd00001i01dd1133i00i000lddd000K1100000000i00i00001d110011300000000i00100331d100003300000010i001s03t1d1000031111100hki0011111ddd1BB1110S01hh11100m0000aaa0000110001001d100m000000000001100e1001d100m0aaa000aaa0110d11001111111ddddddddd116
5
7

View File

@ -1 +1 @@
111001111111100d0d0011111100000111ddd000d0d0000001100000000000000dtd00000e1111111ddd111111111111111100000000000000000h00d0000111111111dd111110100d000110001100000000010100d0001000011000000000i0d00d0000000000000000000i0d00d00001111dd111000000ild00111111000011111ddd00i0d0011111d000011111ddd00i0d0011111d0s0011111ddd00i0d0011111111001111111100i0d00111116
111001111111100i0d0011111100000111ddd000i0d0000001100000000000000itd00000e1111111ddd111111111111111100000000000000000h00d0000111111111dd111110100d000110001100000000010100d0001000011000000000i0d00d0000000000000000000i0d00d00001111dd111000000ild00111111000011111ddd00i0d0011111d000011111ddd00i0d0011111d0s0011111ddd00i0d0011111111001111111100i0d00111116

View File

@ -2,4 +2,4 @@ void draw_level(char level[]);
void draw_player(int x, int y, char type);
void draw_timer(unsigned int frame);
void draw_blackout(int x, int y);
void draw_end(int framelevel, int id_level);
void draw_end(int framelevel, int id_level, char record);

View File

@ -86,3 +86,5 @@ LDFLAGS_CG += -Wl,-Map=build-cg/map
IMG.speedrun.png = profile:p4
IMG.menu.png = profile:p4
IMG.endscreen.png = profile:p4
IMG.new.png = profile:p4

View File

@ -23,6 +23,7 @@ extern bopti_image_t img_ice; //switch block
extern bopti_image_t img_appear; //appear block
extern bopti_image_t img_endscreen;
extern bopti_image_t img_new;
void draw_player(int x, int y, char type)
{
@ -125,12 +126,21 @@ void draw_timer(unsigned int frame)
dprint_opt(0, 0, C_WHITE, C_BLACK, DTEXT_LEFT, DTEXT_TOP, "%u.%02u",(frame)/FPS, (frame)%FPS);
}
void draw_end(int framelevel, int id_level)
void draw_end(int framelevel, int id_level, char record)
{
float framefloat = framelevel;
dimage(144,60,&img_endscreen);
dprint_opt(220, 115, C_WHITE, C_BLACK, DTEXT_LEFT, DTEXT_TOP, "%d", framelevel);
dprint(166, 87, C_RED, "%.2j",(int)(framefloat/FPS*100));
check_medal(framelevel, id_level, 178, 140);
if(record!=2)
{
dprint_opt(220, 115, C_WHITE, C_BLACK, DTEXT_LEFT, DTEXT_TOP, "%d", framelevel);
dprint(166, 87, C_RED, "%.2j",(int)(framefloat/FPS*100));
check_medal(framelevel, id_level, 178, 140);
if(record==1) dimage(60,100,&img_new);
}
else
{
dprint(166, 87, C_RED, "GG !");
dprint(178, 140, C_RED, "%.2j",(int)(framefloat/FPS*100));
}
dupdate();
}

View File

@ -45,7 +45,7 @@ void game(int *id_level, char mode, char *type)
int start_y;
int death_count = 0;
unsigned int coin = 0;
int coin = 0;
char check_coin = 0;
char double_check = 1;
@ -402,10 +402,10 @@ void game(int *id_level, char mode, char *type)
if(mode)
{
if(*id_level==0) *id_level=1;
if(game_loop)
if(game_loop) //end of a level with level selection
{
float framefloat = framelevel;
draw_end(framelevel, *id_level);
draw_end(framelevel, *id_level, 0);
savetimes(framefloat, *id_level);
sleep_ms(5000);
}
@ -422,11 +422,9 @@ void game(int *id_level, char mode, char *type)
void end(unsigned int frame)
{
dclear(C_WHITE);
float framefloat = frame;
dprint_opt(198, 112, C_WHITE, C_BLACK, DTEXT_LEFT, DTEXT_TOP, "%.2j",(int)(framefloat/FPS*100));
dupdate();
sleep_ms(5000);
draw_end((int)frame, 15, 2);
sleep_ms(7000);
main();
}
int main(void)

View File

@ -30,7 +30,7 @@ char start_menu(char *type)
if (selection == 4) selection = 0;
else if (selection == -1) selection = 3;
dtext(32, Y_POS, C_BLACK, "PLAY");
dtext(32, Y_POS + 12, C_BLACK, "SPEEDRUN MODE");
dtext(32, Y_POS + 12, C_BLACK, "ALL MODE");
dtext(32, Y_POS + 24, C_BLACK, "TUTORIAL");
dtext(32, Y_POS + 36, C_BLACK, "EXIT GAME");
dtext(16, Y_POS + (selection * 12), C_BLACK, ">");

View File

@ -1,22 +1,28 @@
#include <gint/bfile.h>
#include <gint/gint.h>
#include <gint/std/stdlib.h>
#include "define.h"
#include "drawlevel.h"
int retcode;
int valeur = 0;
int times[LEVEL_MAX]; //moche et je le sais... A essayer l'allocution dynamique
/*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 new record only to avoid loading times.*/
void savefile(void)
{
uint16_t *filepath = u"\\\\fls0\\AST3.sav";
int descriptor;
descriptor = BFile_Open(filepath, BFile_WriteOnly);
for(int i = 0; i != 14; i++) BFile_Write(descriptor, &times[i], sizeof(times[i]));
for(int i = 0; i != 15; i++) BFile_Write(descriptor, &times[i], sizeof(times[i]));
BFile_Close(descriptor);
}
/*loadfile() is only call by the function loadtime() because loadtime() set the value of "valeur".
It store in the global retcode the time of the player. This function is call once per level
in the level selection menu to avoid loading time.*/
void loadfile(void)
{
int descriptor;
@ -26,22 +32,28 @@ void loadfile(void)
BFile_Close(descriptor);
}
/*savetimes() is call when the player has reached the end of a level.
If his time is better than the save time, it will call the function savefile
else, nothing append to avoid loading time*/
void savetimes(float framelevel, int id_level)
{
if(times[id_level-1]>(int)(framelevel/FPS*100) || times[id_level-1]==0)
{
times[id_level-1]=(int)(framelevel/FPS*100);
draw_end((int)framelevel, id_level, 1);
gint_switch(savefile);
}
}
/*restore() is call when the app is load, it will create the save file if it doesn't exist.
If the file exist, it will read all times from the save and store them in the global times[]*/
void restore()
{
uint16_t *filepath = u"\\\\fls0\\AST3.sav";
struct BFile_FileInfo fileInfo;
int handle;
uint16_t foundpath[30];
int size = 500;
int size = 80;
int descriptor;
char checkfile = BFile_FindFirst(filepath, &handle, foundpath, &fileInfo);
BFile_FindClose(handle);
@ -49,7 +61,7 @@ void restore()
else
{
descriptor = BFile_Open(filepath, BFile_ReadOnly);
for(int i = 0; i != 14; i++)
for(int i = 0; i != 15; i++)
{
BFile_Read(descriptor, &retcode, 4, 4*i);
times[i] = (int)retcode;
@ -58,6 +70,9 @@ void restore()
}
}
/*loadtime is changing the current value of the global "valeur" to set it to the current level
then it execute loadfile and read and stock in the global retcode 4 bits
at the place 4*level (times are in 4 bits) */
int loadtime(int a)
{
valeur = a;

View File

@ -33,7 +33,7 @@ memcpy(level,"10001011111011111111111111000101dd10001111dddd11110000101dd1000100
*disappear=9;
break;
case 7:
memcpy(level,"111001111111100d0d0011111100000111ddd000d0d0000001100000000000000dtd00000e1111111ddd111111111111111100000000000000000h00d0000111111111dd111110100d000110001100000000010100d0001000011000000000i0d00d0000000000000000000i0d00d00001111dd111000000ild00111111000011111ddd00i0d0011111d000011111ddd00i0d0011111d0s0011111ddd00i0d0011111111001111111100i0d00111116",350);
memcpy(level,"111001111111100i0d0011111100000111ddd000i0d0000001100000000000000itd00000e1111111ddd111111111111111100000000000000000h00d0000111111111dd111110100d000110001100000000010100d0001000011000000000i0d00d0000000000000000000i0d00d00001111dd111000000ild00111111000011111ddd00i0d0011111d000011111ddd00i0d0011111d0s0011111ddd00i0d0011111111001111111100i0d00111116",350);
break;
case 8:
memcpy(level,"dddddddddddddddddddddddddBBBBBBBBBBBBBBBBBBBBBBBBB100001kk10011111dt0a000011000010010010000d11a00001100001BB100100000000000013000000000010001110000000300000000001aaaaaa0000000111111000001000000001111110dd00000001000000001000110000000a001BBBd00a0100013000000000010001000010003300s000000010K0100001e003aaBBBBBBBBBBBBBBBBBBBaaaaddddddddddddddddddddddddd",350);
@ -53,6 +53,14 @@ break;
case 13:
memcpy(level,"11111111111111111111111111ddddddddd0S00ddddddddddd1ddddaaaaa000000ddddddddd1ddd00S000000e0ddd0dddddd1dd000000ddddddd00000dddd1daaaa00dd11100S00S000ddd10000000d00000000000S00dd10K000h0d00001100000000dd1111000ddd000000S0d0h00dd1ddd000dd000dd000ddd000dd1dddhhdd000ddddddddd000dd1ddb00S0000100000dd0000dd1dtb00000011s000000000ddd111111d11111111111111dddd",350);
break;
case 14:
memcpy(level,"1111111111111ddd11iK1d00100000d111000000011it1d00000000d100000000011i31110011100d13331110e011ihhh11100000d100011111111i00000000000d100000011111i00111011100d1000000000011000s111111111000000000011dd0001hk001111i00Sddd001dddd00hh0000001i000111000aad1ddhddd0000000001110000001111111dd0000000111000000001111111dd000011110000000001111111111111111ddd1310001",350);
break;
case 15:
memcpy(level,"i011100dd1111dddm111ddmd1i01d1000000010S0011100S01i01d100000001000000000001i01d1cc111001hh1c11111001i01ddddddi00i000bddd00001i01dd1133i00i000lddd000K1100000000i00i00001d110011300000000i00100331d100003300000010i001s03t1d1000031111100hki0011111ddd1BB1110S01hh11100m0000aaa0000110001001d100m000000000001100e1001d100m0aaa000aaa0110d11001111111ddddddddd11",350);
*appear=5;
*disappear=7;
break;
}
set_gravity(id_level, gravity);
unsigned int x = 0;
@ -110,6 +118,12 @@ break;
case 13:
*default_gravity = 0;
break;
case 14:
*default_gravity = 1;
break;
case 15:
*default_gravity = 0;
break;
}}
void del_level(char level[])
{memcpy(level,"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",350);}

View File

@ -8,7 +8,7 @@ void check_medal(unsigned int frame_level, int id_level, int x, int y)
{
float time=1.0;
float framefloat = frame_level;
float level_time[] = {5.91,8.76,5.89,3.58,3.84,8.45,6.92,7.68,10.46,9.25,6.48,11.94,5.68};
float level_time[] = {5.91,8.76,5.83,3.58,3.64,8.62,6.92,7.68,9.86,6.25,6.26,10.86,5.42,8.35,7.53};
time = level_time[id_level-1];
if(frame_level/FPS < (unsigned int)time || (frame_level/FPS <= (unsigned int)time &&
@ -25,7 +25,7 @@ void draw_time(int id_level)
{
dclear(C_WHITE);
float time=1.0;
float level_time[] = {5.91,8.76,5.89,3.58,3.84,8.45,6.92,7.68,10.46,9.25,6.48,11.94,5.68};
float level_time[] = {5.91,8.76,5.83,3.58,3.64,8.62,6.92,7.68,9.86,6.25,6.26,10.86,5.42,8.35,7.53};
time = level_time[id_level-1];
dsubimage(172,90,&img_medals,36,0,12,12,DIMAGE_NONE);

View File

@ -1,13 +1,15 @@
5.91
8.76
5.89
5.83
3.58
3.84
8.45
3.64
8.62
6.92
7.68
10.46
9.25
6.48
11.94
5.68
9.86
6.25
6.26
10.86
5.42
8.35
7.53