User prompt
set initial currentX and currentY to the same as car x and y init position
User prompt
do not calculate current x and y at the top of addRoadSegment
User prompt
set segment height to a random value between 500 and 4000
User prompt
set segment height to a random value between 500 and 400
User prompt
update road width to 20px
Code edit (1 edits merged)
Please save this source code
User prompt
rotation should be reversed when we zig
User prompt
add particles with z-index 1
Code edit (1 edits merged)
Please save this source code
User prompt
add road segments to roadContainer
Code edit (1 edits merged)
Please save this source code
User prompt
add a simple container to mainContainer for road segments
User prompt
calculate currentX and currentY at the bottom of addRoadSegment
User prompt
have both a current x and current y variable to determine where to insert the next road segment
User prompt
calculate a new segmentLength for each road segment
User prompt
Rotate the road segments 45 degrees clockwise
Code edit (1 edits merged)
Please save this source code
User prompt
in addRoadSegment set width and hight of road segment
User prompt
move the updating of currentY and zigzag from the road creation loop into the add road segment method at the bottom
User prompt
Define zigzag outside the addroadsegment method and simply set it to zero
User prompt
Fix Bug: 'TypeError: undefined is not an object (evaluating 'lastSegment.x')' in this line: 'var zigzag = lastSegment.x === 0;' Line Number: 59
User prompt
when creating the road, us the addRoadSegment method
User prompt
Create a new method that adds one more segment to the road
User prompt
in game simply create roadSegment assets rather than attaching a new class type
User prompt
Road segments should be between 200 and 1000 px long and always 400 px wide
===================================================================
--- original.js
+++ change.js
@@ -74,10 +74,10 @@
var roadContainer = mainContainer.addChild(new Container());
var roadSegments = [];
var segmentLength = Math.floor(Math.random() * (1000 - 200 + 1)) + 200;
var segmentWidth = 400;
- var currentX = 0;
- var currentY = 2732;
+ var currentX = 2048 / 2;
+ var currentY = 2732 / 2;
var zigzag = 0;
var initialSegment = mainContainer.createAsset('roadSegment', 'Road Segment', 0.5, 0);
initialSegment.y = currentY;
initialSegment.x = 0;