Skip to content

Commit

Permalink
Print text with gba-free-fonts.
Browse files Browse the repository at this point in the history
  • Loading branch information
laqieer committed Feb 14, 2022
1 parent 075f276 commit 01f91a3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
10 changes: 7 additions & 3 deletions source/fantasy-knight/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
# DATA is a list of directories containing binary data.
# GRAPHICS is a list of directories containing files to be processed by grit.
# AUDIO is a list of directories containing files to be processed by mmutil.
# FONTS is a list of directories containing font files.
# TEXTS is a list of directories or filenames containing text files.
# ROMTITLE is a uppercase ASCII, max 12 characters text string containing the output ROM title.
# ROMCODE is a uppercase ASCII, max 4 characters text string containing the output ROM code.
# USERFLAGS is a list of additional compiler flags:
Expand All @@ -26,17 +28,19 @@ BUILD := build
LIBBUTANO := ../../../butano/butano
PYTHON := python
SOURCES := src
INCLUDES := include
INCLUDES := include $(BUILD)
DATA :=
GRAPHICS := graphics
GRAPHICS := graphics $(BUILD)/fonts
AUDIO := audio
FONTS := ../../../gba-free-fonts/fonts/HanaMin
TEXTS := src/main.cpp
ROMTITLE := FANTASY KNIT
ROMCODE := FKNT
USERFLAGS :=
USERLIBDIRS :=
USERLIBS :=
USERBUILD :=
EXTTOOL :=
EXTTOOL := $(PYTHON) ../../../gba-free-fonts/tools/butano/butano_fonts_tool.py --build=$(BUILD) --fonts="$(FONTS)" --texts="$(TEXTS)"

#---------------------------------------------------------------------------------------------------------------------
# Export absolute butano path:
Expand Down
14 changes: 14 additions & 0 deletions source/fantasy-knight/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,22 @@
#include "bn_affine_bg_actions.h"
#include "bn_music_items.h"
#include "bn_sound_items.h"
#include "bn_string_view.h"
#include "bn_sprite_text_generator.h"
#include "hanamin_sprite_font.h"

bn::sprite_ptr *sprite;
bn::sprite_animate_action<10> *sprite_action;
bn::regular_bg_ptr *regular_bg;
bn::affine_bg_ptr *affine_bg;
bn::affine_bg_rotate_by_action *affine_bg_action;
bn::sprite_text_generator *text_generator;
bn::vector<bn::sprite_ptr, 10> *text_sprites;

void init_sprite();
void init_regular_bg();
void init_affine_bg();
void init_text();
void reset_sprite();
void reset_regular_bg();
void reset_affine_bg();
Expand All @@ -35,6 +41,7 @@ int main()
init_sprite();
init_regular_bg();
init_affine_bg();
init_text();
bn::music_items::age_of_time.play(0.25);
bn::sound_items::evil_monster_kevangc.play();

Expand Down Expand Up @@ -67,6 +74,13 @@ void init_affine_bg()
affine_bg_action = new bn::affine_bg_rotate_by_action(*affine_bg, 5);
}

void init_text()
{
text_generator = new bn::sprite_text_generator(hanamin_sprite_font);
text_sprites = new bn::vector<bn::sprite_ptr, 10>();
text_generator->generate(0, -70, "GBA开发最佳实践", *text_sprites);
}

void reset_sprite()
{
sprite->set_position(0, 0);
Expand Down

0 comments on commit 01f91a3

Please sign in to comment.