I got the project working with just the math2d plugin!
Here’s the code!
local math2d = require "plugin.math2d" local physics = require "physics" physics.start() physics.setGravity(0,0) local ballSpeed = 500 local lw = display.newRect( display.contentCenterX - 450, display.contentCenterY, 40, 600 ) physics.addBody( lw, "static", { bounce = 1 }) local rw = display.newRect( display.contentCenterX + 450, display.contentCenterY, 40, 600 ) physics.addBody( rw, "static", { bounce = 1 }) local tw = display.newRect( display.contentCenterX, display.contentCenterY - 300, 900, 40 ) physics.addBody( tw, "static", { bounce = 1 }) local bw = display.newRect( display.contentCenterX, display.contentCenterY + 300, 900, 40 ) physics.addBody( bw, "static", { bounce = 1 }) local enterFrame = function( self ) local vx,vy = self:getLinearVelocity() vx,vy = math2d.normVec( vx, vy ) vx,vy = math2d.scaleVec( vx, vy, ballSpeed ) self:setLinearVelocity( vx, vy ) end local function newBall( x, y, angle ) local ball = display.newCircle( x, y, 25 ) physics.addBody( ball, { radius = 25, bounce = 1 }) ball.isFixedRotation = true local vec = math2d.angle2Vector( angle, true ) vec = math2d.scale( vec, ballSpeed ) ball:setLinearVelocity( vec.x, vec.y ) ball.enterFrame = enterFrame ball:addEventListener( "enterFrame", ball ) end local timer = timer.performWithDelay( 1, function() newBall( display.contentCenterX, display.contentCenterY, math.random(0,359) ) end, 1 )
So now the question stands – Can this be made with just LUA and Corona?
–SonicX278