Laid the groundwork for a more complex game - introduced a couple of bugs (can attack from anywhere, can't select another of your own vertices in attack mode...)

This commit is contained in:
2011-07-01 14:10:45 -04:00
parent d1c11799f4
commit 4daaced5d7
6 changed files with 138 additions and 64 deletions

View File

@ -5,8 +5,6 @@
#include "itos.h"
#include <SDL.h>
int Game::NODE_RADIUS = 10;
Game::Game(stack<GameState*>* state_stack, SDL_Surface* display)
: GameState(state_stack, display)
@ -54,9 +52,12 @@ void Game::render()
switch(data.get_mode())
{
case MODE_MOVE:
case MODE_BUILD:
range_colour = 0x0000ff;
break;
case MODE_MOVE:
range_colour = 0x00ff00;
break;
case MODE_ATTACK:
range_colour = 0xff0000;
break;
@ -68,7 +69,7 @@ void Game::render()
list<Vertex*> vertices = data.get_vertices();
// Now paint on the targeting circle
if (data.get_current_vertex() != NULL)
if (data.get_current_vertex(true) != NULL)
{
Vertex* v = data.get_current_vertex();
DrawUtils::draw_circle_filled(display, v->x, v->y, range,
@ -104,7 +105,7 @@ void Game::render()
void Game::on_lbutton_down(int x, int y)
{
data.do_vertex(x, y, NODE_RADIUS);
if (!data.endgame()) data.handle_click(x, y);
}
@ -119,4 +120,5 @@ void Game::on_key_down(SDLKey sym, SDLMod mod, Uint16 unicode)
if (sym == SDLK_q && mod & KMOD_CTRL) throw StateExit();
if (sym == SDLK_a) data.set_mode(MODE_ATTACK);
if (sym == SDLK_m) data.set_mode(MODE_MOVE);
if (sym == SDLK_b) data.set_mode(MODE_BUILD);
}