Improvements to button menu and keyboard controls
This commit is contained in:
parent
67cbd43740
commit
7d1ceb396b
50
game.cpp
50
game.cpp
|
@ -61,18 +61,19 @@ bool Game::init()
|
|||
int col5 = 575;
|
||||
int col6 = 680;
|
||||
|
||||
buttons.push_back(new MenuButton("Move", font, col1, row1, BUTTON_MOVE));
|
||||
buttons.push_back(new MenuButton("Build", font, col1, row2,
|
||||
buttons.push_back(new MenuButton("Move (m)", font, col1, row1,
|
||||
BUTTON_MOVE));
|
||||
buttons.push_back(new MenuButton("Build (b)", font, col1, row2,
|
||||
BUTTON_BUILD));
|
||||
buttons.push_back(new MenuButton("Attack", font, col2, row1,
|
||||
buttons.push_back(new MenuButton("Attack (a)", font, col2, row1,
|
||||
BUTTON_ATTACK));
|
||||
buttons.push_back(new MenuButton("Attacker", font, col3, row1,
|
||||
buttons.push_back(new MenuButton("Attacker (t)", font, col3, row1,
|
||||
BUTTON_BUILD_ATTACKER));
|
||||
buttons.push_back(new MenuButton("Defender", font, col3, row2,
|
||||
buttons.push_back(new MenuButton("Defender (d)", font, col3, row2,
|
||||
BUTTON_BUILD_DEFENDER));
|
||||
buttons.push_back(new MenuButton("Producer", font, col4, row1,
|
||||
buttons.push_back(new MenuButton("Producer (p)", font, col4, row1,
|
||||
BUTTON_BUILD_PRODUCER));
|
||||
buttons.push_back(new MenuButton("End Turn", font, col6, row2,
|
||||
buttons.push_back(new MenuButton("End Turn (e)", font, col6, row2,
|
||||
BUTTON_END_TURN));
|
||||
|
||||
|
||||
|
@ -202,24 +203,24 @@ void Game::draw_button(MenuButton* button)
|
|||
|
||||
void Game::draw_node(GameVertex* v)
|
||||
{
|
||||
DrawUtils::draw_circle_filled(display, v->x, v->y, v->r,
|
||||
v->colour);
|
||||
DrawUtils::draw_circle_filled(display, v->x, v->y, v->r,
|
||||
v->colour);
|
||||
|
||||
DrawUtils::draw_text(display, itos(v->score), v->x, v->y, font,
|
||||
0x00ff00, true, true);
|
||||
DrawUtils::draw_text(display, itos(v->score), v->x, v->y, font,
|
||||
0x00ff00, true, true);
|
||||
|
||||
switch (v->type)
|
||||
{
|
||||
case VERTEX_ATTACKER:
|
||||
DrawUtils::draw(display, attacker_icon, v->x + 5, v-> y + 5);
|
||||
break;
|
||||
case VERTEX_DEFENDER:
|
||||
DrawUtils::draw(display, defender_icon, v->x + 5, v-> y + 5);
|
||||
break;
|
||||
case VERTEX_PRODUCER:
|
||||
DrawUtils::draw(display, producer_icon, v->x + 5, v-> y + 5);
|
||||
break;
|
||||
}
|
||||
switch (v->type)
|
||||
{
|
||||
case VERTEX_ATTACKER:
|
||||
DrawUtils::draw(display, attacker_icon, v->x + 5, v-> y + 5);
|
||||
break;
|
||||
case VERTEX_DEFENDER:
|
||||
DrawUtils::draw(display, defender_icon, v->x + 5, v-> y + 5);
|
||||
break;
|
||||
case VERTEX_PRODUCER:
|
||||
DrawUtils::draw(display, producer_icon, v->x + 5, v-> y + 5);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -348,6 +349,9 @@ void Game::on_key_down(SDLKey sym, SDLMod mod, Uint16 unicode)
|
|||
else if (sym == SDLK_a) data.set_mode(MODE_ATTACK);
|
||||
else if (sym == SDLK_m) data.set_mode(MODE_MOVE);
|
||||
else if (sym == SDLK_b) data.set_mode(MODE_BUILD);
|
||||
else if (sym == SDLK_d) data.set_build_type(VERTEX_DEFENDER);
|
||||
else if (sym == SDLK_p) data.set_build_type(VERTEX_PRODUCER);
|
||||
else if (sym == SDLK_t) data.set_build_type(VERTEX_ATTACKER);
|
||||
else if (sym == SDLK_s || sym == SDLK_ESCAPE) data.set_mode(MODE_SELECT);
|
||||
else if (sym == SDLK_e) data.toggle_turn();
|
||||
|
||||
|
|
|
@ -23,13 +23,13 @@ void MenuButton::set_hover(bool is_hovering)
|
|||
|
||||
void MenuButton::draw(SDL_Surface* display, int colour, int background_colour)
|
||||
{
|
||||
SDL_Rect pen = {x, y, 100, 40};
|
||||
SDL_Rect pen = {x, y, 80, 20};
|
||||
|
||||
SDL_FillRect(display, &pen, background_colour);
|
||||
|
||||
int temp_colour = 0x000000;
|
||||
|
||||
DrawUtils::draw_text(display, text, x + 50, y + 20, font, colour, 1, 1);
|
||||
DrawUtils::draw_text(display, text, x + 40, y + 10, font, colour, 1, 1);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user