Test friction sur les murs

This commit is contained in:
Tituya 2020-08-16 15:20:20 +02:00
parent 647abc9106
commit 12d59b8adc
10 changed files with 50 additions and 34 deletions

BIN
AST3.g3a

Binary file not shown.

View File

@ -1,4 +1,4 @@
11100111111111111111111111l00000l01BB1BB1BB1BB1BB1100000000000100100100100110000000000000010010010011b0t000000000000001001001111111000000000000000100111111d000000000000000000100000d000000000000000000010000d000000000000000011110000d000030000a0c0m0000110000d000030000a0c0m0000110000d000030000a0c0m0000110s00d00k0300K0a0c0m00e0111100111111111111111111116
11100111111111111111111111l00000l01BB1BB1BB1BB1BB1100000000100100100100100110000000010000010010010011b0t000001000000001001001111111000100000000000100111111d000100000000000000100000d000100000000000000010000d000000000000000011110000d000030000a0c0m0000110000d000030000a0c0m0000110000d000030000a0c0m0000110s00d00k0300K0a0c0m00e0111100111111111111111111116
7
9

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

@ -0,0 +1 @@
11111111111111111111111111000000010000000100000101100000001000000010000010110000000100000001000001011000100010001000100100101100010001000100010010010110001000100010001001001011000100010001000100100101100010001000100010010010110001000100010001001001011000100000001000000100001100010000000100000010000110s01000000010000001000e111111111111111111111111116

View File

@ -1 +1 @@
dddddddddddddddddddddddddBBBBBBBBBBBBBBBBBBBBBBBBB1000010k10011111dt0a000011000010010010000d11a00001100001BB100100000000000013000000000010001110000000300000000001aaaaaa00000001111110000010000000011111100000000001000000001000110000000a001BBBd00a0100013000000000010001000010003300s000000010K0100001e003aaBBBBBBBBBBBBBBBBBBBaaaaddddddddddddddddddddddddd6
dddddddddddddddddddddddddBBBBBBBBBBBBBBBBBBBBBBBBB100001kk10011111dt0a000011000010010010000d11a00001100001BB100100000000000013000000000010001110000000300000000001aaaaaa00000001111110000010000000011111100000000001000000001000110000000a001BBBd00a0100013000000000010001000010003300s000000010K0100001e003aaBBBBBBBBBBBBBBBBBBBaaaaddddddddddddddddddddddddd6

View File

@ -13,6 +13,7 @@
#define ACCELERATION 0.2
#define MAX_VSPD 9.0
#define FRICTION 0.1
int main(void);
@ -122,6 +123,8 @@ void game(int *id_level, char mode)
if(!collide_solid(player_x, player_y+vert_spd+1, level, gravity))
{
if (vspd<MAX_VSPD) vspd+=ACCELERATION;
if(collide_solid(player_x+1, player_y, level, gravity)) vspd-=FRICTION;
if(collide_solid(player_x-1, player_y, level, gravity)) vspd-=FRICTION;
vert_spd = vspd;
player_y+=vert_spd;
}
@ -143,6 +146,8 @@ void game(int *id_level, char mode)
if(!collide_solid(player_x, player_y-vert_spd-1, level, gravity))
{
if (vspd<MAX_VSPD) vspd+=ACCELERATION;
if(collide_solid(player_x+1, player_y, level, gravity)) vspd-=FRICTION;
if(collide_solid(player_x-1, player_y, level, gravity)) vspd-=FRICTION;
vert_spd = vspd;
player_y-=vert_spd;
}

View File

@ -44,7 +44,7 @@ char speed_menu(int *id_level)
char gravity = 0; //0 down 1 up
int start_x;
int start_y;
char check_coin = 0;
int appear = 10;
int disappear = 13;
@ -57,8 +57,8 @@ char speed_menu(int *id_level)
clearevents();
dclear(C_WHITE);
*id_level += keydown(KEY_RIGHT) - keydown(KEY_LEFT);
if (*id_level == 11) *id_level = 1;
else if (*id_level == 0) *id_level = 10;
if (*id_level == 16) *id_level = 1;
else if (*id_level == 0) *id_level = 15;
set_level(*id_level, level, &start_x, &start_y, &gravity, &appear, &disappear);
draw_level(level);
dimage(0,0,&img_speedrun);

View File

@ -2,7 +2,7 @@
#include <gint/std/string.h>
void set_level(int id_level, char level[], int *startx, int *starty, char *gravity, int *appear, int *disappear){
switch(id_level){case 0:
memcpy(level,"11100111111111111111111111l00000l01BB1BB1BB1BB1BB1100000000000100100100100110000000000000010010010011b0t000000000000001001001111111000000000000000100111111d000000000000000000100000d000000000000000000010000d000000000000000011110000d000030000a0c0m0000110000d000030000a0c0m0000110000d000030000a0c0m0000110s00d00k0300K0a0c0m00e011110011111111111111111111",350);
memcpy(level,"11100111111111111111111111l00000l01BB1BB1BB1BB1BB1100000000100100100100100110000000010000010010010011b0t000001000000001001001111111000100000000000100111111d000100000000000000100000d000100000000000000010000d000000000000000011110000d000030000a0c0m0000110000d000030000a0c0m0000110000d000030000a0c0m0000110s00d00k0300K0a0c0m00e011110011111111111111111111",350);
*appear=7;
*disappear=9;
break;
@ -36,7 +36,7 @@ case 7:
memcpy(level,"111001111111100d0d0011111100000111ddd000d0d0000001100000000000000dtd00000e1111111ddd111111111111111100000000000000000000d0000111111111dd111110100d000110001100000000010100d0001000011000000000d0d00d0000000000000000000d0d00d00001111dd111000000dld00111111000011111ddd00d0d00111111000011111ddd00d0d001111110s0011111ddd00d0d0011111111001111111100d0d00111116",350);
break;
case 8:
memcpy(level,"dddddddddddddddddddddddddBBBBBBBBBBBBBBBBBBBBBBBBB1000010k10011111dt0a000011000010010010000d11a00001100001BB100100000000000013000000000010001110000000300000000001aaaaaa00000001111110000010000000011111100000000001000000001000110000000a001BBBd00a0100013000000000010001000010003300s000000010K0100001e003aaBBBBBBBBBBBBBBBBBBBaaaaddddddddddddddddddddddddd",350);
memcpy(level,"dddddddddddddddddddddddddBBBBBBBBBBBBBBBBBBBBBBBBB100001kk10011111dt0a000011000010010010000d11a00001100001BB100100000000000013000000000010001110000000300000000001aaaaaa00000001111110000010000000011111100000000001000000001000110000000a001BBBd00a0100013000000000010001000010003300s000000010K0100001e003aaBBBBBBBBBBBBBBBBBBBaaaaddddddddddddddddddddddddd",350);
break;
case 9:
memcpy(level,"00000ddddddd100000000000011111111111111111110011111000000dd1111ddd0K10000b1100111000000100000100000110000100000010000010010011000k111dd101dd00d10000011000110000001000001BBBB011000100011dd1000001dddd01100010ddd1dd1d00dd1011001133310ddd1dd1BBBBB1t00001100000ddd1dd1000001ddd1111s0000ddd1dd10000011111111BBB111aaaaa110001111111100000000000e1000000000000",350);
@ -44,6 +44,9 @@ break;
case 10:
memcpy(level,"111111111133111111100011111111111133311111110K01111100000100111111111000111110s000101111111000000011111110K10111111d000000011111110K1011111a001BBBBB111100000101111d0a010000011110000010111a03011d0ddd1111001ddd011d0a0d11000001111000000010a30111100e00111100000k0130ad1111aaaaa1111dd000001031111111ddd1111111111111001111111aaa1111111111111001111111000111",350);
break;
case 11:
memcpy(level,"11111111111111111111111111000000010000000100000101100000001000000010000010110000000100000001000001011000100010001000100100101100010001000100010010010110001000100010001001001011000100010001000100100101100010001000100010010010110001000100010001001001011000100000001000000100001100010000000100000010000110s01000000010000001000e11111111111111111111111111",350);
break;
}
set_gravity(id_level, gravity);
unsigned int x = 0;
@ -92,6 +95,9 @@ break;
case 10:
*default_gravity = 0;
break;
case 11:
*default_gravity = 0;
break;
}}
void del_level(char level[])
{memcpy(level,"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",350);}

View File

@ -12,34 +12,34 @@ void check_medal(unsigned int frame_level, int id_level)
{
float time=1.0;
float framefloat = frame_level;
float level_time[] = {5.88,8.31,6.12,8.72,3.92,3.51,6.76,7.48,12.26,9.25};
float level_time[] = {5.81,8.29,5.89,8.68,3.84,3.58,6.81,7.48,10.46,9.25};
time = level_time[id_level-1];
if(frame_level/FPS < (unsigned int)time || (frame_level/FPS <= (unsigned int)time &&
(unsigned int)((framefloat)/FPS*100-frame_level/FPS*100) <= (unsigned int)((time)*100-(int)(time)*100))) dimage(380,8,&img_createur);
if(frame_level/FPS < (unsigned int)(time*1.1) || (frame_level/FPS <= (unsigned int)(time*1.1) &&
(unsigned int)((framefloat)/FPS*100-frame_level/FPS*100) <= (unsigned int)((time*1.1)*100-(int)(time*1.1)*100))) dimage(360,8,&img_or);
if(frame_level/FPS < (unsigned int)(time*1.2) || (frame_level/FPS <= (unsigned int)(time*1.2) &&
(unsigned int)((framefloat)/FPS*100-frame_level/FPS*100) <= (unsigned int)((time*1.2)*100-(int)(time*1.2)*100))) dimage(340,8,&img_argent);
(unsigned int)((framefloat)/FPS*100-frame_level/FPS*100) <= (unsigned int)((time*1.2)*100-(int)(time*1.2)*100))) dimage(360,8,&img_or);
if(frame_level/FPS < (unsigned int)(time*1.5) || (frame_level/FPS <= (unsigned int)(time*1.5) &&
(unsigned int)((framefloat)/FPS*100-frame_level/FPS*100) <= (unsigned int)((time*1.1)*100-(int)(time*1.1)*100))) dimage(320,8,&img_bronze);
(unsigned int)((framefloat)/FPS*100-frame_level/FPS*100) <= (unsigned int)((time*1.5)*100-(int)(time*1.5)*100))) dimage(340,8,&img_argent);
if(frame_level/FPS < (unsigned int)(time*2) || (frame_level/FPS <= (unsigned int)(time*2) &&
(unsigned int)((framefloat)/FPS*100-frame_level/FPS*100) <= (unsigned int)((time*2)*100-(int)(time*2)*100))) dimage(320,8,&img_bronze);
}
void draw_time(int id_level)
{
dclear(C_WHITE);
float time=1.0;
float level_time[] = {5.88,8.31,6.12,8.72,3.92,3.51,6.76,7.48,12.26,9.25};
float level_time[] = {5.81,8.29,5.89,8.68,3.84,3.58,6.81,7.48,10.46,9.25};
time = level_time[id_level-1];
dimage(160,90,&img_createur);
dprint(175,90,C_BLACK,"%.2j",(int)(time*100));
dimage(160,110,&img_or);
dprint(175,110,C_BLACK,"%.2j",(int)(time*1.1*100));
dprint(175,110,C_BLACK,"%.2j",(int)(time*1.2*100));
dimage(160,130,&img_argent);
dprint(175,130,C_BLACK,"%.2j",(int)(time*1.2*100));
dprint(175,130,C_BLACK,"%.2j",(int)(time*1.5*100));
dimage(160,150,&img_bronze);
dprint(175,150,C_BLACK,"%.2j",(int)(time*1.5*100));
dprint(175,150,C_BLACK,"%.2j",(int)(time*2*100));
dupdate();
getkey();
}

22
time.py
View File

@ -1,3 +1,7 @@
gold = 1.2
argent = 1.5
bronze = 2
f = open("times.lvl","r+")
d = open("src/times.c","w")
ids=f.readlines()
@ -23,12 +27,12 @@ d.write(f"{','.join(times)}")
d.write("};\ntime = level_time[id_level-1];\n\n\
if(frame_level/FPS < (unsigned int)time || (frame_level/FPS <= (unsigned int)time && \n\
(unsigned int)((framefloat)/FPS*100-frame_level/FPS*100) <= (unsigned int)((time)*100-(int)(time)*100))) dimage(380,8,&img_createur);\n\
if(frame_level/FPS < (unsigned int)(time*1.1) || (frame_level/FPS <= (unsigned int)(time*1.1) && \n\
(unsigned int)((framefloat)/FPS*100-frame_level/FPS*100) <= (unsigned int)((time*1.1)*100-(int)(time*1.1)*100))) dimage(360,8,&img_or);\n\
if(frame_level/FPS < (unsigned int)(time*1.2) || (frame_level/FPS <= (unsigned int)(time*1.2) && \n\
(unsigned int)((framefloat)/FPS*100-frame_level/FPS*100) <= (unsigned int)((time*1.2)*100-(int)(time*1.2)*100))) dimage(340,8,&img_argent);\n\
if(frame_level/FPS < (unsigned int)(time*1.5) || (frame_level/FPS <= (unsigned int)(time*1.5) && \n\
(unsigned int)((framefloat)/FPS*100-frame_level/FPS*100) <= (unsigned int)((time*1.1)*100-(int)(time*1.1)*100))) dimage(320,8,&img_bronze);\n\
if(frame_level/FPS < (unsigned int)(time*"+str(gold)+") || (frame_level/FPS <= (unsigned int)(time*"+str(gold)+") && \n\
(unsigned int)((framefloat)/FPS*100-frame_level/FPS*100) <= (unsigned int)((time*"+str(gold)+")*100-(int)(time*"+str(gold)+")*100))) dimage(360,8,&img_or);\n\
if(frame_level/FPS < (unsigned int)(time*"+str(argent)+") || (frame_level/FPS <= (unsigned int)(time*"+str(argent)+") && \n\
(unsigned int)((framefloat)/FPS*100-frame_level/FPS*100) <= (unsigned int)((time*"+str(argent)+")*100-(int)(time*"+str(argent)+")*100))) dimage(340,8,&img_argent);\n\
if(frame_level/FPS < (unsigned int)(time*"+str(bronze)+") || (frame_level/FPS <= (unsigned int)(time*"+str(bronze)+") && \n\
(unsigned int)((framefloat)/FPS*100-frame_level/FPS*100) <= (unsigned int)((time*"+str(bronze)+")*100-(int)(time*"+str(bronze)+")*100))) dimage(320,8,&img_bronze);\n\
}\n\
\n\
void draw_time(int id_level)\n\
@ -43,11 +47,11 @@ d.write("};\ntime = level_time[id_level-1];\n\n\
dimage(160,90,&img_createur);\n\
dprint(175,90,C_BLACK,\"%.2j\",(int)(time*100));\n\
dimage(160,110,&img_or);\n\
dprint(175,110,C_BLACK,\"%.2j\",(int)(time*1.1*100));\n\
dprint(175,110,C_BLACK,\"%.2j\",(int)(time*"+str(gold)+"*100));\n\
dimage(160,130,&img_argent); \n\
dprint(175,130,C_BLACK,\"%.2j\",(int)(time*1.2*100));\n\
dprint(175,130,C_BLACK,\"%.2j\",(int)(time*"+str(argent)+"*100));\n\
dimage(160,150,&img_bronze); \n\
dprint(175,150,C_BLACK,\"%.2j\",(int)(time*1.5*100));\n\
dprint(175,150,C_BLACK,\"%.2j\",(int)(time*"+str(bronze)+"*100));\n\
dupdate();\n\
getkey();\n\
}")

View File

@ -1,10 +1,10 @@
5.88
8.31
6.12
8.72
3.92
3.51
6.76
5.81
8.29
5.89
8.68
3.84
3.58
6.81
7.48
12.26
9.25
10.46
9.25