16,6 → 16,7 |
|
velocity = 1; |
angle = 0; |
abpool = 0; |
name = ""; |
show = false; |
isReady = false; |
64,7 → 65,6 |
if (!collided) |
{ |
collided = hasCollided(bikes); |
|
if (angle == 0) |
{ |
y -= velocity; |
162,7 → 162,7 |
hasHadGo = true; |
} |
|
int sign(float x){ |
int sign(int x){ |
if(x > 0){ |
return 1; |
} |
181,25 → 181,30 |
return true; |
if(linePoints[i].x() < 0 || linePoints[i].x() > 800 || linePoints[i].y() < 0 || linePoints[i].y() > 600) |
return true; |
int j; |
int j, r; |
Bike *bike; |
foreach(bike,bikes) |
for(r = 0; r < bikes.count(); r++) |
{ |
for(j = 0; j < bike->linePoints.count() - 2; j++) |
bike = bikes[r]; |
for(j = 0; j < bike->linePoints.count() - 1; j++) |
{ |
if(!(bike->linePoints[j].x() == bike->linePoints[j+1].x() && linePoints[i].x() == linePoints[i-1].x()) && !(bike->linePoints[j].y() == bike->linePoints[j+1].y() && linePoints[i].y() == linePoints[i-1].y())) |
{ |
|
// If not parallel |
if(bike->linePoints[j].x() == bike->linePoints[j+1].x()) |
{ |
// x equal |
if(linePoints[i-1].x() > bike->linePoints[j].x() && linePoints[i].x() < bike->linePoints[j].x() || linePoints[i-1].x() < bike->linePoints[j].x() && linePoints[i].x() > bike->linePoints[j].x()){ |
|
if(linePoints[i-1].x() > bike->linePoints[j].x() && linePoints[i].x() < bike->linePoints[j].x() || linePoints[i-1].x() < bike->linePoints[j].x() && linePoints[i].x() > bike->linePoints[j].x()) |
{ |
if((sign(linePoints[i-1].y() - bike->linePoints[j].y()) != sign(linePoints[i-1].y() - bike->linePoints[j+1].y()))) |
return true; |
} |
} |
else if(bike->linePoints[j].y() == bike->linePoints[j+1].y()) |
if(bike->linePoints[j].y() == bike->linePoints[j+1].y()) |
{ |
|
if(linePoints[i-1].y() > bike->linePoints[j].y() && linePoints[i].y() < bike->linePoints[j].y() || linePoints[i-1].y() < bike->linePoints[j].y() && linePoints[i].y() > bike->linePoints[j].y()) |
{ |
if((sign(linePoints[i-1].x() - bike->linePoints[j].x()) != sign(linePoints[i-1].x() - bike->linePoints[j+1].x()))) |
222,6 → 227,7 |
|
velocity = 1; |
angle = 0; |
abpool = 0; |
show = true; |
isReady = true; |
hadGo = false; |
250,6 → 256,12 |
{ |
angle += 360; |
} |
if(velocity < 5) |
velocity += 0.5; |
else if(velocity > 5) |
velocity -= 0.5; |
if(abpool<10) |
abpool += 0.2; |
hadGo = true; |
} |
else if (line == "R") |
264,20 → 276,38 |
{ |
angle += 360; |
} |
if(velocity < 5) |
velocity += 0.5; |
else if(velocity > 5) |
velocity -= 0.5; |
if(abpool<10) |
abpool += 0.2; |
hadGo = true; |
} |
else if (line == "A") |
{ |
velocity += 0.1; |
if(abpool > 0){ |
velocity += 0.1; |
abpool -= 0.5; |
} |
hadGo = true; |
} |
else if (line == "D") |
{ |
velocity -= 0.2; |
if(abpool > 0){ |
velocity -= 0.2; |
abpool -= 0.5; |
} |
hadGo = true; |
} |
else if (line == "N") |
{ |
if(velocity < 5) |
velocity += 0.5; |
else if(velocity > 5) |
velocity -= 0.5; |
if(abpool<10) |
abpool += 0.2; |
hadGo = true; |
} |
else if (line.startsWith("NAME ")) |