I’ve been trying to understand the “test edges and chains“ example in PhysicsLab.
I tried to pick the code apart and explicate the variables, but I’m not sure I did it right:
-- test edges & chains
local points = {}
local overallY = WIDTH * 0.08
local peaksMultiple = WIDTH * 0.00003
local waveHeight = HEIGHT * 0.025
local segmentLength = WIDTH/150
for i = 0, WIDTH, segmentLength do
table.insert(points, vec2(i,(math.sin(i*peaksMultiple) * waveHeight) + overallY))
end
local ground = physics.body(CHAIN, false, table.unpack(points))
self.lab:addBody(ground)
What I would like to do is create a gently sloping curve, just one, with its peak in the middle of the screen, kind of like the curve in the attached picture.
I’ve been able to make that happen on a single device in a single orientation, just by fiddling around with the variables until it looked right, but I can’t figure out how to do it on any device in any orientation.