#include "Collision.h"
+#include <SDL/SDL_draw.h>
+
+void CollisionRectangle::draw(){
+ Draw_Rect(This->Screen(), pos.x, pos.y, width, height, color);
+}
+
+void CollisionCircle::draw(){
+ Draw_Circle(This->Screen(), pos.x, pos.y, radius, color);
+}
bool CollisionRectangle::collision(const Collision *c){
if(dynamic_cast<const CollisionRectangle*>(c)){
class Collision
{
public:
- Collision():pos(0.0,0.0){}
+ Collision():pos(0.0,0.0),color(0xFF00FF00){ }
Point2D pos;/**< The position of the center of the collision data */
virtual bool collision(const Collision *c) = 0; /**< Check collision with objects */
/// \todo See this http://www.metanetsoftware.com/technique/tutorialA.html
+ virtual void draw() = 0;/**< Draws the collision data to the screen */
protected:
string name;///< Name of this behavior \todo make this actually be useful
+ Uint32 color;///< The collision box color
};
/**
double width;/**< Rectangle's width */
double height;/**< Rectangle's height */
virtual bool collision(const Collision *c);/**< Check collision with objects */
+ virtual void draw();/**< Draws the collision data to the screen */
};
/**
double radius; /**< The raidus of the circle */
virtual bool collision(const Collision *c);/**< Check collision with objects */
bool collision(const CollisionRectangle*);/**< This does collision between Rectangles and Circles */
+ virtual void draw();/**< Draws the collision data to the screen */
};
#endif
/** Makes the game loop begin and load objects. */
void run();
+
+ /** Returns the main screen to allow for drawing */
+ SDL_Surface* Screen(){ return mScreen; }
private:
static const Uint32 waitTime;
--- /dev/null
+#include "WorldObject.h"
+#include "fns.h"
+
+
+void WorldObject::drawCollisions(vector<Collision*> *vec){
+ for(int i=0; i < vec->size(); i++){
+ (*vec)[i]->draw();
+ }
+}
#ifndef WORLDOBJECT
#define WORLDOBJECT
+#include "fns.h"
+#include "Collision.h"
+
class WorldObject
{
- public:
- WorldObject(int z = 0) :
- ZOrder(z),
- mVisible(true)
- {}
- virtual void draw() = 0;/**< draws object. */
- void xadd(int num) {mPos.x += num;}/**< Increase x coordiante by a given amount. */
- void yadd(int num) {mPos.y += num;}/**< Increase y coordinate by a given amount. */
- void xset(int x) {mPos.x = x;}/**< Sets the Sprite's x Coordinate. */
- void yset(int y) {mPos.y = y;}/**< Sets the Sprite's y coordinate. */
- void setPosition(int x, int y) {mPos.x = x; mPos.y = y;}/**< Sets the Sprite's x an y coordinate. */
+public:
+ WorldObject(int z = 0) :
+ ZOrder(z),
+ mVisible(true)
+ {}
+ virtual void draw() = 0;/**< Draws the Object. */
+ void drawCollisions(vector<Collision*> *vec);/**< Draws Collision data for the Object */
+ void xadd(int num) {mPos.x += num;}/**< Increase x coordiante by a given amount. */
+ void yadd(int num) {mPos.y += num;}/**< Increase y coordinate by a given amount. */
+ void xset(int x) {mPos.x = x;}/**< Sets the Sprite's x Coordinate. */
+ void yset(int y) {mPos.y = y;}/**< Sets the Sprite's y coordinate. */
+ void setPosition(int x, int y) {mPos.x = x; mPos.y = y;}/**< Sets the Sprite's x an y coordinate. */
- protected:
+protected:
Point2D mPos;/**< The current (x,y) position */
bool mVisible;/**< Determine if Object should be visible */
int ZOrder;/**< Stacking order. Determines what draws on top. \todo implement. */
#define FNS
#include <SDL/SDL.h>
#include <string>
-
/// \todo remove this this is just to make testing easy w/o gdb
#include <iostream>
using namespace std;
+class Game;
+///This is a pointer so that all objects in-game can obtain data that is needed everywhere. \todo make so that we have This.game or This->game
+Game* This;
SDL_Surface* LoadImage( std::string filename );/**< Loads supported images. */
}
}
-///This is a pointer so that all objects in-game can obtain data that is needed everywhere. \todo make so that we have This.game or This->game
-Game* This;
-
//-------------------------------------------------------------------//
// Function : main() - Params : argc, argv
// Main program function