/bike.h |
---|
9,6 → 9,8 |
#include <QHostAddress> |
#include <QThread> |
#include <cmath> |
#include <time.h> |
#include <stdio.h> |
using namespace std; |
19,7 → 21,7 |
public: |
Bike(QTcpSocket *sock, int i); |
void draw(QPainter *painter,QList<Bike *> bikes); |
void run(QList<Bike *> bikes); |
void run(); |
bool hasCollided(QList<Bike *> bikes); |
void setText(QString text); |
void reset(); |
35,6 → 37,7 |
int id; |
bool isDisconnected; |
bool hasHadGo; |
QList<Bike *> bikes; |
QColor colour; |
bool collided; |
float abpool; |
/bike.cpp |
---|
103,7 → 103,7 |
} |
} |
void Bike::run(QList<Bike *> bikes) |
void Bike::run() |
{ |
for (int i = 0; i < bikes.count(); i++) |
{ |
163,6 → 163,9 |
} |
} |
hasHadGo = true; |
time_t result = time(NULL); |
cout << result << ": Recieved next move from " << name.toStdString().c_str() << endl; |
} |
int sign(int x){ |
/mainwindow.cpp |
---|
43,7 → 43,7 |
{ |
for (int i = 0; i < bikes.count(); i++) |
{ |
bikes[i]->speed += 0.02; |
bikes[i]->speed *= 1.01; |
} |
} |
63,12 → 63,14 |
if (ready) |
{ |
cout << ":: Sent move request..." << endl; |
for (int i = 0; i < bikes.count(); i++) |
{ |
if (bikes[i]->show) |
{ |
bikes[i]->hasHadGo = false; |
bikes[i]->run(bikes); |
bikes[i]->bikes = bikes; |
bikes[i]->start(); |
} |
} |
Bike *bike; |