Update to use the actual flappy bird font in score

This commit is contained in:
breadone 2023-03-11 15:25:46 +13:00
parent bb4b48b677
commit 984a32a25d
17 changed files with 38 additions and 36 deletions

View File

@ -37,7 +37,6 @@ SOURCES := source
DATA := data
INCLUDES := include
GRAPHICS := gfx
#GFXBUILD := $(BUILD)
ROMFS := romfs
GFXBUILD := $(ROMFS)/gfx
@ -88,6 +87,7 @@ SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
GFXFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.t3s)))
FONTFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.ttf)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
@ -108,10 +108,12 @@ endif
ifeq ($(GFXBUILD),$(BUILD))
#---------------------------------------------------------------------------------
export T3XFILES := $(GFXFILES:.t3s=.t3x)
export EFONTFILES := $(FONTFILES:.ttf=.bcfnt)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export ROMFS_T3XFILES := $(patsubst %.t3s, $(GFXBUILD)/%.t3x, $(GFXFILES))
export ROMFS_FONTFILES := $(patsubst %.ttf, $(GFXBUILD)/%.bcfnt, $(FONTFILES))
export T3XHFILES := $(patsubst %.t3s, $(BUILD)/%.h, $(GFXFILES))
#---------------------------------------------------------------------------------
endif
@ -121,7 +123,7 @@ export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export OFILES_BIN := $(addsuffix .o,$(BINFILES)) \
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \
$(addsuffix .o,$(T3XFILES))
$(addsuffix .o,$(T3XFILES)) $(addsuffix .o,$(EFONTFILES))
export OFILES := $(OFILES_BIN) $(OFILES_SOURCES)
@ -161,7 +163,7 @@ endif
.PHONY: all clean
#---------------------------------------------------------------------------------
all: $(BUILD) $(GFXBUILD) $(DEPSDIR) $(ROMFS_T3XFILES) $(T3XHFILES)
all: $(BUILD) $(GFXBUILD) $(DEPSDIR) $(ROMFS_T3XFILES) $(ROMFS_FONTFILES) $(T3XHFILES)
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
$(BUILD):
@ -188,6 +190,12 @@ $(GFXBUILD)/%.t3x $(BUILD)/%.h : %.t3s
@echo $(notdir $<)
@tex3ds -i $< -H $(BUILD)/$*.h -d $(DEPSDIR)/$*.d -o $(GFXBUILD)/$*.t3x
#---------------------------------------------------------------------------------
$(GFXBUILD)/%.bcfnt : %.ttf
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@mkbcfnt -o $(GFXBUILD)/$*.bcfnt $<
#---------------------------------------------------------------------------------
else
@ -209,13 +217,19 @@ $(OUTPUT).elf : $(OFILES)
@$(bin2o)
#---------------------------------------------------------------------------------
.PRECIOUS : %.t3x
.PRECIOUS : %.t3x %.bcfnt
#---------------------------------------------------------------------------------
%.t3x.o %_t3x.h : %.t3x
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
#---------------------------------------------------------------------------------
%.bcfnt.o %_bcfnt.h : %.bcfnt
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
#---------------------------------------------------------------------------------
# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
@ -248,6 +262,12 @@ endef
@echo $(notdir $<)
@tex3ds -i $< -H $*.h -d $*.d -o $*.t3x
#---------------------------------------------------------------------------------
%.bcfnt : %.ttf
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@mkbcfnt -o $*.bcfnt $<
-include $(DEPSDIR)/*.d
#---------------------------------------------------------------------------------------

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

BIN
gfx/fbfont.ttf Normal file

Binary file not shown.

View File

@ -1,15 +1,5 @@
--atlas -f rgba8888 -z auto
bird.png
big0.png
big1.png
big2.png
big3.png
big4.png
big5.png
big6.png
big7.png
big8.png
big9.png
bg.png
floor.png
logo.png

BIN
romfs/fbfont.bcfnt Normal file

Binary file not shown.

BIN
romfs/sprites.t3x Normal file

Binary file not shown.

View File

@ -19,7 +19,7 @@
#define SCREEN_WIDTH 400
#define SCREEN_HEIGHT 240
// Simple sprite struct
typedef struct {
C2D_Sprite spr;
float x, y; // pos
@ -47,11 +47,6 @@ static void initSprites() {
// set bird consts
C2D_SpriteSetPos(&sprites[SPR_BIRD].spr, SCREEN_WIDTH / 4, SCREEN_HEIGHT / 3);
// big number positions
for (size_t i = 1; i < 10; i++) {
C2D_SpriteSetPos(&sprites[i].spr, 260, 100); // a guess
}
// set bottom screen scorecard
C2D_SpriteSetCenter(&sprites[SPR_SCORECARD].spr, 0.0, 0.0);
C2D_SpriteSetPos(&sprites[SPR_SCORECARD].spr, 2, 40);
@ -93,8 +88,9 @@ int main(int argc, char* argv[]) {
C2D_Font font;
g_staticBuf = C2D_TextBufNew(4096);
font = C2D_FontLoadSystem(CFG_REGION_EUR);
font = C2D_FontLoad("romfs:/fbfont.bcfnt");
C2D_TextFontParse(&scoreText, font, g_staticBuf, "0");
C2D_TextOptimize(&scoreText);
// Load graphics
spriteSheet = C2D_SpriteSheetLoad("romfs:/gfx/sprites.t3x");
@ -141,6 +137,7 @@ int main(int argc, char* argv[]) {
char scoreString[(((sizeof score) * CHAR_BIT) + 2)/3 + 2];
sprintf(scoreString, "%d", score);
C2D_TextFontParse(&scoreText, font, g_staticBuf, scoreString);
C2D_TextOptimize(&scoreText);
// Render the scene
@ -156,13 +153,16 @@ int main(int argc, char* argv[]) {
// C2D_DrawSprite(&scoreSprite->spr);
C2D_DrawText(&scoreText, 0, 260, 100, 0.0f, 1, 1);
C2D_DrawText(&scoreText, 0, 255, 90, 0.0f, 1.0f, 1.0f);
C3D_FrameEnd(0);
}
// Delete graphics
C2D_SpriteSheetFree(spriteSheet);
C2D_TextBufDelete(g_staticBuf);
C2D_FontFree(font);
// Deinit libs
C2D_Fini();

View File

@ -4,21 +4,13 @@
#define SPRITES_H
#define SPR_BIRD 0
#define SPR_BIG0 1
#define SPR_BIG1 2
#define SPR_BIG2 3
#define SPR_BIG3 4
#define SPR_BIG5 6
#define SPR_BIG7 8
#define SPR_BIG8 9
#define SPR_BIG9 10
#define SPR_BG 11
#define SPR_FLOOR 12
#define SPR_LOGO 13
#define SPR_PIPEBOTTOM 14
#define SPR_PIPETOP 15
#define SPR_BG 1
#define SPR_FLOOR 2
#define SPR_LOGO 3
#define SPR_PIPEBOTTOM 4
#define SPR_PIPETOP 5
#define SPR_SCORECARD 16
#define SPR_SCORECARD 6
#endif