\param color the color to be drawn
*/
void DrawCircle(SDL_Surface* screen, const Point2D wPos, const Point2D pos, Uint32 color){
- DrawPixel(screen, wPos.x + pos.x, wPos.y + pos.y, color);
- DrawPixel(screen, wPos.x - pos.x, wPos.y + pos.y, color);
- DrawPixel(screen, wPos.x + pos.x, wPos.y - pos.y, color);
- DrawPixel(screen, wPos.x - pos.x, wPos.y - pos.y, color);
- DrawPixel(screen, wPos.x + pos.y, wPos.y + pos.x, color);
- DrawPixel(screen, wPos.x - pos.y, wPos.y + pos.x, color);
- DrawPixel(screen, wPos.x + pos.y, wPos.y - pos.x, color);
- DrawPixel(screen, wPos.x - pos.y, wPos.y - pos.x, color);
+ DrawPixel(screen, int(wPos.x + pos.x), int(wPos.y + pos.y), color);
+ DrawPixel(screen, int(wPos.x - pos.x), int(wPos.y + pos.y), color);
+ DrawPixel(screen, int(wPos.x + pos.x), int(wPos.y - pos.y), color);
+ DrawPixel(screen, int(wPos.x - pos.x), int(wPos.y - pos.y), color);
+ DrawPixel(screen, int(wPos.x + pos.y), int(wPos.y + pos.x), color);
+ DrawPixel(screen, int(wPos.x - pos.y), int(wPos.y + pos.x), color);
+ DrawPixel(screen, int(wPos.x + pos.y), int(wPos.y - pos.x), color);
+ DrawPixel(screen, int(wPos.x - pos.y), int(wPos.y - pos.x), color);
}
/**
This function is tasked with drawing lines by the midpoint method.
//if the end point is lower swap em
if(end.y < start.y){
- x = end.x;
- y = end.y;
- xMax = start.x;
- yMax = start.y;
+ x = (int)end.x;
+ y = (int)end.y;
+ xMax = (int)start.x;
+ yMax = (int)start.y;
}
else {
- x = start.x;
- y = start.y;
- xMax = end.x;
- yMax = end.y;
+ x = (int)start.x;
+ y = (int)start.y;
+ xMax = (int)end.x;
+ yMax = (int)end.y;
}
//the change in x
void CollisionCircle::draw(const Point2D& pos){
Slock(Game::game()->Screen());
- int x=0,y=radius;///<The relative x,y pos
- int midpt = 1-radius;///<the midpt of the circle
+ int x=0,y=(int)radius;///<The relative x,y pos
+ int midpt = 1-(int)radius;///<the midpt of the circle
//draw pts
DrawCircle(Game::game()->Screen(), pos + mPos, Point2D(x,y), color);
//calculate other points
}
bool Collision::checkCollisions(const vector<Collision*>& c, const Point2D cPos, const Point2D pos){
- for(int i=0; i < c.size(); i++){
+ for(unsigned int i=0; i < c.size(); i++){
if(collision(c[i], cPos, pos))//if any are true return true then and there
return true;
}
bool CollisionRectangle::collision(const Collision *c, const Point2D cPos, const Point2D pos) const {
if(const CollisionRectangle* rec = dynamic_cast<const CollisionRectangle*>(c)){
///check rect vs rect really just axis aligned box check (simpler)
- float r1Left = -width/2 + mPos.x + pos.x;
- float r1Right = width/2 + mPos.x + pos.x;
- float r1Top = -height/2 + mPos.y + pos.y;
- float r1Bottom = height/2 + mPos.y + pos.y;
+ double r1Left = -width/2 + mPos.x + pos.x;
+ double r1Right = width/2 + mPos.x + pos.x;
+ double r1Top = -height/2 + mPos.y + pos.y;
+ double r1Bottom = height/2 + mPos.y + pos.y;
- float r2Left = -rec->width/2 + rec->mPos.x + cPos.x;
- float r2Right = rec->width/2 + rec->mPos.x + cPos.x;
- float r2Top = -rec->height/2 + rec->mPos.y + cPos.y;
- float r2Bottom = rec->height/2 + rec->mPos.y + cPos.y;
+ double r2Left = -rec->width/2 + rec->mPos.x + cPos.x;
+ double r2Right = rec->width/2 + rec->mPos.x + cPos.x;
+ double r2Top = -rec->height/2 + rec->mPos.y + cPos.y;
+ double r2Bottom = rec->height/2 + rec->mPos.y + cPos.y;
bool outsideX = r1Right < r2Left || r1Left > r2Right;
bool outsideY = r1Bottom < r2Top || r1Top > r2Bottom;