fix define glitch, back to subimages

This commit is contained in:
Tituya 2021-03-22 22:50:42 +01:00
parent a306f3ec7c
commit c9a4e38a21
20 changed files with 53 additions and 180 deletions

View File

@ -11,38 +11,24 @@ find_package(Gint 2.1 REQUIRED)
include_directories(include)
add_custom_command(
OUTPUT "${CMAKE_CURRENT_LIST_DIR}/src/setlevel.c"
COMMENT "Generate src/setlevel.c"
COMMAND python3 compile_levels.py
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
DEPENDS compile_levels.py
)
add_custom_command(
OUTPUT
"${CMAKE_CURRENT_LIST_DIR}/src/times.c"
"${CMAKE_CURRENT_LIST_DIR}/include/define.h"
COMMENT "Generate src/times.c & include/define.h"
COMMAND sh generate_define.sh
COMMAND python3 time.py
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
DEPENDS time.py times.lvl)
add_custom_command(
OUTPUT "${CMAKE_CURRENT_LIST_DIR}/src/setlevel.c"
COMMENT "Generate src/setlevel.c"
COMMAND sh update_levels.sh
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
DEPENDS update_levels.sh compile_levels.py
editor/levels/0.lvl
editor/levels/1.lvl
editor/levels/2.lvl
editor/levels/3.lvl
editor/levels/4.lvl
editor/levels/5.lvl
editor/levels/6.lvl
editor/levels/7.lvl
editor/levels/8.lvl
editor/levels/9.lvl
editor/levels/10.lvl
editor/levels/11.lvl
editor/levels/12.lvl
editor/levels/13.lvl
editor/levels/14.lvl
editor/levels/15.lvl
editor/levels/16.lvl)
DEPENDS time.py times.lvl generate_define.sh
)
set(SOURCES
src/collide.c
@ -57,12 +43,10 @@ set(ASSETS)
set(ASSETS_fx)
set(ASSETS_cg
assets-cg/img/appear.png
assets-cg/img/appearblock.png
assets-cg/img/blackout.png
assets-cg/img/chock.png
assets-cg/img/chrono1.png
assets-cg/img/chrono2.png
assets-cg/img/chrono2appear.png
assets-cg/img/coin.png
assets-cg/img/damaged.png
assets-cg/img/dead.png
@ -71,14 +55,11 @@ set(ASSETS_cg
assets-cg/img/ice.png
assets-cg/img/key1.png
assets-cg/img/key2.png
assets-cg/img/key2block.png
assets-cg/img/key2blockvoid.png
assets-cg/img/keyblock.png
assets-cg/img/medals.png
assets-cg/img/menu.png
assets-cg/img/new.png
assets-cg/img/player.png
assets-cg/img/solid_0.png
assets-cg/img/solid.png
assets-cg/img/speedrun.png
assets-cg/img/switch.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 339 B

After

Width:  |  Height:  |  Size: 940 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 636 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 607 B

After

Width:  |  Height:  |  Size: 883 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 348 B

View File

@ -1,9 +1,6 @@
appear.png:
type:bopti-image
name: img_appear
appearblock.png:
type:bopti-image
name: img_appearblock
blackout.png:
type:bopti-image
name: img_blackout
@ -16,9 +13,6 @@ chrono1.png:
chrono2.png:
type:bopti-image
name: img_chrono2
chrono2appear.png:
type:bopti-image
name: img_chrono2appear
coin.png:
type:bopti-image
name: img_coin
@ -33,6 +27,7 @@ end.png:
name: img_end
endscreen.png:
type:bopti-image
profile:p4
name: img_endscreen
fxconv-metadata.txt:
type:bopti-image
@ -46,32 +41,26 @@ key1.png:
key2.png:
type:bopti-image
name: img_key2
key2block.png:
type:bopti-image
name: img_key2block
key2blockvoid.png:
type:bopti-image
name: img_key2blockvoid
keyblock.png:
type:bopti-image
name: img_keyblock
medals.png:
type:bopti-image
name: img_medals
menu.png:
type:bopti-image
profile:p4
name: img_menu
new.png:
type:bopti-image
profile:p4
name: img_new
player.png:
type:bopti-image
name: img_player
solid_0.png:
solid.png:
type:bopti-image
name: img_solid_0
name: img_solid
speedrun.png:
type:bopti-image
profile:p4
name: img_speedrun
switch.png:
type:bopti-image

Binary file not shown.

Before

Width:  |  Height:  |  Size: 266 B

After

Width:  |  Height:  |  Size: 812 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 258 B

After

Width:  |  Height:  |  Size: 982 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 259 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 590 B

View File

Before

Width:  |  Height:  |  Size: 461 B

After

Width:  |  Height:  |  Size: 461 B

View File

@ -47,7 +47,3 @@ while 1:
save.write("}}\nvoid del_level(char level[])\n{memcpy(level,\"\
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",350);}")
#copy the textures from editor
import shutil
shutil.copytree("editor/img","assets-cg/img", dirs_exist_ok=True)

View File

@ -1,4 +1,4 @@
11111dddd100d110111111331000000000000d1d0000dd10s0111d00000000K1d10000d11111ddddd11ddhh1dddd000dddd11100Sh00dd00000dd00000001i0000000dd000000d0000S001i01100d0dd00d000dd0000001i0d00Sd0dd00dd10ddhh00l01i0ddddd0dd00ddi0d00000001iBBBdd0011aaddi0d0S00d0011000dd000300ddi0d0000d00110mmdd000d00ddi0dd00dd0011emtdddddd00ddi0ddddddkk1111111111100111Bdddd110016
15
14
7

View File

@ -2,4 +2,3 @@
echo "#define LEVEL_MAX $(ls editor/levels/[^0]*.lvl | wc -l)
#define PLAYER_HEIGHT 11
#define FPS 70" > include/define.h
python3 compile_levels.py

View File

@ -1,90 +0,0 @@
#---
# fxSDK project configuration file for cube
#---
# Project name, should be at most 8 bytes long.
# (You can also specify NAME_G1A or NAME_G3A to override individually.)
NAME := AST3
# Internal name, should be '@' followed by at most 7 uppercase letters.
# WARNING: If this convention is not followed, the add-in might not appear in
# the main menu of the calculator!
INTERNAL := ASTTT
# Output file name. The default is to take <NAME>, replace spaces with dashes,
# and add .g1a (or .g3a). You can specify a different folder if you want.
TARGET_FX :=
TARGET_CG :=
# fx-9860G icon location
ICON_FX = assets-fx/icon-fx.png
# fx-CG 50 icon locations
ICON_CG_UNS = assets-cg/icon-cg-uns.png
ICON_CG_SEL = assets-cg/icon-cg-sel.png
#---
# Toolchain selection
#---
# Toolchain for fx9860g. Please see also CFLAGS_FX below.
TOOLCHAIN_FX := sh-elf
# Toolchain for fxcg50. Please see also CFLAGS_CG below.
TOOLCHAIN_CG := sh-elf
#---
# Compiler flags
#---
# Base compiler flags for the fxSDK, you usually want to keep these.
CFLAGS := -mb -ffreestanding -nostdlib -fstrict-volatile-bitfields
# Platform-specific compiler flags.
# <> If you are using sh3eb-elf, use -m3. (You can do this on both FX and CG.)
# <> If you are using sh4eb-elf, use -m4-nofpu. (Not ideal on FX but works.)
# <> If you are using sh4eb-nofpu-elf, then your compiler will likely use the
# FPU and cause problems on the calculator. Consider another configuration.
# <> If you are using an sh-elf with several targets, specify whichever you
# support. I recommend -m3 on FX and -m4-nofpu on CG.
# Please see also TOOLCHAIN_FX and TOOLCHAIN_CG above.
CFLAGS_FX := -D FX9860G -m3
CFLAGS_CG := -D FXCG50 -m4-nofpu
# Additional compiler flags, change to your own taste!
CFLAGS += -Wall -Wextra -Os
# Include paths. Add one -I option for each folder from which you want to
# be able to include files with #include<>.
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_FX :=
LIBS_CG :=
# Base linker flags for the fxSDK, you usually want to keep these.
LDFLAGS_FX := -T fx9860g.ld -lgint-fx $(LIBS_FX) -lgint-fx -lgcc
LDFLAGS_CG := -T fxcg50.ld -lgint-cg $(LIBS_CG) -lgint-cg -lgcc
# Additional linker flags, if you need any.
LDFLAGS :=
# Additional platform-specific linker flags.
LDFLAGS_FX += -Wl,-Map=build-fx/map
LDFLAGS_CG += -Wl,-Map=build-cg/map
#---
# File conversion parameters
#---
# Here you can add fxconv options for each converted file, individually.
# The syntax is "<type>.<file>". For example, to specify the parameters for a
# font named "hexa.png", you might write:
#
# FONT.hexa.png = charset:print grid.size:3x5 grid.padding:1
IMG.speedrun.png = profile:p4
IMG.menu.png = profile:p4
IMG.endscreen.png = profile:p4
IMG.new.png = profile:p4

View File

@ -6,26 +6,21 @@
#define VISIBLE_RECT 35
extern bopti_image_t img_solid_0; //solid block
extern bopti_image_t img_solid; //solid block
extern bopti_image_t img_coin; //facultative coin
extern bopti_image_t img_dead; //dead block
extern bopti_image_t img_player; //player
extern bopti_image_t img_end; //end of level
extern bopti_image_t img_key1; //key 1
extern bopti_image_t img_keyblock; //block link to the key1
extern bopti_image_t img_blackout; //blackout
extern bopti_image_t img_chrono1; //chronoblock
extern bopti_image_t img_chrono2; //chronoblock 2
extern bopti_image_t img_key2; //key 2
extern bopti_image_t img_key2block; //block link to the key 2
extern bopti_image_t img_key2blockvoid; //block link to the 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_appear; //appear block
extern bopti_image_t img_appearblock; //appear block
extern bopti_image_t img_chrono2appear; //appear block
extern bopti_image_t img_endscreen;
extern bopti_image_t img_new;
@ -46,7 +41,7 @@ void draw_level(char level[])
switch(level[i])
{
case '1': //solid block
dimage(x,y,&img_solid_0);
dimage(x,y,&img_solid);
break;
case 't': //coin (treasure)
dimage(x,y,&img_coin);
@ -58,25 +53,25 @@ void draw_level(char level[])
dimage(x,y,&img_end);
break;
case '3': //block link to the key1
dimage(x,y,&img_keyblock);
dsubimage(x,y,&img_key1,0,0,16,16,DIMAGE_NONE);
break;
case 'k': //key1
dimage(x,y,&img_key1);
dsubimage(x,y,&img_key1,16,0,16,16,DIMAGE_NONE);
break;
case 'a': //block link to the key2 when it's not powered on
dimage(x,y,&img_key2blockvoid);
case 'a': //block link to the key2 when it's not on
dsubimage(x,y,&img_key2,0,0,16,16,DIMAGE_NONE);
break;
case '4': //block link to the key2
dimage(x,y,&img_key2block);
dsubimage(x,y,&img_key2,16,0,16,16,DIMAGE_NONE);
break;
case 'K': //key2
dimage(x,y,&img_key2);
dsubimage(x,y,&img_key2,32,0,16,16,DIMAGE_NONE);
break;
case 'c': //chrono blocks
dimage(x,y,&img_chrono1);
break;
case 'C': //chrono blocks
dimage(x,y,&img_chrono2);
dsubimage(x,y,&img_chrono2,16,0,16,16,DIMAGE_NONE);
break;
case 'b': //blackout blocks
dimage(x,y,&img_blackout);
@ -94,16 +89,16 @@ void draw_level(char level[])
dimage(x,y,&img_switch);
break;
case 'h': //void appear blocks
dimage(x,y,&img_appear);
dsubimage(x,y,&img_appear,0,0,16,16,DIMAGE_NONE);
break;
case 'H': //appear blocks
dimage(x,y,&img_appearblock);
dsubimage(x,y,&img_appear,16,0,16,16,DIMAGE_NONE);
break;
case 'y': //appear blocks
dimage(x,y,&img_appear);
dsubimage(x,y,&img_appear,0,0,16,16,DIMAGE_NONE);
break;
case 'm': //chronoappear blocks
dimage(x,y,&img_chrono2appear);
dsubimage(x,y,&img_chrono2,0,0,16,16,DIMAGE_NONE);
break;
}
x+=16;

View File

@ -2,6 +2,8 @@
#include <gint/gint.h>
#include "define.h"
#include "drawlevel.h"
#include <gint/keyboard.h>
int retcode;
int id_leveltab = 0;
@ -39,7 +41,7 @@ void loadfile(void)
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] == 0 || keydown(KEY_7))
{
times[id_level - 1] = (int)(framelevel / FPS * 100);
draw_end((int)framelevel, id_level, 1);

33
time.py
View File

@ -2,35 +2,36 @@ gold = 1.2
argent = 1.5
bronze = 2
f = open("times.lvl","r+")
d = open("src/times.c","w")
lvm = open(f"include/define.h","r")
ids=f.readlines()
timeslevel = open("times.lvl","r+")
dest = open("src/times.c","w")
lvm = open("include/define.h","r")
ids=timeslevel.readlines()
times=[]
for i in ids:
times.append(i.rstrip())
try:
for i in range(int(''.join(list(filter(str.isdigit, lvm.readline()))))):
hop=times[i].find("-")
if hop!=-1: times[i]=times[i][:hop]
except IndexError:
times.append("0.00")
d.write("#include \"times.h\"\n\
times.append(i.rstrip())
nblvl = int(''.join(filter(str.isdigit,lvm.readline())))
while(len(times) < nblvl):
times.append("0.00")
dest.write("#include \"times.h\"\n\
#include \"define.h\"\n\
#include <gint/display.h>\n\
#include <gint/keyboard.h>\n\n\
extern bopti_image_t img_medals;\n\
float level_time[] = {")
d.write(f"{','.join(times)}")
dest.write(f"{','.join(times)}")
d.write("};\n\
dest.write("};\n\
void check_medal(unsigned int frame_level, int id_level, int x, int y)\n\
{\n\
float time=1.0;\n\
float framefloat = frame_level;")
d.write("\ntime = level_time[id_level-1];\n\n\
dest.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))) dsubimage(x+45,y,&img_medals,36,0,12,12,DIMAGE_NONE);\n\
if(frame_level/FPS < (unsigned int)(time*"+str(gold)+") || (frame_level/FPS <= (unsigned int)(time*"+str(gold)+") && \n\
@ -46,7 +47,7 @@ void draw_time(int id_level)\n\
dclear(C_WHITE);\n\
float time=1.0;\n")
d.write("\ntime = level_time[id_level-1];\n\n\
dest.write("\ntime = level_time[id_level-1];\n\n\
dsubimage(172,90,&img_medals,36,0,12,12,DIMAGE_NONE);\n\
dprint(187,90,C_BLACK,\"%.2j\",(int)(time*100));\n\
dsubimage(172,110,&img_medals,24,0,12,12,DIMAGE_NONE);\n\

View File

@ -13,4 +13,4 @@
5.39
8.35
7.45
14.01
10.53