find_package(SDL REQUIRED)
find_package(SDL_image REQUIRED)
-add_executable(game Animation.cpp fns.cpp Game.cpp Level.cpp main.cpp Sprite.cpp Text.cpp Actor.cpp Background.cpp LevelWorld.cpp WorldObject.cpp Collision.cpp)
+add_executable(game Animation.cpp fns.cpp Game.cpp Level.cpp main.cpp WorldObject.cpp Sprite.cpp Text.cpp Actor.cpp Background.cpp LevelWorld.cpp Collision.cpp)
target_link_libraries(game ${SDL_LIBRARY} ${SDLIMAGE_LIBRARY})
Draw_Rect(Game::game()->Screen(), pos.x + mPos.x, pos.y + mPos.y, width, height, color);
}
-void CollisionCircle::draw(Point2D& pos){
+void CollisionCircle::draw(const Point2D& pos){
Draw_Circle(Game::game()->Screen(), pos.x + mPos.x, pos.y + mPos.y, radius, color);
}
Point2D mPos;/**< 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(Point2D& pos) = 0;/**< Draws the collision data to the screen */
+ virtual void draw(const Point2D& pos) = 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(Point2D& pos);/**< Draws the collision data to the screen */
+ virtual void draw(const Point2D& pos);/**< 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(Point2D& pos);/**< Draws the collision data to the screen */
+ virtual void draw(const Point2D& pos);/**< Draws the collision data to the screen */
};
#endif
dest.y = mPos.y;
if(mVisible == true)
SDL_BlitSurface(frame.image,NULL,mScreen,&dest);
- if(Game::game()->ShowCollisions)
- drawCollisions(frame.collisionData, mPos + frame.animationPeg);
+ if(Game::game()->ShowCollisions){
+ Point2D pt =mPos + frame.animationPeg;
+ drawCollisions(frame.collisionData, pt);
+ }
}
#include "fns.h"
-void WorldObject::drawCollisions(vector<Collision*> &vec, Point2D& pos){
+void WorldObject::drawCollisions(vector<Collision*> &vec, const Point2D& pos){
for(int i=0; i < vec.size(); i++){
vec[i]->draw(pos);
}
ZOrder(z),
mVisible(true)
{}
- virtual void draw() = 0;/**< Draws the Object. */
- void drawCollisions(vector<Collision*>& vec, Point2D& pos);/**< 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. */
+ virtual void draw() = 0;/**< Draws the Object. */
+ void drawCollisions(vector<Collision*>& vec, const Point2D& pos);/**< 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:
Point2D mPos;/**< The current (x,y) position */
bufp = (Uint8 *)screen->pixels + y*screen->pitch + x * 3;
if(SDL_BYTEORDER == SDL_LIL_ENDIAN)
{
-bufp[0] = color;
+ bufp[0] = color;
bufp[1] = color >> 8;
bufp[2] = color >> 16;
} else {