User prompt
in distance check use segment.width / 2
Code edit (1 edits merged)
Please save this source code
User prompt
use the road segment calculation to determine of the car is currently on a road segment. The car is on a road segment if the distance is < segment.width
User prompt
remove the console log
Code edit (17 edits merged)
Please save this source code
User prompt
when calculating segmentEnd subtract sin
User prompt
when calculating segmentEnd use segment.height
User prompt
in roadSegments distance calculation reverse sin and cos
Code edit (1 edits merged)
Please save this source code
Code edit (9 edits merged)
Please save this source code
User prompt
the Shortest distance to road calculation does not seem to yield the expected result. if the car is driving on the center of the road the expectation is that the result should be zero
User prompt
in tick, use calculateDistanceToPoint to calculate the shortest distance to any road segment
User prompt
in the game class, add a method that can calculate the distance between a point (the car) and a given line segment (segments)
Code edit (1 edits merged)
Please save this source code
User prompt
for the secound point in distanceToLineSegment use the rotation of the road and height of road to calculate that point
User prompt
In tick use the distanceToLineSegment method to calculate the shortest distance to any segment
User prompt
In tick use the distanceToLineSegment method to calculate distance to the segment at index 0
User prompt
in game, add a method that can calculate the distance between the car and a given line segment based on line (segment) to point (car) math
User prompt
the road segment distance calculation does not seem to work
Code edit (1 edits merged)
Please save this source code
User prompt
In tick, calculate how close the car is to the center line of any road segment
User prompt
make the first road segment created 3000px long
User prompt
make the first road segment created 3000px long
Code edit (1 edits merged)
Please save this source code
User prompt
in tick calculate if the car center is currently inside or outside any of the road segments
===================================================================
--- original.js
+++ change.js
@@ -131,13 +131,12 @@
x: segment.x - Math.sin(segment.rotation) * segment.height,
y: segment.y + Math.cos(segment.rotation) * segment.height
};
var distance = self.calculateDistanceToPoint(carPosition, segmentStart, segmentEnd);
- if (distance < segment.width) {
+ if (distance < segment.width / 2) {
carIsOnRoad = true;
}
});
- console.log(carIsOnRoad);
if (!carIsOnRoad) {
isGameOver = true;
}
var particleOffsets = [{