level 19, new rough block
This commit is contained in:
parent
dfc151ff1a
commit
25a2f92e28
|
@ -85,7 +85,8 @@ set(ASSETS_cg
|
|||
assets-cg/img/speedrun.png
|
||||
assets-cg/img/switch.png
|
||||
assets-cg/img/nbswitch.png
|
||||
assets-cg/img/nbswitchlayout.png)
|
||||
assets-cg/img/nbswitchlayout.png
|
||||
assets-cg/img/rough.png)
|
||||
|
||||
set(FLAGS -Wall -Wextra -Os)
|
||||
|
||||
|
|
|
@ -72,3 +72,6 @@ nbswitchlayout.png:
|
|||
type:bopti-image
|
||||
profile:p4
|
||||
name: img_nbswitchlayout
|
||||
rough.png:
|
||||
type:bopti-image
|
||||
name: img_rough
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Binary file not shown.
After Width: | Height: | Size: 177 B |
|
@ -24,7 +24,7 @@ def newgrille():
|
|||
["1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1"]
|
||||
|
||||
def load(ids):
|
||||
global grille, gravityid, app, disa, nbswitch
|
||||
global grille, gravityid, app, disa, nbswitchmax
|
||||
try:
|
||||
lv = open(f"editor/levels/{ids}.lvl","r")
|
||||
ide = lv.readlines()
|
||||
|
@ -32,7 +32,7 @@ def load(ids):
|
|||
|
||||
app = int(ide[1][:-1])
|
||||
disa = int(ide[2])
|
||||
nbswitch = int(ide[3])
|
||||
nbswitchmax = int(ide[3])
|
||||
|
||||
ide = str(ide[0][:-2])
|
||||
grille=[]
|
||||
|
@ -102,7 +102,9 @@ def place():
|
|||
elif grille[a][b]=="h" and tab:
|
||||
fenetre.blit(pygame.transform.scale(appearblock,(52,52)),(52*b,52*a))
|
||||
if grille[a][b]=="z":
|
||||
fenetre.blit(pygame.transform.scale(nbswitchblock,(52,52)),(52*b,52*a))
|
||||
fenetre.blit(pygame.transform.scale(nbswitch,(52,52)),(52*b,52*a))
|
||||
if grille[a][b]=="r":
|
||||
fenetre.blit(pygame.transform.scale(rough,(52,52)),(52*b,52*a))
|
||||
fenetre.blit(level, (10, 10))
|
||||
fenetre.blit(levelgr, (10, 60))
|
||||
fenetre.blit(timeapp, (55, 10))
|
||||
|
@ -113,10 +115,10 @@ def place():
|
|||
pygame.display.flip()
|
||||
|
||||
def write():
|
||||
global nbswitch
|
||||
global nbswitchmax
|
||||
f = open(f"editor/levels/{id_level}.lvl","w+")
|
||||
if "z" not in str(grille): nbswitch = 1
|
||||
f.write(str(grille).replace("]","").replace("(","").replace(")","").replace("'","").replace("[","").replace(" ","").replace(",","")+f"{gravityid}\n{app}\n{disa}\n{nbswitch}")
|
||||
if "z" not in str(grille): nbswitchmax = 1
|
||||
f.write(str(grille).replace("]","").replace("(","").replace(")","").replace("'","").replace("[","").replace(" ","").replace(",","")+f"{gravityid}\n{app}\n{disa}\n{nbswitchmax}")
|
||||
f.close()
|
||||
|
||||
pygame.init()
|
||||
|
@ -126,14 +128,14 @@ fenetre = pygame.display.set_mode((25*52, 14*52))
|
|||
font = pygame.font.SysFont('arial',25,True)
|
||||
|
||||
#Defini la suite des blocs pendant les changements (cliquer sur un 1 va donner un 2...)
|
||||
suite=["0","1","d","s","e","k","3","K","a","c","m","t","l","b","B","i","S","h","z"]
|
||||
suite=["0","1","d","s","e","k","3","K","a","c","m","t","l","b","B","i","S","h","z","r"]
|
||||
|
||||
lvm = open(f"generated/include/define.h","r")
|
||||
id_level = 0
|
||||
gravityid = 6
|
||||
disa = 10
|
||||
app = 13
|
||||
nbswitch = 1
|
||||
nbswitchmax = 1
|
||||
lock=""
|
||||
tab = 0
|
||||
|
||||
|
@ -157,7 +159,8 @@ switch = pygame.image.load("editor/img/switch.png").convert_alpha()
|
|||
ice = pygame.image.load("editor/img/ice.png").convert_alpha()
|
||||
appear = pygame.image.load("editor/img/appear.png").convert_alpha()
|
||||
appearblock = pygame.image.load("editor/img/appearblock.png").convert_alpha()
|
||||
nbswitchblock = pygame.image.load("editor/img/nbswitch.png").convert_alpha()
|
||||
nbswitch = pygame.image.load("editor/img/nbswitch.png").convert_alpha()
|
||||
rough = pygame.image.load("editor/img/rough.png").convert_alpha()
|
||||
|
||||
load(id_level)
|
||||
place()
|
||||
|
@ -194,11 +197,11 @@ while securite==False:
|
|||
write()
|
||||
place()
|
||||
if carac == "t" and "z" in str(grille):
|
||||
nbswitch+=1
|
||||
nbswitchmax+=1
|
||||
write()
|
||||
place()
|
||||
if carac == "g" and "z" in str(grille):
|
||||
if nbswitch > 0: nbswitch-=1
|
||||
if nbswitchmax > 0: nbswitchmax-=1
|
||||
write()
|
||||
place()
|
||||
if carac == "a":
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 177 B |
|
@ -1,4 +1,4 @@
|
|||
11111111111111111111111111000000000000000000000001i000000000000000000000001i0000iiiii11i11iiiii00001i000000000000000000000001i00S000000000000000000001i000000000000000000000001i000011111111111111100001i000000000000000000000001i000000000000000000000001i0000iiiiiiiiiiiiiii00001i000000000000000000000001i00s00000000000000000e00111111iiiiiiiiiiiiiii111116
|
||||
1333111111111111iiii11111i000d1iii1iiii000000d0001i0000iiii1iiii000000d0e0ii000000001iii1000000d000ii000000001iid1aaa0000000ii00S000000000000a000S000i10000K00000S0000i1rr1iid111iiii1ii1rrr1iiid000000i10k00000000000000000i000i10000000000000000000i000i1333rrii11iiiirriii11000i100000000000000000000000i10s0000000000000000000S011333iiirriirriii111iiii116
|
||||
8
|
||||
10
|
||||
1
|
|
@ -7,4 +7,5 @@
|
|||
void mod_accel_and_fric(float *acceleration, float *friction, int x, int y,
|
||||
char level[]);
|
||||
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[]);
|
||||
int mod_solid(float *acceleration, float *friction, int x, int y, char level[]);
|
||||
|
|
|
@ -26,7 +26,8 @@ char collide_solid(int x, int y, char level[])
|
|||
return collide(x, y, level, '1') || collide(x, y, level, '3') ||
|
||||
collide(x, y, level, '4') || collide(x, y, level, 'c') ||
|
||||
collide(x, y, level, 'C') || collide(x, y, level, 'B') ||
|
||||
collide(x, y, level, 'i') || collide(x, y, level, 'H');
|
||||
collide(x, y, level, 'i') || collide(x, y, level, 'H') ||
|
||||
collide(x, y, level, 'r');
|
||||
}
|
||||
|
||||
char collide_dead(int x, int y, char level[])
|
||||
|
|
|
@ -14,10 +14,6 @@ void check_medal(unsigned int frame_level, int id_level, int x, int y)
|
|||
const int player_time = (int)((float)frame_level / FPS * 100.0);
|
||||
int i;
|
||||
|
||||
/* OK, this doesn't have the exact same behavior than the previously
|
||||
* generated code had. But the conditions were so dirty and hard to
|
||||
* understand than I simplified it.
|
||||
* -- KikooDX */
|
||||
i = 4;
|
||||
while (i-- > 0) {
|
||||
const int mtime = (int)(time * medal_multiplier[i] * 100.0);
|
||||
|
|
|
@ -19,9 +19,10 @@ extern bopti_image_t img_key2; // key 2
|
|||
extern bopti_image_t img_damaged; // damaged block
|
||||
extern bopti_image_t img_chock; // chock block
|
||||
extern bopti_image_t img_switch; // switch block
|
||||
extern bopti_image_t img_ice; // switch block
|
||||
extern bopti_image_t img_ice; // ice block
|
||||
extern bopti_image_t img_appear; // appear block
|
||||
extern bopti_image_t img_nbswitch; // appear block
|
||||
extern bopti_image_t img_nbswitch; // nbswitch block
|
||||
extern bopti_image_t img_rough; // rough block
|
||||
|
||||
extern bopti_image_t img_endscreen;
|
||||
extern bopti_image_t img_nbswitchlayout;
|
||||
|
@ -106,6 +107,9 @@ void draw_level(char level[])
|
|||
case 'z': // nbswitch blocks
|
||||
dimage(x, y, &img_nbswitch);
|
||||
break;
|
||||
case 'r': // rough blocks
|
||||
dimage(x, y, &img_rough);
|
||||
break;
|
||||
}
|
||||
x += 16;
|
||||
if (x == 16 * 25) {
|
||||
|
@ -155,4 +159,4 @@ void draw_nbswitch(int nbswitch)
|
|||
{
|
||||
dimage(300, 150, &img_nbswitchlayout);
|
||||
dprint(335, 175, C_RED, "%d", nbswitch);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,20 +6,32 @@ 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))
|
||||
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);
|
||||
}
|
||||
|
||||
int mod_ice(float *acceleration, float *friction, int x, int y, char level[])
|
||||
{
|
||||
if (collide(x, y - 1, level, 'i') || collide(x, y + 1, level, 'i')) {
|
||||
*friction /= 4.0;
|
||||
*friction /= 3.0;
|
||||
*acceleration /= 2.0;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
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;
|
||||
*acceleration *= 2;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mod_solid(float *acceleration, float *friction, int x, int y, char level[])
|
||||
{
|
||||
if (collide_solid(x, y - 1, level) || collide_solid(x, y + 1, level)) {
|
||||
|
|
58
src/main.c
58
src/main.c
|
@ -1,3 +1,16 @@
|
|||
/*
|
||||
* @author : Tituya x KikooDX
|
||||
*/
|
||||
|
||||
#include <gint/clock.h>
|
||||
#include <gint/display.h>
|
||||
#include <gint/gint.h>
|
||||
#include <gint/keyboard.h>
|
||||
#include <gint/std/string.h>
|
||||
#include <gint/timer.h>
|
||||
#include <gint/std/stdlib.h>
|
||||
#include <gint/rtc.h>
|
||||
|
||||
#include "collide.h"
|
||||
#include "define.h"
|
||||
#include "drawlevel.h"
|
||||
|
@ -8,15 +21,6 @@
|
|||
#include "times.h"
|
||||
#include "util.h"
|
||||
#include "friction.h"
|
||||
#include <gint/clock.h>
|
||||
#include <gint/display.h>
|
||||
#include <gint/gint.h>
|
||||
#include <gint/keyboard.h>
|
||||
#include <gint/std/string.h>
|
||||
#include <gint/timer.h>
|
||||
|
||||
#include <gint/std/stdlib.h>
|
||||
#include <gint/rtc.h>
|
||||
|
||||
#define VACCELERATION 0.2
|
||||
#define MAX_VSPD 9.0
|
||||
|
@ -26,21 +30,18 @@ static int callback(volatile int *frame_elapsed);
|
|||
static void game(int *id_level, char mode, char *type);
|
||||
|
||||
int main(void) {
|
||||
static int run = 0;
|
||||
if (!run) {
|
||||
gint_world_switch(GINT_CALL(restore));
|
||||
srand(rtc_ticks());
|
||||
run = 1;
|
||||
}
|
||||
gint_world_switch(GINT_CALL(restore));
|
||||
srand(rtc_ticks());
|
||||
|
||||
startmenu_launcher();
|
||||
gint_world_switch(GINT_CALL(savefile));
|
||||
gint_osmenu();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void startmenu_launcher() {
|
||||
char type = 1;
|
||||
static int menu_run = 1;
|
||||
int menu_run = 1;
|
||||
int id_level = 1;
|
||||
while(menu_run) {
|
||||
const enum MenuCode valeur = start_menu(&type);
|
||||
|
@ -169,7 +170,7 @@ static void game(int *id_level, char mode, char *type)
|
|||
}
|
||||
|
||||
// right and left movement + collision
|
||||
const int signe = (keydown(KEY_RIGHT) - keydown(KEY_LEFT));
|
||||
int signe = (keydown(KEY_RIGHT) - keydown(KEY_LEFT));
|
||||
mod_accel_and_fric(&acceleration, &friction, player_x, player_y, level);
|
||||
hspd *= 1 - friction;
|
||||
hspd += signe * acceleration;
|
||||
|
@ -245,13 +246,15 @@ static void game(int *id_level, char mode, char *type)
|
|||
if (check_coin)
|
||||
coin--;
|
||||
check_coin = 0;
|
||||
set_level(*id_level, level, &start_x, &start_y,
|
||||
&gravity, &appear, &disappear, &nbswitch);
|
||||
blackout = 0;
|
||||
check_nbswitch = 0;
|
||||
death_count++;
|
||||
double_check = 1;
|
||||
framelevel = 0;
|
||||
hrem = 0.00;
|
||||
|
||||
set_level(*id_level, level, &start_x, &start_y,
|
||||
&gravity, &appear, &disappear, &nbswitch);
|
||||
if (*id_level == 1 && !mode)
|
||||
frame = 0;
|
||||
}
|
||||
|
@ -265,6 +268,7 @@ static void game(int *id_level, char mode, char *type)
|
|||
blackout = 0;
|
||||
double_check = 1;
|
||||
framelevel = 0;
|
||||
hrem = 0.00;
|
||||
|
||||
set_level(*id_level, level, &start_x, &start_y,
|
||||
&gravity, &appear, &disappear, &nbswitch);
|
||||
|
@ -431,6 +435,7 @@ static void game(int *id_level, char mode, char *type)
|
|||
switch(valeur) {
|
||||
case MenuContinue: {
|
||||
timer_start(timer);
|
||||
check = 1; //prevent for switch when back to the level
|
||||
} break;
|
||||
case MenuBack: {
|
||||
game_loop = 0;
|
||||
|
@ -442,14 +447,15 @@ static void game(int *id_level, char mode, char *type)
|
|||
timer_stop(timer);
|
||||
// when a level is quit
|
||||
|
||||
//if level selection and end
|
||||
if (mode == 1 && *id_level != 0 && hasReachedEnd == 1) {
|
||||
|
||||
float framefloat = framelevel;
|
||||
draw_end(framelevel, *id_level, 0);
|
||||
savetime(framefloat, *id_level);
|
||||
sleep_ms(2500);
|
||||
//if level selection
|
||||
if (mode == 1 && *id_level != 0) {
|
||||
|
||||
if(hasReachedEnd) {
|
||||
float framefloat = framelevel;
|
||||
draw_end(framelevel, *id_level, 0);
|
||||
savetime(framefloat, *id_level);
|
||||
sleep_ms(2500);
|
||||
}
|
||||
|
||||
int doIRun = level_selection(id_level);
|
||||
if(doIRun)
|
||||
|
|
|
@ -138,12 +138,13 @@ enum MenuPause pause_menu(char level[], int id_level, int coin, int death_count)
|
|||
dtext(32, Y_POS + 12, C_BLACK, "BACK");
|
||||
dtext(16, Y_POS + (selected * 12), C_BLACK,
|
||||
">");
|
||||
dprint(180, 45, C_BLACK, "LEVEL : %d",
|
||||
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)) {
|
||||
return selected;
|
||||
|
|
19
time.py
19
time.py
|
@ -1,30 +1,17 @@
|
|||
gold = 1.2
|
||||
silver = 1.5
|
||||
bronze = 2
|
||||
|
||||
x = 340
|
||||
y = 140
|
||||
|
||||
timeslevel = open("times.lvl","r+")
|
||||
dest = open("generated/times.c","w")
|
||||
lvm = open("generated/include/define.h","r")
|
||||
ids=timeslevel.readlines()
|
||||
define = open("generated/include/define.h","r")
|
||||
times=[]
|
||||
|
||||
for i in ids:
|
||||
for i in timeslevel.readlines():
|
||||
times.append(i.rstrip())
|
||||
|
||||
nblvl = int(''.join(filter(str.isdigit,lvm.readline())))
|
||||
nblvl = int(''.join(filter(str.isdigit,define.readline())))
|
||||
|
||||
while(len(times) < nblvl):
|
||||
times.append("0.00")
|
||||
|
||||
dest.write("""#include "times.h"
|
||||
#include "define.h"
|
||||
#include <gint/display.h>
|
||||
#include <gint/keyboard.h>
|
||||
|
||||
extern bopti_image_t img_medals;
|
||||
float level_time[] = {\n\t""")
|
||||
|
||||
dest.write("{}".format(',\n\t'.join(times)))
|
||||
|
|
Loading…
Reference in New Issue