Subversion Repositories QTron

Compare Revisions

Ignore whitespace Rev 7 → Rev 8

/bike.h
18,7 → 18,8
public:
Bike(QTcpSocket *sock, int i);
void draw(QPainter *painter);
void run(QList<Bike *> bikes);
void run(QList<Bike *> bikes);
bool hasCollided();
void reset();
bool isReady;
bool dead;
31,8 → 32,9
QList<QPoint> linePoints;
int id;
bool isDisconnected;
bool hasHadGo;
QColor colour;
bool hasHadGo;
QColor colour;
bool collided;
 
private:
QTcpSocket *socket;
/bike.cpp
21,6 → 21,7
isReady = false;
hadGo = false;
dead = false;
collided = false;
 
colour.setBlue(0);
colour.setRed(0);
60,22 → 61,31
painter->drawLine(point1, point2);
}
 
if (angle == 0)
if (!collided)
{
y -= velocity;
collided = hasCollided();
 
if (angle == 0)
{
y -= velocity;
}
else if (angle == 90)
{
x += velocity;
}
else if (angle == 180)
{
y += velocity;
}
else if (angle == 270)
{
x -= velocity;
}
}
else if (angle == 90)
else
{
x += velocity;
linePoints.clear();
}
else if (angle == 180)
{
y += velocity;
}
else if (angle == 270)
{
x -= velocity;
}
 
if (angle == 0 || angle == 180)
{
152,6 → 162,14
hasHadGo = true;
}
 
bool Bike::hasCollided()
{
// Do collision detection here
// use linePoints
 
return false;
}
 
void Bike::reset()
{
x = rand() % 800;
166,6 → 184,7
isReady = true;
hadGo = false;
dead = false;
collided = false;
 
socket->write("RESET\n");
}