I am new to this and was playing around with the Billy Cart code. I thought it would be a good way to learn what exactly everything is doing by changing things and seeing how they affect the app. I understand how to change the peak height for the ground. The shapes this app creates have six sides. Can someone help explain to me how to change the shapes to have more sides? I was wanting to change the shapes and make the jumps more round and make the track appear to be one continuous line instead of the ground being so boxy between changes in slope. This is part of the code but I am not sure what to change. I’m just trying to understand the track design before I try to learn about the rest of the program.
Thanks everyone,
local function offset(x, y)
return x, y - display.contentHeight
end
local function newContour(params)
local physicsShape = {}
local coords = params.coords
local bodyType = params.bodyType
local contour = display.newLine(coords[1], coords[2], coords[3], coords[4])
physicsShape[1], physicsShape[2] = offset(coords[1], coords[2])
physicsShape[3], physicsShape[4] = offset(coords[3], coords[4])
if params.color then
contour:setColor(params.color[1], params.color[2], params.color[3])
else
contour:setColor(255, 0, 0, 255)
end
contour.width = 8
for i = 5, #coords, 2 do
contour:append(coords[i], coords[i+1])
physicsShape[i], physicsShape[i+1] = offset(coords[i], coords[i+1])
end
contour:append(coords[1], coords[2])
physics.addBody(contour, bodyType or “static”,
{ friction = 1, bounce = 0.0, shape=physicsShape} )
return contour
end
local p = params or {}
-----------------------------------------
– Slope definition with variable peak
-----------------------------------------
local function newSlope(peakY)
local slope =
{
0, 320,
0, 260,
200, peakY,
280, peakY,
480, 260,
480, 320
}
return slope
end
local peaks = { 259, 150, 100, 150, 249, 239, 110, 219, 170, 239, 150 }
local lastXPos = 0
local shapeStartIndex = localGroup.numChildren+1
local lastIndex = shapeStartIndex
local shapeEndIndex = shapeStartIndex + #peaks-1
local panels = {}
local colors = { { 205, 133, 63 },{ 139, 69, 19 }, { 205, 133, 63 },{ 139, 69, 19 },{ 205, 133, 63 } }
for i = 1, #peaks do
local ground = newContour
{
coords = newSlope(peaks[i]),
color = colors[i % #colors]
}
ground.x = ground.x + (i-1) * 480
ground.index = i
lastXPos = ground.x
localGroup:insert(ground)
ground.id = “gr”
panels[#panels+1] = ground
end