Hi!
I’m trying to make a simple puzzle game sort of like the Unblock Me game in App Store.
But I don’t know where to start.
Is there a tutorial for making a simple puzzle game?
I want to be able to drag shapes squares and rectangles like in Unblock Me.
I don’t want physics, only collision between different shapes.
(So they can’t move over/under each other)
Can someone point me in the right direction?
I have written this code at the moment but it doesn’t really do what I need:
[lua]-- hide the status bar
display.setStatusBar( display.HiddenStatusBar )
local physics = require(“physics”)
local gameUI = require(“gameUI”)
physics.start()
physics.setGravity(0, 0)
– physics.setDrawMode(“hybrid”)
local arguments =
{
{ x=0, y=0, w=50, h=50, r=0, red=255, green=0, blue=0 },
{ x=100, y=0, w=50, h=50, r=0, red=0, green=255, blue=0 },
{ x=200, y=0, w=50, h=50, r=0, red=0, green=0, blue=255 }
}
function dragBody( event )
– gameUI.dragBody( event ) – default drag body behavior
– Substitute one of these lines for the line above to see what happens!
gameUI.dragBody( event, { maxForce=1, frequency=2 } ) – slow, elastic dragging
– gameUI.dragBody( event, { maxForce=20000, frequency=10, dampingRatio=0.2, center=true } ) – very tight dragging, snaps to object center
end
– Iterate through arguments array and create rounded rects (vector objects) for each item
for _,item in ipairs( arguments ) do
local button = display.newRoundedRect( item.x, item.y, item.w, item.h, item.r )
button:setFillColor( item.red, item.green, item.blue )
–button.strokeWidth = 6
button:setStrokeColor( 200,200,200,255 )
physics.addBody(button, {})
– Make the button instance respond to touch events
button:addEventListener( “touch”, dragBody )
end
– define wall
local leftWall = display.newRect(0, 0, 1, display.contentHeight)
local rightWall = display.newRect(display.contentWidth, 0, 1, display.contentHeight)
local ceiling = display.newRect(0, 0, display.contentWidth, 1)
– floor wont work…
–local floor = display.newRect(0, 0, display.contentWidth, 1)
– turn wall pays bodies
physics.addBody(leftWall, “static”, { bounce = 0} )
physics.addBody(rightWall, “static”, { bounce = 0} )
physics.addBody(ceiling, “static”, { bounce = 0} )
– floor wont work…
–physics.addBody(floor, “static”, { bounce = 0.0})[/lua] [import]uid: 211691 topic_id: 34920 reply_id: 334920[/import]