summaryrefslogtreecommitdiffstats
path: root/Game.cpp
diff options
context:
space:
mode:
authormario <mario@notk.org>2011-11-29 14:34:01 +0100
committermario <mario@notk.org>2011-11-29 14:34:01 +0100
commitc82f2bfa593614f266bd67bc979f5ecbc5349774 (patch)
tree57f6bc8147acee45fc8f61305710fa9feaade6aa /Game.cpp
parentea176fc6edd05eccfd79ddb7ce6a83c38b601e29 (diff)
parentf6e512372eae12830050e9f0dcdd64cf7a322fac (diff)
Fixed warnngs (implicit casts and float/double conversion
Diffstat (limited to 'Game.cpp')
-rw-r--r--Game.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/Game.cpp b/Game.cpp
index 6ad4e02..bcd2ebe 100644
--- a/Game.cpp
+++ b/Game.cpp
@@ -1,14 +1,18 @@
+#include <stdio.h>
#include "Game.h"
#include "AIController.h"
+#define _USE_MATH_DEFINES
+#include <math.h>
+
Game::Game(int width, int height, PlayerNumber num):
m_Field(width, height)
{
- m_vPlayers.clear(); // is it possible to resize it without trying to fill it? (i.e. fill with null pointers)
+ m_vPlayers.resize(num); // is it possible to resize it without trying to fill it? (i.e. fill with null pointers)
for(PlayerNumber i = 0; i<num; ++i)
{
- int x = (int)(width * (0.5 + 0.3*cosf(2*M_PI*(float)i/num+M_PI)));
- int y = (int)(height * (0.5 + 0.3*sinf(2*M_PI*(float)i/num+M_PI)));
+ int x = (int)(width * (0.5f + 0.3f*cosf(2.f*M_PI*(float)i/num+M_PI)));
+ int y = (int)(height * (0.5f + 0.3f*sinf(2.f*M_PI*(float)i/num+M_PI)));
VelocityVector velocity;
if (abs(x-width/2) >= abs(y-height/2)) {
@@ -24,8 +28,11 @@ Game::Game(int width, int height, PlayerNumber num):
velocity = VelocityVector(0,1);
}
}
-
- m_vPlayers.push_back(Player(i, Coordinates(x,y), velocity));
+
+ m_vPlayers[i].setCoordinates(Coordinates(x,y));
+ m_vPlayers[i].setVelocityVector(velocity);
+ m_vPlayers[i].setNumber(i);
+ m_vPlayers[i].revive();
m_Field.getCell(Coordinates(x,y)).setState(PLAYER);
m_Field.getCell(Coordinates(x,y)).setPlayer(&m_vPlayers[i]);
@@ -73,7 +80,7 @@ void Game::updateGame(uint timeElapsedMs) {
// ask the AI if they wanna change something?
for(std::vector<Player>::iterator player = m_vPlayers.begin(); player != m_vPlayers.end(); ++player) {
if (player->getController()) {
- player->getController()->think();
+ player->getController()->think();
}
}