diff --git a/Hearts/Hearts.vcproj b/Hearts/Hearts.vcproj
index 97182a8..8c729ea 100644
--- a/Hearts/Hearts.vcproj
+++ b/Hearts/Hearts.vcproj
@@ -167,127 +167,145 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Hearts/animation.cpp b/Hearts/animation.cpp
deleted file mode 100644
index 0294a64..0000000
--- a/Hearts/animation.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/* File Name: animation.cpp
- * Copyright: (c) Kayne Ruse, all rights reserved.
- * Author: Kayne Ruse
- * Date: 9/7/2011
- * Version: 1, Stable
- * Description: The Animation class, animates spritesheets.
- * Part of the KAGE Game Engine.
-*/
-#include "animation.h"
-using namespace KAGE;
-
-//-------------------------
-//Public access members
-//-------------------------
-
-Animation::Animation(int _stateCount, int _frameCount, float _speed) {
- stateCount = _stateCount;
- frameCount = _frameCount;
- state = 0;
- frame = 0;
- speed = _speed;
-}
-
-void Animation::Process(int delta) {
- frame += delta * speed + speed;
-
- if (frame >= frameCount)
- frame = 0;
-
- SetCell();
-}
-
-//-------------------------
-//Accessors and mutators
-//-------------------------
-
-int Animation::SetStateCount(int _stateCount) {
- frame = 0;
- return stateCount = _stateCount;
-}
-
-int Animation::SetFrameCount(int _frameCount) {
- frame = 0;
- return frameCount = _frameCount;
-}
-
-int Animation::SetState(int _state) {
- if (_state >= stateCount)
- return -1;
-
- frame = 0;
- return state = _state;
-}
-
-float Animation::SetFrame(float _frame) {
- if (_frame >= frameCount)
- return -1;
-
- return frame = _frame;
-}
-
-float Animation::SetSpeed(float _speed) {
- frame = 0;
- return speed = _speed;
-}
-
-int Animation::GetStateCount() {
- return stateCount;
-}
-
-int Animation::GetFrameCount() {
- return frameCount;
-}
-
-int Animation::GetState() {
- return state;
-}
-
-float Animation::GetFrame() {
- return frame;
-}
-
-float Animation::GetSpeed() {
- return speed;
-}
diff --git a/Hearts/animation.h b/Hearts/animation.h
deleted file mode 100644
index a1e3418..0000000
--- a/Hearts/animation.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* File Name: animation.h
- * Copyright: (c) Kayne Ruse, all rights reserved.
- * Author: Kayne Ruse
- * Date: 9/7/2011
- * Version: 1, Stable
- * Description: The Animation class, animates spritesheets.
- * Part of the KAGE Game Engine.
-*/
-#ifndef KR_KAGE_ANIMATION_H_
-#define KR_KAGE_ANIMATION_H_
-
-/* Version information */
-#define ANIMATION_VERSION_MAJOR 1
-#define ANIMATION_VERSION_MINOR 0
-#define ANIMATION_VERSION_PATCH 0
-#define ANIMATION_VERSION "1.0.0"
-#define ANIMATION_VERSION_STRING "KAGE::Animation Version 1.0.0, Stable"
-
-namespace KAGE {
- class Animation {
- public:
- /* Public access members */
- Animation(int stateCount, int frameCount, float speed = 0);
-
- virtual void Process(int delta);
-
- /* Accessors and mutators */
- virtual int SetStateCount (int stateCount);
- virtual int SetFrameCount (int frameCount);
-
- virtual int SetState (int state);
- virtual float SetFrame (float frame);
- virtual float SetSpeed (float speed);
-
- virtual int GetStateCount ();
- virtual int GetFrameCount ();
-
- virtual int GetState ();
- virtual float GetFrame ();
- virtual float GetSpeed ();
- protected:
- /* Protected access members */
- virtual void SetCell()=0;
- private:
- /* Private access members */
- int stateCount;
- int frameCount;
-
- int state;
- float frame;
- float speed;
- };
-}
-
-#endif
diff --git a/Hearts/card.h b/Hearts/card.h
index 2dd3a0e..ad492cf 100644
--- a/Hearts/card.h
+++ b/Hearts/card.h
@@ -62,8 +62,8 @@ protected:
const int suit;
const int rank;
- int face;
- SDL_Surface* faceSurface;
+ int face; //TODO: "facestate"
+ SDL_Surface* faceSurface; //TODO: Image
SDL_Surface* backSurface;
Card* next;
diff --git a/Hearts/card_list.cpp b/Hearts/card_list.cpp
index 518ee36..465c46c 100644
--- a/Hearts/card_list.cpp
+++ b/Hearts/card_list.cpp
@@ -140,7 +140,7 @@ Card* CardList::PassSlab(int first, int count) {
void CardList::Shuffle() {
//New version
- srand((unsigned int)time(NULL));
+ srand((unsigned int)time(NULL)); //TODO: Remove this, initiate randomization in the Scene (and shuffle 3 times ;) )
iterator shuffleHead = NULL;
iterator prev = NULL;
diff --git a/Hearts/hearts_engine.h b/Hearts/hearts_engine.h
index 723d337..683a844 100644
--- a/Hearts/hearts_engine.h
+++ b/Hearts/hearts_engine.h
@@ -45,14 +45,14 @@ private:
KAGE::ImageManager mImage;
KAGE::AudioManager mAudio;
- /* Game phase members */
+ /* Game phase members */ //TODO: "phases"
void SetupPhase();
void SwapPhase();
void TrickPhase();
void ScorePhase();
void CleanupPhase();
- /* Play phase members */
+ /* Play phase members */ //TODO: "steps"
void PlayBeforePhase();
void PlayPlayerPhase();
void PlayAfterPhase();
diff --git a/Hearts/network_manager.cpp b/Hearts/network_manager.cpp
deleted file mode 100644
index 15fb18b..0000000
--- a/Hearts/network_manager.cpp
+++ /dev/null
@@ -1,155 +0,0 @@
-/* File Name: network_manager.cpp
- * Copyright: (c) Kayne Ruse, all rights reserved.
- * Author: Kayne Ruse
- * Date: 21/6/2011
- * Version: 3, Stable
- * Description: The Network Manager deals with the networking for your game.
- * Part of the KAGE Game Engine.
-*/
-#include
-#include "network_manager.h"
-using namespace std;
-using namespace KAGE;
-
-//-------------------------
-//Public access members
-//-------------------------
-
-NetworkManager::~NetworkManager() {
- SDLNet_FreePacket(packet);
- SDLNet_Quit();
-}
-
-int NetworkManager::Init(int port, int packetSize) {
- if (SDLNet_Init() != 0) {
- cout << "Error in NetworkManager::Init()" << endl;
- cout << "Failed to initialise SDL_net" << endl;
- return -1;
- }
-
- packet = SDLNet_AllocPacket(packetSize);
- if (packet == NULL) {
- cout << "Error in NetworkManager::Init()" << endl;
- cout << "SDLNet_AllocPacket() returned NULL" << endl;
- cout << "packetSize: " << packetSize << endl;
- return -1;
- }
-
- socket = SDLNet_UDP_Open(port);
- if (socket == NULL) {
- cout << "Error in NetworkManager::Init()" << endl;
- cout << "SDLNet_UDP_Open() returned NULL" << endl;
- cout << "port: " << port << endl;
- return -1;
- }
-
- return 0;
-}
-
-IPaddress* NetworkManager::Add(const char* name, char* ip, int port) {
- if (Exists(name)) {
- cout << "Error in NetworkManager::Add()" << endl;
- cout << "An IPaddress of that name already exists" << endl;
- cout << "name: " << name << endl;
- cout << "ip: " << ip << endl;
- cout << "port: " << port << endl;
- return NULL;
- }
-
- IPaddress* add = new IPaddress;
-
- if (SDLNet_ResolveHost(add,ip,port) != 0) {
- cout << "Error in NetworkManager::Add(name,ip,port)" << endl;
- cout << "Failed to resolve an IPaddress" << endl;
- cout << "name: " << name << endl;
- cout << "ip: " << ip << endl;
- cout << "port: " << port << endl;
- delete add;
- return NULL;
- }
-
- return NamedManager::Add(name,add);
-}
-
-IPaddress* NetworkManager::Add(const char* name, IPaddress* address) {
- if (Exists(name)) {
- cout << "Error in NetworkManager::Add()" << endl;
- cout << "An IPaddress of that name already exists" << endl;
- cout << "name: " << name << endl;
- return NULL;
- }
-
- return NamedManager::Add(name,address);
-}
-
-//-------------------------
-//Network members
-//-------------------------
-int NetworkManager::Send(const char* name, const char* data) {
- IPaddress* add = Get(name);
- if (add == NULL) {
- cout << "Error in NetworkManager::Send(name,data)" << endl;
- cout << "No such IPaddress with that name" << endl;
- cout << "name: " << name << endl;
- return -2;
- }
-
- return Send(add,data);
-}
-
-int NetworkManager::Send(IPaddress* address, const char* data) {
- //send this data to the address
- strcpy_s((char*)packet->data,512,data);
- packet->address = *address;
-
- packet->len = strlen((char*)packet->data) + 1;
- SDLNet_UDP_Send(socket,-1,packet);
- return 0;
-}
-
-int NetworkManager::Send(char* ip, int port, const char* data) {
- IPaddress* add = new IPaddress;
-
- if (SDLNet_ResolveHost(add,ip,port) != 0) {
- cout << "Error in NetworkManager::Send(ip,port,data)" << endl;
- cout << "Failed to resolve an IPaddress" << endl;
- cout << "ip: " << ip << endl;
- cout << "port: " << port << endl;
- cout << "data: " << data << endl;
- delete add;
- return -1;
- }
-
- int ret = Send(add,data);
- delete add;
- return ret;
-}
-
-void NetworkManager::SendAll(const char* data) {
- for (MapType::iterator it = mapList.begin(); it != mapList.end(); it++)
- Send(it->second,data);
-}
-
-int NetworkManager::Receive() {
- return SDLNet_UDP_Recv(socket, packet);
-}
-
-//-------------------------
-//Accessors and mutators
-//-------------------------
-
-const char* NetworkManager::Data() {
- return (char*)packet->data;
-}
-
-bool NetworkManager::CheckData(const char* str) {
- return !strcmp((char*)packet->data,str);
-}
-
-bool NetworkManager::CheckData(const char* str, int num) {
- return !strncmp((char*)packet->data,str,num);
-}
-
-UDPpacket* NetworkManager::Packet() {
- return packet;
-}
diff --git a/Hearts/network_manager.h b/Hearts/network_manager.h
deleted file mode 100644
index b2d066e..0000000
--- a/Hearts/network_manager.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* File Name: network_manager.h
- * Copyright: (c) Kayne Ruse, all rights reserved.
- * Author: Kayne Ruse
- * Date: 21/6/2011
- * Version: 3, Stable
- * Description: The Network Manager deals with the networking for your game.
- * Part of the KAGE Game Engine.
-*/
-#ifndef KR_KAGE_NETWORKMANAGER_H_
-#define KR_KAGE_NETWORKMANAGER_H_
-
-/* Version information */
-#define NETWORKMANAGER_VERSION_MAJOR 3
-#define NETWORKMANAGER_VERSION_MINOR 0
-#define NETWORKMANAGER_VERSION_PATCH 0
-#define NETWORKMANAGER_VERSION "3.0.0"
-#define NETWORKMANAGER_VERSION_STRING "KAGE::NetworkManager Version 3, Stable"
-
-#include "SDL_net.h"
-#include "named_manager.h"
-
-namespace KAGE {
- class NetworkManager : public NamedManager {
- public:
- /* Public access members */
- ~NetworkManager();
-
- int Init(int port, int packetSize = 512);
-
- IPaddress* Add(const char* name, char* ip, int port);
- IPaddress* Add(const char* name, IPaddress* address);
-
- /* Network members */
- int Send(const char* name, const char* data);
- int Send(IPaddress* address, const char* data);
- int Send(char* ip, int port, const char* data);
- void SendAll(const char* data);
- int Receive();
-
- /* Accessors and mutators */
- const char* Data();
- bool CheckData(const char* str);
- bool CheckData(const char* str, int num);
- UDPpacket* Packet();
-
- /* Private access members */
- UDPsocket socket;
- UDPpacket* packet;
- };
-}
-
-#endif
diff --git a/Hearts/object.cpp b/Hearts/object.cpp
deleted file mode 100644
index d654b5b..0000000
--- a/Hearts/object.cpp
+++ /dev/null
@@ -1,197 +0,0 @@
-/* File Name: object.cpp
- * Copyright: (c) Kayne Ruse, all rights reserved.
- * Author: Kayne Ruse
- * Date: 9/7/2011
- * Version: 4, Stable
- * Description: The Object class, with movement and collision functionality.
- * Part of the KAGE Game Engine.
-*/
-#include
-#include "object.h"
-using namespace std;
-using namespace KAGE;
-
-//-------------------------
-//Public access members
-//-------------------------
-
-Object::Object(float _realX, float _realY, int boxX, int boxY, int boxWidth, int boxHeight, float _radius) {
- realX = _realX;
- realY = _realY;
- motionX = 0;
- motionY = 0;
- boundingBox.x = boxX;
- boundingBox.y = boxY;
- boundingBox.w = boxWidth;
- boundingBox.h = boxHeight;
- radius = _radius;
-}
-
-void Object::Process(int delta) {
- realX += delta * motionX + motionX;
- realY += delta * motionY + motionY;
- UpdateClip();
-}
-
-//-------------------------
-//Accessors and mutators
-//-------------------------
-
-void Object::SetPosition(float _realX, float _realY) {
- realX = _realX;
- realY = _realY;
- UpdateClip();
-}
-
-void Object::ShiftPosition(float _realX, float _realY) {
- realX += _realX;
- realY += _realY;
- UpdateClip();
-}
-
-float Object::SetRealX(float _realX) {
- realX = _realX;
- UpdateClip();
- return realX;
-}
-
-float Object::SetRealY(float _realY) {
- realY = _realY;
- UpdateClip();
- return realY;
-}
-
-float Object::GetRealX() {
- return realX;
-}
-
-float Object::GetRealY() {
- return realY;
-}
-
-void Object::SetMotion(float _motionX, float _motionY) {
- motionX = _motionX;
- motionY = _motionY;
-}
-
-float Object::SetMotionX(float _motionX) {
- return motionX = _motionX;
-}
-
-float Object::SetMotionY(float _motionY) {
- return motionY = _motionY;
-}
-
-void Object::ShiftMotion(float _motionX, float _motionY) {
- motionX += _motionX;
- motionY += _motionY;
-}
-
-float Object::ShiftMotionX(float _motionX) {
- return motionX += _motionX;
-}
-
-float Object::ShiftMotionY(float _motionY) {
- return motionY += _motionY;
-}
-
-void Object::StopMotion() {
- motionX = 0;
- motionY = 0;
-}
-
-float Object::GetMotionX() {
- return motionX;
-}
-
-float Object::GetMotionY() {
- return motionY;
-}
-
-//-------------------------
-//Collision code
-//-------------------------
-
-SDL_Rect Object::SetBoundingBox(int x, int y, int w, int h) {
- boundingBox.x = x;
- boundingBox.y = y;
- boundingBox.w = w;
- boundingBox.h = h;
- return boundingBox;
-}
-
-SDL_Rect Object::SetBoundingBox(SDL_Rect _boundingBox) {
- return boundingBox = _boundingBox;
-}
-
-float Object::SetRadius(float _radius) {
- return radius = _radius;
-}
-
-SDL_Rect* Object::GetBoundingBox() {
- return &boundingBox;
-}
-
-SDL_Rect Object::GetWorldBoundingBox() {
- SDL_Rect ret = boundingBox;
- ret.x += (Sint16)realX;
- ret.y += (Sint16)realY;
- ret.w += (Uint16)realX;
- ret.h += (Uint16)realY;
- return ret;
-}
-
-float Object::GetRadius() {
- return radius;
-}
-
-bool Object::CheckWorldBoundingBox(SDL_Rect arg) {
- if (radius > 0) {
- cout << "Error in Object::CheckWorldBoundingBox()" << endl;
- cout << "Wrong collision type" << endl;
- cout << "radius: " << radius << endl;
- return false;
- }
-
- SDL_Rect box = GetWorldBoundingBox();
- if ((int)arg.x < (int)box.w &&
- (int)arg.w > (int)box.x &&
- (int)arg.y < (int)box.h &&
- (int)arg.h > (int)box.y)
- return true;
- return false;
-}
-
-inline float sqr(float f) {
- return f*f;
-}
-
-bool Object::CheckRadius(float _realX, float _realY, float _radius) {
- if (radius <= 0) {
- cout << "Error in Object::CheckRadius()" << endl;
- cout << "Wrong collision type" << endl;
- cout << "radius: " << radius << endl;
- return false;
- }
-
- if (sqr(radius + _radius) > sqr(realX - _realX) + sqr(realY - _realY))
- return true;
- return false;
-}
-
-bool Object::CheckPoint(float _realX, float _realY) {
- if (radius > 0) {
- cout << "Error in Object::CheckPoint()" << endl;
- cout << "Wrong collision type" << endl;
- cout << "radius: " << radius << endl;
- return false;
- }
-
- SDL_Rect box = GetWorldBoundingBox();
- if ((int)box.x < (int)_realX &&
- (int)box.y < (int)_realY &&
- (int)box.w > (int)_realX &&
- (int)box.h > (int)_realY)
- return true;
- return false;
-}
diff --git a/Hearts/object.h b/Hearts/object.h
deleted file mode 100644
index c8b8386..0000000
--- a/Hearts/object.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* File Name: object.h
- * Copyright: (c) Kayne Ruse, all rights reserved.
- * Author: Kayne Ruse
- * Date: 9/7/2011
- * Version: 4, Stable
- * Description: The Object class, with movement and collision functionality.
- * Part of the KAGE Game Engine.
-*/
-#ifndef KR_KAGE_OBJECT_H_
-#define KR_KAGE_OBJECT_H_
-
-/* Version information */
-#define OBJECT_VERSION_MAJOR 4
-#define OBJECT_VERSION_MINOR 0
-#define OBJECT_VERSION_PATCH 0
-#define OBJECT_VERSION "4.0.0"
-#define OBJECT_VERSION_STRING "KAGE::Object Version 4, Stable"
-
-#include "SDL.h"
-
-namespace KAGE {
- class Object {
- public:
- /* Public access members */
- Object(float realX = 0, float realY = 0, int boxX = 0, int boxY = 0, int boxWidth = 0, int boxHeight = 0, float radius = 0);
-
- virtual void Process(int delta);
-
- /* Accessors and mutators */
- virtual void SetPosition (float realX, float realY);
- virtual void ShiftPosition (float realX, float realY);
- virtual float SetRealX (float realX);
- virtual float SetRealY (float realY);
-
- virtual float GetRealX ();
- virtual float GetRealY ();
-
- virtual void SetMotion (float motionX, float motionY);
- virtual float SetMotionX (float motionX);
- virtual float SetMotionY (float motionY);
-
- virtual void ShiftMotion (float motionX, float motionY);
- virtual float ShiftMotionX (float motionX);
- virtual float ShiftMotionY (float motionY);
-
- virtual void StopMotion ();
-
- virtual float GetMotionX ();
- virtual float GetMotionY ();
-
- /* Collision code */
- virtual SDL_Rect SetBoundingBox (int x, int y, int w, int h);
- virtual SDL_Rect SetBoundingBox (SDL_Rect boundingBox);
- virtual float SetRadius (float radius);
-
- virtual SDL_Rect* GetBoundingBox ();
- virtual SDL_Rect GetWorldBoundingBox ();
- virtual float GetRadius ();
-
- virtual bool CheckWorldBoundingBox (SDL_Rect boundingBox);
- virtual bool CheckRadius (float realX, float realY, float radius = 0);
- virtual bool CheckPoint (float realX, float realY);
- protected:
- /* Protected access members */
- virtual void UpdateClip()=0;
- private:
- /* Private access members */
- float realX;
- float realY;
- float motionX;
- float motionY;
-
- SDL_Rect boundingBox;
- float radius;
- };
-}
-
-#endif
diff --git a/Hearts/player.cpp b/Hearts/player.cpp
index 5425e14..72d9031 100644
--- a/Hearts/player.cpp
+++ b/Hearts/player.cpp
@@ -120,6 +120,7 @@ void Player::SetHandPositions() {
}
void Player::SetTrickPositions() {
+ //Sorts out the cards won from tricks for display at the end of the round
int x = posX, y = posY;
tricks.Sort();
@@ -139,6 +140,7 @@ void Player::DrawHand(SDL_Surface* dest) {
}
void Player::DrawTricks(SDL_Surface* dest) {
+ //draws the cards won from tricks at the end of the round
tricks.Sort();
for (int i = 0; i < tricks.Size(); i++) {
@@ -153,6 +155,7 @@ void Player::DrawTricks(SDL_Surface* dest) {
//-------------------------
void Player::AddSwapCards(int card) {
+ //highlight a card
for (int i = 0; i < 3; i++) {
if (swapCards[i] == -1) {
swapCards[i] = card;
@@ -162,6 +165,7 @@ void Player::AddSwapCards(int card) {
}
bool Player::CheckSwapCards(int card) {
+ //if a card has been highlighted
for (int i = 0; i < 3; i++)
if (card == swapCards[i])
return true;
@@ -169,6 +173,7 @@ bool Player::CheckSwapCards(int card) {
}
bool Player::CheckSwapCards() {
+ //check if three cards have been highlighted
for (int i = 0; i < 3; i++)
if (swapCards[i] == -1)
return false;
diff --git a/Hearts/player.h b/Hearts/player.h
index 193e887..078ec5d 100644
--- a/Hearts/player.h
+++ b/Hearts/player.h
@@ -34,7 +34,7 @@ public:
CardList* Hand();
CardList* Tricks();
- /* Score members */
+ /* Score members */ //TODO: not good.
int Score(int score = 0);
int Wins(int wins = 0);
@@ -52,7 +52,7 @@ public:
bool CheckSwapCards();
protected:
- /* Swapping members */
+ /* Swapping members */ //TODO: raname to the "highlight" system
void AddSwapCards(int);
bool CheckSwapCards(int);
void RemoveSwapCards(int);
diff --git a/Hearts/player_ai.cpp b/Hearts/player_ai.cpp
index 5922f49..c0d73db 100644
--- a/Hearts/player_ai.cpp
+++ b/Hearts/player_ai.cpp
@@ -73,6 +73,10 @@ Card* PlayerAI::PassPlayFirstTrick(int leadingSuit) {
if (Hand()->Read(i)->Suit() == leadingSuit)
return Hand()->Pass(i);
+ /* bug: it's possible that if every penalty card is initially dealt the the AI, it'll break
+ * Solution: Always shuffle first.
+ */
+
//can't follow suit, no penalty cards
Hand()->SortRank();
Card* c = NULL;