Skip to content

Commit

Permalink
Switch to flarn2006's bmpfont library, Enable romfs (not working thou…
Browse files Browse the repository at this point in the history
…gh), Scene clean up, and replays work on any setting
  • Loading branch information
TricksterGuy committed Jun 15, 2016
1 parent 89f60f6 commit e011b37
Show file tree
Hide file tree
Showing 28 changed files with 596 additions and 229 deletions.
214 changes: 107 additions & 107 deletions bottomless-block-barrage.layout

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions resources/template.rsf
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ BasicInfo:
ProductCode : $(APP_PRODUCT_CODE)
Logo : Nintendo # Nintendo / Licensed / Distributed / iQue / iQueForSystem

#RomFs:
RomFs:
# Specifies the root path of the read only file system to include in the ROM.
#RootPath : $(APP_ROMFS)
RootPath : $(APP_ROMFS)

TitleInfo:
Category : Application
Expand Down
Binary file added romfs/font/Arial Black.bff
Binary file not shown.
7 changes: 5 additions & 2 deletions source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ std::unique_ptr<Font> font;

int main()
{
romfsInit();
sf2d_init();
sf2d_set_clear_color(RGBA8(0x0, 0x0, 0x0, 0xFF));
sf2d_set_3D(0);

font.reset(new Font(font_gfx, FONT_GFX_WIDTH, FONT_GFX_HEIGHT, 16, 16, TEXFMT_RGBA8, SF2D_PLACE_RAM));
Window::set_skin(windowskin, TEXFMT_RGBA8, SF2D_PLACE_RAM);
font.reset(new Font("/Arial Black.bff"));
if (font->valid())
Window::set_skin(windowskin, TEXFMT_RGBA8, SF2D_PLACE_RAM);
std::unique_ptr<Scene> scene;
current_scene = new TitleScene();

Expand All @@ -44,5 +46,6 @@ int main()
}

sf2d_fini();
romfsExit();
return 0;
}
11 changes: 9 additions & 2 deletions source/moves_recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
const std::string generate_filename()
{
char buffer[128];
time_t now = time(0);
/*time_t now = time(0);
struct tm tstruct = *localtime(&now);
strftime(buffer, sizeof(buffer), "/bbb-moves/%Y-%m-%d-%X", &tstruct);
strftime(buffer, sizeof(buffer), "/bbb-moves/%Y-%m-%d-%X", &tstruct);*/
sprintf(buffer, "/bbb-moves/%ld", osGetTime());
return buffer;

}

void MovesRecorder::clear()
Expand Down Expand Up @@ -45,6 +47,8 @@ bool MovesRecorder::save(const std::string& specific_filename)

file.write(reinterpret_cast<char*>(&size), sizeof(size));
file.write(reinterpret_cast<char*>(&seed), sizeof(seed));
file.write(reinterpret_cast<char*>(&difficulty), sizeof(difficulty));
file.write(reinterpret_cast<char*>(&level), sizeof(level));
for (u32 i = 0; i < moves.size(); i++)
{
const Move& move = moves[i];
Expand All @@ -66,6 +70,8 @@ bool MovesRecorder::load(const std::string& filename)
u32 size = 0;
file.read(reinterpret_cast<char*>(&size), sizeof(size));
file.read(reinterpret_cast<char*>(&seed), sizeof(seed));
file.read(reinterpret_cast<char*>(&difficulty), sizeof(difficulty));
file.read(reinterpret_cast<char*>(&level), sizeof(level));
for (u32 i = 0; i < size; i++)
{
Move move;
Expand All @@ -76,6 +82,7 @@ bool MovesRecorder::load(const std::string& filename)
moves.push_back(move);
}
file.close();
return true;
}

void MovesRecorder::keys(u32& trigger, u32& held)
Expand Down
2 changes: 2 additions & 0 deletions source/moves_recorder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class MovesRecorder


u32 seed;
u32 difficulty = 0;
u32 level = 1;
private:
std::vector<Move> moves;
u32 frame = 0;
Expand Down
9 changes: 1 addition & 8 deletions source/scenes/endless_config_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,7 @@ void EndlessConfigScene::update_level_select()
}
}

void EndlessConfigScene::draw_top_left()
{
difficulty_choices.draw();
level_text.draw();
level_slider.draw();
}

void EndlessConfigScene::draw_top_right()
void EndlessConfigScene::draw_top()
{
difficulty_choices.draw();
level_text.draw();
Expand Down
3 changes: 1 addition & 2 deletions source/scenes/endless_config_scene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ class EndlessConfigScene : public Scene
void initialize();
void update();
protected:
void draw_top_left();
void draw_top_right();
void draw_top();
void draw_bottom();
private:
void update_difficulty_select();
Expand Down
22 changes: 4 additions & 18 deletions source/scenes/endless_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ EndlessScene::EndlessScene(const Config& c) : config(c), level(c.level)
void EndlessScene::initialize()
{
recorder.seed = (unsigned int) time(NULL);
recorder.difficulty = config.difficulty;
recorder.level = config.level;
srand(recorder.seed);

switch (config.difficulty)
Expand Down Expand Up @@ -172,7 +174,7 @@ void EndlessScene::update_gameover()
if (trigger & KEY_A)
{
if (save_replay_command.selection() == 0)
recorder.save("/bbb-moves/test");
recorder.save();

save_replay_command.set_active(false);
save_replay_command.set_hidden(true);
Expand All @@ -198,23 +200,7 @@ void EndlessScene::update_gameover()
}
}

void EndlessScene::draw_top_left()
{
if (panel_table.is_gameover())
{
game_over.draw();
try_again.draw();
save_replay_command.draw();
try_again_command.draw();
}
else
{
info.draw();
ccc_stats.draw();
}
}

void EndlessScene::draw_top_right()
void EndlessScene::draw_top()
{
if (panel_table.is_gameover())
{
Expand Down
3 changes: 1 addition & 2 deletions source/scenes/endless_scene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ class EndlessScene : public Scene
void update();

protected:
void draw_top_left();
void draw_top_right();
void draw_top();
void draw_bottom();

void draw_selector();
Expand Down
9 changes: 1 addition & 8 deletions source/scenes/puzzle_select_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,7 @@ void PuzzleSelectScene::update_level_select()
}
}

void PuzzleSelectScene::draw_top_left()
{
set_choices.draw();
stage_choices.draw();
level_choices.draw();
}

void PuzzleSelectScene::draw_top_right()
void PuzzleSelectScene::draw_top()
{
set_choices.draw();
stage_choices.draw();
Expand Down
3 changes: 1 addition & 2 deletions source/scenes/puzzle_select_scene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ class PuzzleSelectScene : public Scene
void initialize();
void update();
protected:
void draw_top_left();
void draw_top_right();
void draw_top();
void draw_bottom();
private:
void update_set_select();
Expand Down
21 changes: 8 additions & 13 deletions source/scenes/replay_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@
#include "selector_gfx.h"
#include "debug_text.h"

ReplayScene::ReplayScene(const Config& c) : config(c), level(c.level)
ReplayScene::ReplayScene(const Config& c) : config(c)
{

}

void ReplayScene::initialize()
{
recorder.load(config.replay_filename);
level = recorder.level;
srand(recorder.seed);

switch (config.difficulty)
switch (recorder.difficulty)
{
case EASY:
panel_table.create(11, 6, 5, easy_speed_settings);
Expand All @@ -33,8 +34,8 @@ void ReplayScene::initialize()
break;
}

info.set_level(config.level);
info.set_difficulty(config.difficulty);
info.set_level(level);
info.set_difficulty(static_cast<Difficulty>(recorder.difficulty));

panels.create(panels_gfx, PANELS_GFX_WIDTH, PANELS_GFX_HEIGHT, TEXFMT_RGBA8, SF2D_PLACE_RAM);
selector.create(selector_gfx, SELECTOR_GFX_WIDTH, SELECTOR_GFX_HEIGHT, TEXFMT_RGBA8, SF2D_PLACE_RAM);
Expand Down Expand Up @@ -90,7 +91,7 @@ void ReplayScene::update()
if (last_match.is_timeout())
{
int timeout = calculate_timeout(last_match.combo, last_match.cascade + 1,
3 - (int)config.difficulty, panel_table.is_danger());
3 - (int)recorder.difficulty, panel_table.is_danger());
panel_table.set_timeout(timeout);
info.set_timeout(timeout);
}
Expand Down Expand Up @@ -118,7 +119,7 @@ void ReplayScene::update()
if (minfo.is_timeout())
{
int timeout = calculate_timeout(minfo.combo, minfo.cascade + 1,
3 - (int)config.difficulty, panel_table.is_danger());
3 - (int)recorder.difficulty, panel_table.is_danger());
info.set_timeout(timeout);
}
last_match = minfo;
Expand All @@ -130,13 +131,7 @@ void ReplayScene::update()
frame++;
}

void ReplayScene::draw_top_left()
{
info.draw();
ccc_stats.draw();
}

void ReplayScene::draw_top_right()
void ReplayScene::draw_top()
{
info.draw();
ccc_stats.draw();
Expand Down
5 changes: 1 addition & 4 deletions source/scenes/replay_scene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,14 @@ class ReplayScene : public Scene
struct Config
{
std::string replay_filename;
Difficulty difficulty;
int level;
};
ReplayScene(const Config& config);
~ReplayScene() {}
void initialize();
void update();

protected:
void draw_top_left();
void draw_top_right();
void draw_top();
void draw_bottom();

void draw_selector();
Expand Down
13 changes: 3 additions & 10 deletions source/scenes/replay_select_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ std::vector<std::string> get_replays()

void ReplaySelectScene::initialize()
{
replays.create(0, 0, TOP_SCREEN_WIDTH / 3 - 2 * WINDOW_BORDER_SIZE, 16, 3, get_replays());
replays.create(0, 0, TOP_SCREEN_WIDTH - 2 * WINDOW_BORDER_SIZE, 16, 1, get_replays());
replays.set_active(true);
}

Expand All @@ -40,11 +40,9 @@ void ReplaySelectScene::update()
if (trigger & KEY_A)
{
std::string choice = replays.choice();
choice = "/bbb-moves/test";// + choice;
choice = "/bbb-moves/" + choice;
ReplayScene::Config config;
config.replay_filename = choice;
config.level = 1;
config.difficulty = EASY;
current_scene = new ReplayScene(config);
}
else if (trigger & KEY_B || (trigger == 0 && replays.empty()))
Expand All @@ -54,12 +52,7 @@ void ReplaySelectScene::update()

}

void ReplaySelectScene::draw_top_left()
{
replays.draw();
}

void ReplaySelectScene::draw_top_right()
void ReplaySelectScene::draw_top()
{
replays.draw();
}
Expand Down
3 changes: 1 addition & 2 deletions source/scenes/replay_select_scene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ class ReplaySelectScene : public Scene
void initialize();
void update();
protected:
void draw_top_left();
void draw_top_right();
void draw_top();
void draw_bottom();
private:
CommandWindow replays;
Expand Down
6 changes: 4 additions & 2 deletions source/scenes/scene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ class Scene
virtual void update() {}
void draw();
protected:
virtual void draw_top_left() {}
virtual void draw_top_right() {}
virtual void draw_top_left() {draw_top();}
virtual void draw_top_right() {draw_top();}

virtual void draw_top() {}
virtual void draw_bottom() {}
KeyRepeatStore repeat;
};
Expand Down
7 changes: 1 addition & 6 deletions source/scenes/title_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,7 @@ void TitleScene::update()
current_scene = NULL;
}

void TitleScene::draw_top_left()
{
background.draw();
}

void TitleScene::draw_top_right()
void TitleScene::draw_top()
{
background.draw();
}
Expand Down
3 changes: 1 addition & 2 deletions source/scenes/title_scene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ class TitleScene : public Scene
void initialize();
void update();
protected:
void draw_top_left();
void draw_top_right();
void draw_top();
void draw_bottom();
private:
Texture background;
Expand Down
Loading

0 comments on commit e011b37

Please sign in to comment.