2D Collision

Blitz3D SDK Forums/Blitz3D SDK Programming/2D Collision

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

High there, I am using something similar to the SDK so I think I am in the right place, basically I've got a wrapped c++ version of Blitzmax and I'm having problems with basic collisions within a class, i.e. comparing itself with other objects created by using an iterator to scroll through a list, I've converted the rectsOverLap function. In Bmax the way you stop an object from comparing itself with itself is:
If obj:TObject <> Self Then
     Do collision


Here is my code at the moment which simply draws a rectangle for every player created and in the update() it's looking through the list do a rects overlap, but it's not working, I think it's the if(*iter ? ! this : false), but I'm not sure what to do?
using namespace std;


class CPlayer
{
public:
	CPlayer(double x, double y)
	{
		this->m_x = x;
		this->m_y = y;
		this->m_list.push_back(this);
	}
	virtual ~CPlayer(){}

	void draw()
	{
		ezSetColor(150, 150, 150);
		ezDrawRect(this->m_x, this->m_y, 32, 32);

		update();
	}

	double getX()
	{
		return this->m_x;
	}

	double getY()
	{
		return this->m_y;
	}

	void update()
	{
		list<CPlayer*>::iterator iter;

		for(iter = this->m_list.begin(); iter != this->m_list.end(); iter++)
		{
			double pos_x = (*iter)->getX();
			double pos_y = (*iter)->getY();
			
			if(*iter ? !this : false){
				if(this->rectsOverlap(this->m_x, this->m_y, 32, 32, pos_x, pos_y, 32, 32)){
					ezSetColor(255, 255, 255);
					ezDrawText("C", this->m_x+5, this->m_y+5);
				}
			}
		}
	}

	bool rectsOverlap(double x0, double y0, double w0, double h0, double x2, double y2, double w2, double h2)
	{
		if(x0 > (x2 + w2) || (x0 + w0) < x2) {return false;}
		if(y0 > (y2 + h2) || (y0 + h0) < y2) {return false;}
		return true;
	}

private:
	double m_x, m_y;
	list<CPlayer*> m_list;

};

//Write your game/application here
void ezRunApp()
{   

    ezGraphics(800,600,false);
    
    CPlayer player1(40, 40);
    CPlayer player2(30, 30);

    while(!ezKeyHit(27))    // Main Loop
    {
        ezCls();

	player1.draw();
	player2.draw();

        ezFlip();
    }
}


Thanks