I’m building an app designed to spin a wheel and pick a random number based on the angle of rotation. The problem is the program spins the same exact amount every single time it is run regardless of the speed inputted into torque.
display.setDefault("background", 1, 1, 1) --function scene:create( event ) --local sceneGroup = self.view physics.start() physics.setGravity(0,0) physics.setDrawMode("normal") --physics.pause() --local wheel = display.newImage(sceneGroup, "arrow.png", true) local wheel = display.newImage("arrow.png") --wheel.x = display.contentWidth - 195 wheel.x = display.contentCenterX wheel.y = display.contentCenterY --wheel.y = display.contentHeight - 268 physics.addBody(wheel, "dynamic",{bounce=0, friction=0.2, radius=1}) wheel.isFixedRotation = false --local nail = display.newCircle(sceneGroup, display.contentCenterX, display.contentCenterY, 4) --physics.addBody(nail, "static",{bounce=0, friction=0.2, radius=4}) --local joint = physics.newJoint("pivot", wheel, nail, display.contentCenterX, display.contentCenterY) --joint.isLimitEnabled = false local options = { --parent = textGroup, text = "0", x = display.contentCenterX, y = display.contentCenterY - 200, width = 228, --required for multi-line and alignment font = native.systemFontBold, fontSize = 19, align = "center" --new alignment parameter } local myText = display.newText( options ) myText:setFillColor( 0, 0, 0 ) function go() math.randomseed( os.time() ) goo = true local speed = math.random( -500, 500 ) wheel.angularDamping = math.random( .6, .8 ) wheel:applyTorque(speed) end go() spinObject = function(event) return true end function printTimeSinceStart( event ) myText.text = "("..math.deg(math.asin(math.sin(wheel.rotation)))..")" if wheel.angularVelocity == 0 and goo == true then print(math.abs(math.deg(math.asin(math.sin(wheel.rotation))))) go() end end Runtime:addEventListener( "enterFrame", printTimeSinceStart ) wheel:addEventListener("tap", spinObject) --end