Made some adjustments to the game's ranging

This commit is contained in:
Anna Rose 2011-06-28 22:27:33 -04:00
parent 8550b0f8f1
commit d2322a7caf
4 changed files with 8 additions and 6 deletions

View File

@ -4,7 +4,7 @@
#include "debug.h" #include "debug.h"
#include <SDL.h> #include <SDL.h>
int Game::NODE_RADIUS = 12; int Game::NODE_RADIUS = 10;
Game::Game(SDL_Surface* display) Game::Game(SDL_Surface* display)

2
game.h
View File

@ -38,8 +38,6 @@ class Game : public GameState
GameData data; GameData data;
static int NODE_RADIUS; static int NODE_RADIUS;
static int MAX_MOVE_DISTANCE;
// surfaces containing textures to draw // surfaces containing textures to draw
SDL_Surface* background; SDL_Surface* background;

View File

@ -10,6 +10,8 @@ using std::list;
int GameData::PLAYER1_COLOUR = 0x4a483f; int GameData::PLAYER1_COLOUR = 0x4a483f;
int GameData::PLAYER2_COLOUR = 0x090c7a; int GameData::PLAYER2_COLOUR = 0x090c7a;
int GameData::BASE_MOVE_RADIUS = 75;
GameData::GameData() GameData::GameData()
: Graph(true) : Graph(true)
{ {
@ -180,17 +182,17 @@ int GameData::get_range(Vertex* node)
if (node == NULL) node = current; if (node == NULL) node = current;
if (node == NULL) return 0; if (node == NULL) return 0;
else if (mode == MODE_MOVE) return 100; else if (mode == MODE_MOVE) return BASE_MOVE_RADIUS;
else if (mode == MODE_ATTACK) else if (mode == MODE_ATTACK)
{ {
int range = 200; int range = BASE_MOVE_RADIUS;
list<Vertex*> neighbors = node->neighbors; list<Vertex*> neighbors = node->neighbors;
for(list<Vertex*>::iterator cursor = neighbors.begin(); for(list<Vertex*>::iterator cursor = neighbors.begin();
cursor != neighbors.end(); cursor++) cursor != neighbors.end(); cursor++)
{ {
Vertex* v = *cursor; Vertex* v = *cursor;
range -= 100 - MathUtils::distance(v->x, v->y, node->x, node->y); range -= (100 - MathUtils::distance(v->x, v->y, node->x, node->y)) / 2;
} }
if (range < 0) range = 0; if (range < 0) range = 0;
return range; return range;

View File

@ -52,6 +52,8 @@ class GameData : public Graph
static int PLAYER1_COLOUR; static int PLAYER1_COLOUR;
static int PLAYER2_COLOUR; static int PLAYER2_COLOUR;
static int BASE_MOVE_RADIUS;
}; };
#endif #endif