Make colors configurable
This commit is contained in:
parent
4a2f879448
commit
47349c06c1
@ -11,7 +11,7 @@ tetris: tetris.o sdlpp.o
|
|||||||
|
|
||||||
sdlpp.o: ../sdlpp.cpp ../sdlpp.hpp
|
sdlpp.o: ../sdlpp.cpp ../sdlpp.hpp
|
||||||
$(CXX) $(CFLAGS) -c -o $@ $<
|
$(CXX) $(CFLAGS) -c -o $@ $<
|
||||||
tetris.o: tetris.cpp ../sdlpp.hpp
|
tetris.o: tetris.cpp ../sdlpp.hpp config.hpp
|
||||||
$(CXX) $(CFLAGS) -c -o $@ $<
|
$(CXX) $(CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
78
tetris/config.hpp
Normal file
78
tetris/config.hpp
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
std::map<std::string, std::map<std::string, std::string>> color_schemes = {
|
||||||
|
{ "default", {
|
||||||
|
{"piece_brick", "#FF0000"},
|
||||||
|
{"piece_brick_out", "#AA0000"},
|
||||||
|
{"piece_T", "#00FF00"},
|
||||||
|
{"piece_T_out", "#00AA00"},
|
||||||
|
{"piece_L_right", "#0000FF"},
|
||||||
|
{"piece_L_right_out", "#0000AA"},
|
||||||
|
{"piece_Z_right", "#FF00FF"},
|
||||||
|
{"piece_Z_right_out", "#AA00AA"},
|
||||||
|
{"piece_line", "#FFFF00"},
|
||||||
|
{"piece_line_out", "#AAAA00"},
|
||||||
|
{"piece_L_left", "#00FFFF"},
|
||||||
|
{"piece_L_left_out", "#00AAAA"},
|
||||||
|
{"piece_Z_left", "#FFFFFF"},
|
||||||
|
{"piece_Z_left_out", "#AAAAAA"},
|
||||||
|
{"shadow", "#AAAAAAAA"},
|
||||||
|
{"background", "#222222"},
|
||||||
|
{"line", "#888888"},
|
||||||
|
{"barrier", "#AA0000"},
|
||||||
|
{"text", "#FFFFFF"},
|
||||||
|
{"text_out", "#000000"},
|
||||||
|
{"menu_background", "#00000080"},
|
||||||
|
{"menu_item_background", "#FFFFFF40"},
|
||||||
|
}},
|
||||||
|
{ "gruvbox_dark", {
|
||||||
|
{"piece_brick", "#cc241d"},
|
||||||
|
{"piece_brick_out", "#fb4934"},
|
||||||
|
{"piece_T", "#98971a"},
|
||||||
|
{"piece_T_out", "#b8bb26"},
|
||||||
|
{"piece_L_right", "#458588"},
|
||||||
|
{"piece_L_right_out", "#83a598"},
|
||||||
|
{"piece_Z_right", "#b16286"},
|
||||||
|
{"piece_Z_right_out", "#d3869b"},
|
||||||
|
{"piece_line", "#d79921"},
|
||||||
|
{"piece_line_out", "#fabd2f"},
|
||||||
|
{"piece_L_left", "#689d6a"},
|
||||||
|
{"piece_L_left_out", "#8ec07c"},
|
||||||
|
{"piece_Z_left", "#a89984"},
|
||||||
|
{"piece_Z_left_out", "#ebdbb2"},
|
||||||
|
{"shadow", "#bdae9380"},
|
||||||
|
{"background", "#282828"},
|
||||||
|
{"line", "#fbf1c7"},
|
||||||
|
{"barrier", "#d65d0e"},
|
||||||
|
{"text", "#ebdbb2"},
|
||||||
|
{"text_out", "#1d2021"},
|
||||||
|
{"menu_background", "#28282880"},
|
||||||
|
{"menu_item_background", "#d5c4a180"},
|
||||||
|
}},
|
||||||
|
{ "blackandwhite", {
|
||||||
|
{"piece_brick", "#FFFFFF"},
|
||||||
|
{"piece_brick_out", "#000000"},
|
||||||
|
{"piece_T", "#FFFFFF"},
|
||||||
|
{"piece_T_out", "#000000"},
|
||||||
|
{"piece_L_right", "#FFFFFF"},
|
||||||
|
{"piece_L_right_out", "#000000"},
|
||||||
|
{"piece_Z_right", "#FFFFFF"},
|
||||||
|
{"piece_Z_right_out", "#000000"},
|
||||||
|
{"piece_line", "#FFFFFF"},
|
||||||
|
{"piece_line_out", "#000000"},
|
||||||
|
{"piece_L_left", "#FFFFFF"},
|
||||||
|
{"piece_L_left_out", "#000000"},
|
||||||
|
{"piece_Z_left", "#FFFFFF"},
|
||||||
|
{"piece_Z_left_out", "#000000"},
|
||||||
|
{"shadow", "#FFFFFF80"},
|
||||||
|
{"background", "#000000"},
|
||||||
|
{"line", "#FFFFFF"},
|
||||||
|
{"barrier", "#FFFFFF"},
|
||||||
|
{"text", "#FFFFFF"},
|
||||||
|
{"text_out", "#000000"},
|
||||||
|
{"menu_background", "#00000080"},
|
||||||
|
{"menu_item_background", "#FFFFFF40"},
|
||||||
|
}},
|
||||||
|
};
|
@ -1,4 +1,5 @@
|
|||||||
#include "../sdlpp.hpp"
|
#include "../sdlpp.hpp"
|
||||||
|
#include "config.hpp"
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
@ -50,6 +51,8 @@ bool update_score = false;
|
|||||||
bool checked_line = false;
|
bool checked_line = false;
|
||||||
bool wait_for_anim = false;
|
bool wait_for_anim = false;
|
||||||
|
|
||||||
|
auto &colors = color_schemes["gruvbox_dark"];
|
||||||
|
|
||||||
std::vector< int > bag = { 28, 28, 28, 28, 28, 28, 28 };
|
std::vector< int > bag = { 28, 28, 28, 28, 28, 28, 28 };
|
||||||
|
|
||||||
std::shared_ptr< SDLPP::Font > font;
|
std::shared_ptr< SDLPP::Font > font;
|
||||||
@ -237,7 +240,7 @@ public:
|
|||||||
void turnIntoShadow() {
|
void turnIntoShadow() {
|
||||||
for(auto &block : getObjects() ) {
|
for(auto &block : getObjects() ) {
|
||||||
block->setId(SHADOW_ID);
|
block->setId(SHADOW_ID);
|
||||||
block->setColor("#AAAAAAAA");
|
block->setColor(colors["shadow"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::shared_ptr<TetrisPiece> copySelf() {
|
std::shared_ptr<TetrisPiece> copySelf() {
|
||||||
@ -305,8 +308,8 @@ std::shared_ptr< TetrisPiece >
|
|||||||
tetrisBrick( std::shared_ptr< SDLPP::Renderer > renderer,
|
tetrisBrick( std::shared_ptr< SDLPP::Renderer > renderer,
|
||||||
std::shared_ptr< SDLPP::Scene > scene ) {
|
std::shared_ptr< SDLPP::Scene > scene ) {
|
||||||
auto retPiece = std::make_shared< TetrisPiece >();
|
auto retPiece = std::make_shared< TetrisPiece >();
|
||||||
auto color = "#FF0000";
|
auto color = colors["piece_brick"];
|
||||||
auto outline = "#AA0000";
|
auto outline = colors["piece_brick_out"];
|
||||||
retPiece->addPiece( createTetrisBlock( 0.5 - BLOCK_SIZE, TOP_BORDER, color,
|
retPiece->addPiece( createTetrisBlock( 0.5 - BLOCK_SIZE, TOP_BORDER, color,
|
||||||
outline, TETRIS_BRICK, renderer,
|
outline, TETRIS_BRICK, renderer,
|
||||||
scene ),
|
scene ),
|
||||||
@ -330,8 +333,8 @@ std::shared_ptr< TetrisPiece >
|
|||||||
tetrisT( std::shared_ptr< SDLPP::Renderer > renderer,
|
tetrisT( std::shared_ptr< SDLPP::Renderer > renderer,
|
||||||
std::shared_ptr< SDLPP::Scene > scene ) {
|
std::shared_ptr< SDLPP::Scene > scene ) {
|
||||||
auto retPiece = std::make_shared< TetrisPiece >();
|
auto retPiece = std::make_shared< TetrisPiece >();
|
||||||
auto color = "#00FF00";
|
auto color = colors["piece_T"];
|
||||||
auto outline = "#00AA00";
|
auto outline = colors["piece_T_out"];
|
||||||
retPiece->addPiece( createTetrisBlock( 0.5 - BLOCK_SIZE,
|
retPiece->addPiece( createTetrisBlock( 0.5 - BLOCK_SIZE,
|
||||||
TOP_BORDER + BLOCK_SIZE, color,
|
TOP_BORDER + BLOCK_SIZE, color,
|
||||||
outline, TETRIS_T, renderer, scene ),
|
outline, TETRIS_T, renderer, scene ),
|
||||||
@ -353,8 +356,8 @@ std::shared_ptr< TetrisPiece >
|
|||||||
tetrisLRight( std::shared_ptr< SDLPP::Renderer > renderer,
|
tetrisLRight( std::shared_ptr< SDLPP::Renderer > renderer,
|
||||||
std::shared_ptr< SDLPP::Scene > scene ) {
|
std::shared_ptr< SDLPP::Scene > scene ) {
|
||||||
auto retPiece = std::make_shared< TetrisPiece >();
|
auto retPiece = std::make_shared< TetrisPiece >();
|
||||||
auto color = "#0000FF";
|
auto color = colors["piece_L_right"];
|
||||||
auto outline = "#0000AA";
|
auto outline = colors["piece_L_right_out"];
|
||||||
retPiece->addPiece(
|
retPiece->addPiece(
|
||||||
createTetrisBlock( 0.5 - BLOCK_SIZE, TOP_BORDER + BLOCK_SIZE, color,
|
createTetrisBlock( 0.5 - BLOCK_SIZE, TOP_BORDER + BLOCK_SIZE, color,
|
||||||
outline, TETRIS_L_RIGHT, renderer, scene ),
|
outline, TETRIS_L_RIGHT, renderer, scene ),
|
||||||
@ -378,8 +381,8 @@ std::shared_ptr< TetrisPiece >
|
|||||||
tetrisZRight( std::shared_ptr< SDLPP::Renderer > renderer,
|
tetrisZRight( std::shared_ptr< SDLPP::Renderer > renderer,
|
||||||
std::shared_ptr< SDLPP::Scene > scene ) {
|
std::shared_ptr< SDLPP::Scene > scene ) {
|
||||||
auto retPiece = std::make_shared< TetrisPiece >();
|
auto retPiece = std::make_shared< TetrisPiece >();
|
||||||
auto color = "#FF00FF";
|
auto color = colors["piece_Z_right"];
|
||||||
auto outline = "#AA00AA";
|
auto outline = colors["piece_Z_right_out"];
|
||||||
retPiece->addPiece(
|
retPiece->addPiece(
|
||||||
createTetrisBlock( 0.5 - BLOCK_SIZE, TOP_BORDER + BLOCK_SIZE, color,
|
createTetrisBlock( 0.5 - BLOCK_SIZE, TOP_BORDER + BLOCK_SIZE, color,
|
||||||
outline, TETRIS_Z_RIGHT, renderer, scene ),
|
outline, TETRIS_Z_RIGHT, renderer, scene ),
|
||||||
@ -402,8 +405,8 @@ std::shared_ptr< TetrisPiece >
|
|||||||
tetrisLine( std::shared_ptr< SDLPP::Renderer > renderer,
|
tetrisLine( std::shared_ptr< SDLPP::Renderer > renderer,
|
||||||
std::shared_ptr< SDLPP::Scene > scene ) {
|
std::shared_ptr< SDLPP::Scene > scene ) {
|
||||||
auto retPiece = std::make_shared< TetrisPiece >();
|
auto retPiece = std::make_shared< TetrisPiece >();
|
||||||
auto color = "#FFFF00";
|
auto color = colors["piece_line"];
|
||||||
auto outline = "#AAAA00";
|
auto outline = colors["piece_line_out"];
|
||||||
retPiece->addPiece( createTetrisBlock( 0.5 - 2 * BLOCK_SIZE, TOP_BORDER,
|
retPiece->addPiece( createTetrisBlock( 0.5 - 2 * BLOCK_SIZE, TOP_BORDER,
|
||||||
color, outline, TETRIS_LINE,
|
color, outline, TETRIS_LINE,
|
||||||
renderer, scene ),
|
renderer, scene ),
|
||||||
@ -426,8 +429,8 @@ std::shared_ptr< TetrisPiece >
|
|||||||
tetrisLLeft( std::shared_ptr< SDLPP::Renderer > renderer,
|
tetrisLLeft( std::shared_ptr< SDLPP::Renderer > renderer,
|
||||||
std::shared_ptr< SDLPP::Scene > scene ) {
|
std::shared_ptr< SDLPP::Scene > scene ) {
|
||||||
auto retPiece = std::make_shared< TetrisPiece >();
|
auto retPiece = std::make_shared< TetrisPiece >();
|
||||||
auto color = "#00FFFF";
|
auto color = colors["piece_L_left"];
|
||||||
auto outline = "#00AAAA";
|
auto outline = colors["piece_L_left_out"];
|
||||||
retPiece->addPiece( createTetrisBlock( 0.5 - BLOCK_SIZE, TOP_BORDER, color,
|
retPiece->addPiece( createTetrisBlock( 0.5 - BLOCK_SIZE, TOP_BORDER, color,
|
||||||
outline, TETRIS_L_LEFT, renderer,
|
outline, TETRIS_L_LEFT, renderer,
|
||||||
scene ),
|
scene ),
|
||||||
@ -451,8 +454,8 @@ std::shared_ptr< TetrisPiece >
|
|||||||
tetrisZLeft( std::shared_ptr< SDLPP::Renderer > renderer,
|
tetrisZLeft( std::shared_ptr< SDLPP::Renderer > renderer,
|
||||||
std::shared_ptr< SDLPP::Scene > scene ) {
|
std::shared_ptr< SDLPP::Scene > scene ) {
|
||||||
auto retPiece = std::make_shared< TetrisPiece >();
|
auto retPiece = std::make_shared< TetrisPiece >();
|
||||||
auto color = "#FFFFFF";
|
auto color = colors["piece_Z_left"];
|
||||||
auto outline = "#AAAAAA";
|
auto outline = colors["piece_Z_left_out"];
|
||||||
retPiece->addPiece( createTetrisBlock( 0.5 - BLOCK_SIZE, TOP_BORDER, color,
|
retPiece->addPiece( createTetrisBlock( 0.5 - BLOCK_SIZE, TOP_BORDER, color,
|
||||||
outline, TETRIS_Z_LEFT, renderer,
|
outline, TETRIS_Z_LEFT, renderer,
|
||||||
scene ),
|
scene ),
|
||||||
@ -480,7 +483,7 @@ std::vector< std::shared_ptr< TetrisPiece > ( * )(
|
|||||||
|
|
||||||
void addStuff( SDLPP::Scene &scene, std::shared_ptr< SDLPP::Renderer > &r ) {
|
void addStuff( SDLPP::Scene &scene, std::shared_ptr< SDLPP::Renderer > &r ) {
|
||||||
auto bg = std::make_shared< SDLPP::RectangleRender >( 0, 0, 10, 10, r,
|
auto bg = std::make_shared< SDLPP::RectangleRender >( 0, 0, 10, 10, r,
|
||||||
"#222222", true );
|
colors["background"], true );
|
||||||
bg->setPermanent();
|
bg->setPermanent();
|
||||||
scene.addObject( bg );
|
scene.addObject( bg );
|
||||||
|
|
||||||
@ -500,7 +503,7 @@ void addStuff( SDLPP::Scene &scene, std::shared_ptr< SDLPP::Renderer > &r ) {
|
|||||||
posy = 1;
|
posy = 1;
|
||||||
for ( int i = 0; i < 20; i++ ) {
|
for ( int i = 0; i < 20; i++ ) {
|
||||||
posy -= BLOCK_SIZE;
|
posy -= BLOCK_SIZE;
|
||||||
auto line = std::make_shared< SDLPP::LineRenderer >( LEFT_BORDER, posy, RIGHT_BORDER, posy, r, "#AAAAAA" );
|
auto line = std::make_shared< SDLPP::LineRenderer >( LEFT_BORDER, posy, RIGHT_BORDER, posy, r, colors["line"] );
|
||||||
line->setStatic();
|
line->setStatic();
|
||||||
line->centerX();
|
line->centerX();
|
||||||
scene.addObject( line );
|
scene.addObject( line );
|
||||||
@ -509,36 +512,35 @@ void addStuff( SDLPP::Scene &scene, std::shared_ptr< SDLPP::Renderer > &r ) {
|
|||||||
auto posx = RIGHT_BORDER;
|
auto posx = RIGHT_BORDER;
|
||||||
for ( int i = 0; i < 9; i++ ) {
|
for ( int i = 0; i < 9; i++ ) {
|
||||||
posx -= BLOCK_SIZE;
|
posx -= BLOCK_SIZE;
|
||||||
auto line = std::make_shared< SDLPP::LineRenderer >( posx, TOP_BORDER + BLOCK_SIZE, posx, BOTTOM_BORDER, r, "#AAAAAA" );
|
auto line = std::make_shared< SDLPP::LineRenderer >( posx, TOP_BORDER + BLOCK_SIZE, posx, BOTTOM_BORDER, r, colors["line"] );
|
||||||
line->setStatic();
|
line->setStatic();
|
||||||
line->centerX();
|
line->centerX();
|
||||||
scene.addObject( line );
|
scene.addObject( line );
|
||||||
}
|
}
|
||||||
|
|
||||||
auto left_barrier = std::make_shared< SDLPP::RectangleRender >(
|
auto left_barrier = std::make_shared< SDLPP::RectangleRender >(
|
||||||
LEFT_BORDER - 0.02, 0, 0.02, BOTTOM_BORDER, r, "#AA0000", true );
|
LEFT_BORDER - 0.02, 0, 0.02, BOTTOM_BORDER, r, colors["barrier"], true );
|
||||||
left_barrier->centerX();
|
left_barrier->centerX();
|
||||||
left_barrier->setStatic();
|
left_barrier->setStatic();
|
||||||
scene.addObject( left_barrier );
|
scene.addObject( left_barrier );
|
||||||
auto right_barrier = std::make_shared< SDLPP::RectangleRender >(
|
auto right_barrier = std::make_shared< SDLPP::RectangleRender >(
|
||||||
RIGHT_BORDER, 0, 0.02, BOTTOM_BORDER, r, "#AA0000", true );
|
RIGHT_BORDER, 0, 0.02, BOTTOM_BORDER, r, colors["barrier"], true );
|
||||||
right_barrier->centerX();
|
right_barrier->centerX();
|
||||||
right_barrier->setStatic();
|
right_barrier->setStatic();
|
||||||
scene.addObject( right_barrier );
|
scene.addObject( right_barrier );
|
||||||
auto bottom_barrier = std::make_shared< SDLPP::RectangleRender >(
|
auto bottom_barrier = std::make_shared< SDLPP::RectangleRender >(
|
||||||
LEFT_BORDER - 0.02, BOTTOM_BORDER, RIGHT_BORDER - LEFT_BORDER + 0.04,
|
LEFT_BORDER - 0.02, BOTTOM_BORDER, RIGHT_BORDER - LEFT_BORDER + 0.04,
|
||||||
0.02, r, "#AA0000", true );
|
0.02, r, colors["barrier"], true );
|
||||||
bottom_barrier->centerX();
|
bottom_barrier->centerX();
|
||||||
bottom_barrier->setStatic();
|
bottom_barrier->setStatic();
|
||||||
scene.addObject( bottom_barrier );
|
scene.addObject( bottom_barrier );
|
||||||
auto tetris = std::make_shared< SDLPP::TextRenderer >(
|
auto tetris = std::make_shared< SDLPP::TextRenderer >(
|
||||||
0.4, 0, 0.2, 0.1, r, *font, "TETRIS", "FFFFFF", "000000", 5 );
|
0.4, 0, 0.2, 0.1, r, *font, "TETRIS", colors["text"], colors["text_out"], 5 );
|
||||||
tetris->centerX();
|
tetris->centerX();
|
||||||
tetris->setStatic();
|
tetris->setStatic();
|
||||||
scene.addObject( tetris );
|
scene.addObject( tetris );
|
||||||
auto next = std::make_shared< SDLPP::TextRenderer >(
|
auto next = std::make_shared< SDLPP::TextRenderer >(
|
||||||
RIGHT_BORDER + 0.1, 0.35, 0.2, 0.1, r, *font, "NEXT", "FFFFFF",
|
RIGHT_BORDER + 0.1, 0.35, 0.2, 0.1, r, *font, "NEXT", colors["text"], colors["text_out"], 5, SDLPP_TEXT_CENTER );
|
||||||
"000000", 5, SDLPP_TEXT_CENTER );
|
|
||||||
next->centerX();
|
next->centerX();
|
||||||
next->setStatic();
|
next->setStatic();
|
||||||
scene.addObject( next );
|
scene.addObject( next );
|
||||||
@ -552,15 +554,14 @@ void addStuff( SDLPP::Scene &scene, std::shared_ptr< SDLPP::Renderer > &r ) {
|
|||||||
gameover->setStatic();
|
gameover->setStatic();
|
||||||
scene.addObject( gameover );
|
scene.addObject( gameover );
|
||||||
auto score_text = std::make_shared< SDLPP::TextRenderer >(
|
auto score_text = std::make_shared< SDLPP::TextRenderer >(
|
||||||
RIGHT_BORDER + 0.1, 0.1, 0.2, 0.1, r, *font, "SCORE", "#FFFFFF",
|
RIGHT_BORDER + 0.1, 0.1, 0.2, 0.1, r, *font, "SCORE", colors["text"], colors["text_out"], 5, SDLPP_TEXT_CENTER );
|
||||||
"#000000", 5, SDLPP_TEXT_CENTER );
|
|
||||||
score_text->centerX();
|
score_text->centerX();
|
||||||
score_text->setStatic();
|
score_text->setStatic();
|
||||||
scene.addObject( score_text );
|
scene.addObject( score_text );
|
||||||
|
|
||||||
score_texture = std::make_shared< SDLPP::TextRenderer >(
|
score_texture = std::make_shared< SDLPP::TextRenderer >(
|
||||||
RIGHT_BORDER + 0.1, 0.2, 0.2, 0.1, r, *font, std::to_string( score ),
|
RIGHT_BORDER + 0.1, 0.2, 0.2, 0.1, r, *font, std::to_string( score ),
|
||||||
"FFFFFF", "000000", 5, SDLPP_TEXT_TOP );
|
colors["text"], colors["text_out"], 5, SDLPP_TEXT_TOP );
|
||||||
score_texture->centerX();
|
score_texture->centerX();
|
||||||
score_texture->setStatic();
|
score_texture->setStatic();
|
||||||
scene.addObject( score_texture );
|
scene.addObject( score_texture );
|
||||||
@ -599,37 +600,36 @@ void addStuff( SDLPP::Scene &scene, std::shared_ptr< SDLPP::Renderer > &r ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void updateScore() {
|
void updateScore() {
|
||||||
score_texture->setText( *font, std::to_string( score ), "#FFFFFF",
|
score_texture->setText( *font, std::to_string( score ), colors["text"], colors["text_out"], 5 );
|
||||||
"#000000", 5 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void addPause( SDLPP::Scene &scene, std::shared_ptr< SDLPP::Renderer > &r ) {
|
void addPause( SDLPP::Scene &scene, std::shared_ptr< SDLPP::Renderer > &r ) {
|
||||||
auto bg = std::make_shared< SDLPP::RectangleRender >( 0, 0, 10, 10, r,
|
auto bg = std::make_shared< SDLPP::RectangleRender >( 0, 0, 10, 10, r,
|
||||||
"#00000080", true );
|
colors["menu_background"], true );
|
||||||
bg->setId( 123 );
|
bg->setId( 123 );
|
||||||
bg->setPermanent( true );
|
bg->setPermanent( true );
|
||||||
scene.addObject( bg );
|
scene.addObject( bg );
|
||||||
auto y = std::make_shared< SDLPP::TextRenderer >( 0.25, 0.1, 0.5, 0.3, r );
|
auto y = std::make_shared< SDLPP::TextRenderer >( 0.25, 0.1, 0.5, 0.3, r );
|
||||||
y->setText( *font, "PAUSED", "#FFFFFF", "#000000", 5 );
|
y->setText( *font, "PAUSED", colors["text"], colors["text_out"], 5 );
|
||||||
y->setId( 0 );
|
y->setId( 0 );
|
||||||
y->centerX();
|
y->centerX();
|
||||||
scene.addObject( y );
|
scene.addObject( y );
|
||||||
auto resume =
|
auto resume =
|
||||||
std::make_shared< SDLPP::TextRenderer >( 0.4, 0.51, 0.2, 0.08, r );
|
std::make_shared< SDLPP::TextRenderer >( 0.4, 0.51, 0.2, 0.08, r );
|
||||||
resume->setText( *font, "Resume", "#FFFFFF", "#000000", 5 );
|
resume->setText( *font, "Resume", colors["text"], colors["text_out"], 5 );
|
||||||
resume->setColor( "#FFFFFF40" );
|
resume->setColor( colors["menu_item_background"] );
|
||||||
resume->centerX();
|
resume->centerX();
|
||||||
scene.addObject( resume );
|
scene.addObject( resume );
|
||||||
pause_options.push_back( resume );
|
pause_options.push_back( resume );
|
||||||
auto restart =
|
auto restart =
|
||||||
std::make_shared< SDLPP::TextRenderer >( 0.4, 0.61, 0.2, 0.08, r );
|
std::make_shared< SDLPP::TextRenderer >( 0.4, 0.61, 0.2, 0.08, r );
|
||||||
restart->setText( *font, "Restart", "#FFFFFF", "#000000", 5 );
|
restart->setText( *font, "Restart", colors["text"], colors["text_out"], 5 );
|
||||||
restart->centerX();
|
restart->centerX();
|
||||||
scene.addObject( restart );
|
scene.addObject( restart );
|
||||||
pause_options.push_back( restart );
|
pause_options.push_back( restart );
|
||||||
auto quit =
|
auto quit =
|
||||||
std::make_shared< SDLPP::TextRenderer >( 0.4, 0.71, 0.2, 0.08, r );
|
std::make_shared< SDLPP::TextRenderer >( 0.4, 0.71, 0.2, 0.08, r );
|
||||||
quit->setText( *font, "Quit Game", "#FFFFFF", "#000000", 5 );
|
quit->setText( *font, "Quit Game", colors["text"], colors["text_out"], 5 );
|
||||||
quit->centerX();
|
quit->centerX();
|
||||||
scene.addObject( quit );
|
scene.addObject( quit );
|
||||||
pause_options.push_back( quit );
|
pause_options.push_back( quit );
|
||||||
@ -637,25 +637,25 @@ void addPause( SDLPP::Scene &scene, std::shared_ptr< SDLPP::Renderer > &r ) {
|
|||||||
|
|
||||||
void addGameOver( SDLPP::Scene &scene, std::shared_ptr< SDLPP::Renderer > &r ) {
|
void addGameOver( SDLPP::Scene &scene, std::shared_ptr< SDLPP::Renderer > &r ) {
|
||||||
auto bg = std::make_shared< SDLPP::RectangleRender >( 0, 0, 10, 10, r,
|
auto bg = std::make_shared< SDLPP::RectangleRender >( 0, 0, 10, 10, r,
|
||||||
"#00000080", true );
|
colors["menu_background"], true );
|
||||||
bg->setId( 123 );
|
bg->setId( 123 );
|
||||||
bg->setPermanent( true );
|
bg->setPermanent( true );
|
||||||
scene.addObject( bg );
|
scene.addObject( bg );
|
||||||
auto y = std::make_shared< SDLPP::TextRenderer >( 0.25, 0.1, 0.5, 0.3, r );
|
auto y = std::make_shared< SDLPP::TextRenderer >( 0.25, 0.1, 0.5, 0.3, r );
|
||||||
y->setText( *font, "GAME OVER", "#FFFFFF", "#000000", 5 );
|
y->setText( *font, "GAME OVER", colors["text"], colors["text_out"], 5 );
|
||||||
y->setId( 0 );
|
y->setId( 0 );
|
||||||
y->centerX();
|
y->centerX();
|
||||||
scene.addObject( y );
|
scene.addObject( y );
|
||||||
auto restart =
|
auto restart =
|
||||||
std::make_shared< SDLPP::TextRenderer >( 0.4, 0.5, 0.2, 0.1, r );
|
std::make_shared< SDLPP::TextRenderer >( 0.4, 0.5, 0.2, 0.1, r );
|
||||||
restart->setText( *font, "Restart", "#FFFFFF", "#000000", 5 );
|
restart->setText( *font, "Restart", colors["text"], colors["text_out"], 5 );
|
||||||
restart->centerX();
|
restart->centerX();
|
||||||
restart->setColor( "#FFFFFF40" );
|
restart->setColor( colors["menu_item_background"] );
|
||||||
scene.addObject( restart );
|
scene.addObject( restart );
|
||||||
game_over_options.push_back( restart );
|
game_over_options.push_back( restart );
|
||||||
auto quit =
|
auto quit =
|
||||||
std::make_shared< SDLPP::TextRenderer >( 0.4, 0.7, 0.2, 0.1, r );
|
std::make_shared< SDLPP::TextRenderer >( 0.4, 0.7, 0.2, 0.1, r );
|
||||||
quit->setText( *font, "Quit Game", "#FFFFFF", "#000000", 5 );
|
quit->setText( *font, "Quit Game", colors["text"], colors["text_out"], 5 );
|
||||||
quit->centerX();
|
quit->centerX();
|
||||||
scene.addObject( quit );
|
scene.addObject( quit );
|
||||||
game_over_options.push_back( quit );
|
game_over_options.push_back( quit );
|
||||||
@ -884,7 +884,7 @@ void handleKeyDownPause( SDL_Keycode key ) {
|
|||||||
pause_select++;
|
pause_select++;
|
||||||
if ( pause_select > pause_max )
|
if ( pause_select > pause_max )
|
||||||
pause_select = 0;
|
pause_select = 0;
|
||||||
pause_options[pause_select]->setColor( "FFFFFF40" );
|
pause_options[pause_select]->setColor( colors["menu_item_background"] );
|
||||||
break;
|
break;
|
||||||
case SDLK_w:
|
case SDLK_w:
|
||||||
case SDLK_UP:
|
case SDLK_UP:
|
||||||
@ -892,7 +892,7 @@ void handleKeyDownPause( SDL_Keycode key ) {
|
|||||||
pause_select--;
|
pause_select--;
|
||||||
if ( pause_select < 0 )
|
if ( pause_select < 0 )
|
||||||
pause_select = pause_max;
|
pause_select = pause_max;
|
||||||
pause_options[pause_select]->setColor( "FFFFFF40" );
|
pause_options[pause_select]->setColor( colors["menu_item_background"] );
|
||||||
break;
|
break;
|
||||||
case SDLK_RETURN:
|
case SDLK_RETURN:
|
||||||
switch ( pause_select ) {
|
switch ( pause_select ) {
|
||||||
@ -942,7 +942,7 @@ void handleKeyDownGameOver( SDL_Keycode key ) {
|
|||||||
game_over_select++;
|
game_over_select++;
|
||||||
if ( game_over_select > game_over_max )
|
if ( game_over_select > game_over_max )
|
||||||
game_over_select = 0;
|
game_over_select = 0;
|
||||||
game_over_options[game_over_select]->setColor( "FFFFFF40" );
|
game_over_options[game_over_select]->setColor( colors["menu_item_background"] );
|
||||||
break;
|
break;
|
||||||
case SDLK_w:
|
case SDLK_w:
|
||||||
case SDLK_UP:
|
case SDLK_UP:
|
||||||
@ -950,7 +950,7 @@ void handleKeyDownGameOver( SDL_Keycode key ) {
|
|||||||
game_over_select--;
|
game_over_select--;
|
||||||
if ( game_over_select < 0 )
|
if ( game_over_select < 0 )
|
||||||
game_over_select = game_over_max;
|
game_over_select = game_over_max;
|
||||||
game_over_options[game_over_select]->setColor( "FFFFFF40" );
|
game_over_options[game_over_select]->setColor( colors["menu_item_background"] );
|
||||||
break;
|
break;
|
||||||
case SDLK_RETURN:
|
case SDLK_RETURN:
|
||||||
switch ( game_over_select ) {
|
switch ( game_over_select ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user