/bike.h |
---|
19,6 → 19,7 |
Bike(QTcpSocket *sock, int i); |
void draw(QPainter *painter); |
void run(QList<Bike *> bikes); |
bool hasCollided(); |
void reset(); |
bool isReady; |
bool dead; |
33,6 → 34,7 |
bool isDisconnected; |
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,6 → 61,10 |
painter->drawLine(point1, point2); |
} |
if (!collided) |
{ |
collided = hasCollided(); |
if (angle == 0) |
{ |
y -= velocity; |
76,6 → 81,11 |
{ |
x -= velocity; |
} |
} |
else |
{ |
linePoints.clear(); |
} |
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"); |
} |