Skip to content

Commit

Permalink
Added hint text, fixed issue with doors going through blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePythonator committed Mar 1, 2022
1 parent f5faf54 commit 76825f7
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 3 deletions.
9 changes: 9 additions & 0 deletions Constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace SPRITES {
const uint8_t SCALE = 2;

const uint8_t TEXT_SCALE = 4;
const uint8_t TEXT_HINT_SCALE = 2;

const uint8_t SIZE = 16;
const uint8_t SIZE_HALF = SIZE / 2;
Expand All @@ -15,6 +16,7 @@ namespace SPRITES {
const uint8_t TEXT_OFFSET_X = SIZE * 4;// 5 or 6 work too, but text looks too wide when beziering

const uint8_t TEXT_LOCKED_ALPHA = 96;
const uint8_t TEXT_HINT_ALPHA = 128;
}

namespace TILE_ID {
Expand Down Expand Up @@ -303,6 +305,13 @@ namespace STRINGS {

const std::string COLON_SPACE = ": ";

extern const std::vector<std::string> HINTS {
"Blue and Pink move in opposite directions",
"If you want a challenge, try collecting the orbs",
"Springs can be used to reach other areas",
"Buttons open all doors of the same colour"
};

namespace MENU {
namespace TITLE {
const std::string HEADING_BLUE = "A PAIR OF";
Expand Down
4 changes: 4 additions & 0 deletions Constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace SPRITES {
extern const uint8_t SCALE;

extern const uint8_t TEXT_SCALE;
extern const uint8_t TEXT_HINT_SCALE;

extern const uint8_t SIZE;
extern const uint8_t SIZE_HALF;
Expand All @@ -23,6 +24,7 @@ namespace SPRITES {
extern const uint8_t TEXT_OFFSET_X;// 5 or 6 work too, but text looks too wide when beziering

extern const uint8_t TEXT_LOCKED_ALPHA;
extern const uint8_t TEXT_HINT_ALPHA;
}

namespace TILE_ID {
Expand Down Expand Up @@ -289,6 +291,8 @@ namespace STRINGS {

extern const std::string COLON_SPACE;

extern const std::vector<std::string> HINTS;

namespace MENU {
namespace TITLE {
extern const std::string HEADING_BLUE;
Expand Down
3 changes: 2 additions & 1 deletion Door.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ void Door::render(Spritesheet& spritesheet) {
/*if (height < SPRITES::SIZE) {
spritesheet.sprite_scaled(type == 0 ? TILE_ID::DOOR::VERTICAL::BLUE_MIDDLE : TILE_ID::DOOR::VERTICAL::PINK_MIDDLE, x, y - height + GAME::DOOR::CLOSE_SIZE);
}*/
float clamped = std::max(y - height + GAME::DOOR::CLOSE_SIZE, y - SPRITES::SIZE);

spritesheet.sprite_scaled(type == 0 ? TILE_ID::DOOR::VERTICAL::BLUE_MIDDLE : TILE_ID::DOOR::VERTICAL::PINK_MIDDLE, x, y - height + GAME::DOOR::CLOSE_SIZE);
spritesheet.sprite_scaled(type == 0 ? TILE_ID::DOOR::VERTICAL::BLUE_MIDDLE : TILE_ID::DOOR::VERTICAL::PINK_MIDDLE, x, clamped);
spritesheet.sprite_scaled(type == 0 ? TILE_ID::DOOR::VERTICAL::BLUE_BOTTOM : TILE_ID::DOOR::VERTICAL::PINK_BOTTOM, x, y - height + GAME::DOOR::CLOSE_SIZE + SPRITES::SIZE);
}

Expand Down
14 changes: 13 additions & 1 deletion Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ void Game::load_data() {
//font_white = FontHandler::Font(renderer, font_sheet_surface, SPRITES::SIZE, SPRITES::TEXT_SCALE, COLOURS::WHITE);
font_selected = FontHandler::Font(renderer, font_sheet_surface, SPRITES::SIZE, SPRITES::TEXT_SCALE, COLOURS::SELECTED, COLOURS::TRUE_WHITE);
font_highlighted = FontHandler::Font(renderer, font_sheet_surface, SPRITES::SIZE, SPRITES::TEXT_SCALE, COLOURS::HIGHLIGHTED, COLOURS::TRUE_WHITE);
font_hint = FontHandler::Font(renderer, font_sheet_surface, SPRITES::SIZE, SPRITES::TEXT_HINT_SCALE, COLOURS::WHITE, COLOURS::TRUE_WHITE);
font_hint.set_alpha(SPRITES::TEXT_HINT_ALPHA);

font_title_blue = FontHandler::Font(renderer, title_font_blue_sheet_surface, SPRITES::SIZE, SPRITES::TEXT_SCALE, COLOURS::TRUE_WHITE);
font_title_pink = FontHandler::Font(renderer, title_font_pink_sheet_surface, SPRITES::SIZE, SPRITES::TEXT_SCALE, COLOURS::TRUE_WHITE);
Expand Down Expand Up @@ -897,6 +899,8 @@ void Game::render_game_running() {

level_handler.render(spritesheet);

render_hint();

player.render(spritesheet);

// Display fade-in black rect
Expand Down Expand Up @@ -1085,6 +1089,8 @@ void Game::render_game_paused() {

level_handler.render(spritesheet);

render_hint();

player.render(spritesheet);

// Cause game scene to be partially faded out
Expand Down Expand Up @@ -1162,7 +1168,6 @@ void Game::render_game_end() {
float left_x = positions.first;
float right_x = positions.second;


// TODO: No longer use death count in score. Possible remove score altogether and just display time, orbs, and highscores for those.

// TODO: JUST DISPLAY TIME, ORBS, and HIGHSCORES FOR EACH. (and deaths)
Expand Down Expand Up @@ -1491,6 +1496,13 @@ ImageParticle Game::create_game_finish_particle(float x, float y, uint8_t colour
return ImageParticle(TILE_ID::PARTICLE::FINISH_BLUE + colour, new_x * position_scale, y * position_scale, x_speed * position_scale, y_speed * position_scale, 0.0f, 0.0f, 0.0f, rand() % 90 - 45, scale, 255, fade);
}

void Game::render_hint() {
// Render help text
if (current_level < STRINGS::HINTS.size()) {
TextHandler::render_text(font_hint, STRINGS::HINTS[current_level], WINDOW::WIDTH / (2 * SPRITES::TEXT_HINT_SCALE), SPRITES::SIZE * 4, SPRITES::SPACE_WIDTH);
}
}

void Game::fill_menu_shape_particle(uint8_t count) {
for (uint8_t i = 0; i < count; i++) {
//uint8_t colour = rand() % 3 ? 1 : 0;
Expand Down
6 changes: 5 additions & 1 deletion Game.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ class Game {

ImageParticle create_game_finish_particle(float x, float y, uint8_t id);

void render_hint();

void fill_menu_shape_particle(uint8_t count);
void setup_menu_shape_particles();

Expand Down Expand Up @@ -152,7 +154,7 @@ class Game {

// Fonts
SDL_Texture* font_sheet_texture = NULL;
FontHandler::Font font_white, font_selected, font_highlighted, font_title_blue, font_title_pink;
FontHandler::Font font_white, font_selected, font_highlighted, font_hint, font_title_blue, font_title_pink;

// Input handler
InputHandler input_handler;
Expand Down Expand Up @@ -204,6 +206,8 @@ class Game {
struct {
bool audio_music = true;
bool audio_sfx = true;
//bool show_hints = true;

uint8_t level_reached = 0;

std::vector<float> highscore_times;
Expand Down

0 comments on commit 76825f7

Please sign in to comment.