Hey people.
I made a game were the purpose is to hit different colors in a specific order. Kinda like Simon says. I created everything, the score counts when the ball hits the object, but thats all. Now what i have in mind is that when you press start game, it should light up maybe to colors, e.g blue and red, then you hit blue and red, then blue, red, green and so on.
How do i create something like that.
Here’s what I got.
[lua]module(…, package.seeall)
function new()
local localGroup = display.newGroup()
local physics = require( “physics”)
physics.start()
physics.setGravity(0, 0)
display.setStatusBar( display.HiddenStatusBar )
local bg = display.newImage(“background.png”)
local soccer_ball = display.newImageRect(“soccer_ball.png”, 35, 35)
soccer_ball.x = 160
soccer_ball.y = 200
physics.addBody(soccer_ball,{ density = 0.3, friction = 0.9, radius = 50})
local object1 = display.newImage( “paddle.png”, 17, 119)
object1.x = 11
object1.y = 419
physics.addBody( object1, “static” )
local object2 = display.newImageRect( “paddle1.png”, 17, 119)
object2.x = 11
object2.y = 299
physics.addBody( object2, “static”, { density=1, friction=0.3, bounce=0.2 } )
local object3 = display.newImageRect( “paddle2.png”, 17, 119)
object3.x = 11
object3.y = 181
physics.addBody( object3, “static”, { density=1, friction=0.3, bounce=0.2 } )
local object4 = display.newImageRect( “paddle3.png”, 17, 119)
object4.x = 11
object4.y = 61
physics.addBody( object4, “static”, { density=1, friction=0.3, bounce=0.2 } )
local object5 = display.newImageRect( “paddle4.png”, 17, 119)
object5.x = 309
object5.y = 420
physics.addBody( object5, “static”, { density=1, friction=0.3, bounce=0.2 } )
local object6 = display.newImageRect( “paddle5.png”, 17, 119)
object6.x = 309
object6.y = 300
physics.addBody( object6, “static”, { density=1, friction=0.3, bounce=0.2 } )
local object7 = display.newImageRect( “paddle6.png”, 17, 119)
object7.x = 309
object7.y = 180
physics.addBody( object7, “static”, { density=1, friction=0.3, bounce=0.2 } )
local object8 = display.newImageRect( “paddle7.png”, 17, 119)
object8.x = 309
object8.y = 61
physics.addBody( object8, “static”, { density=1, friction=0.3, bounce=0.2 } )
local object9 = display.newImageRect( “paddle8.png”, 267, 19)
object9.x = 160
object9.y = 11
physics.addBody( object9, “static”, { density=1, friction=0.3, bounce=0.2 } )
local object10 = display.newImageRect( “paddle9.png”, 267, 19)
object10.x = 161
object10.y = 468
physics.addBody( object10, “static”, { density=1, friction=0.3, bounce=0.2 } )
local sound1 = audio.loadSound(“Space Gun 01.wav”)
local sound2 = audio.loadSound(“dum.aiff”)
local sound3 = audio.loadSound(“Metal Hit 04.wav”)
local sound4 = audio.loadSound(“Arcade Alarm 01.wav”)
local sound5 = audio.loadSound(“Arcade Beep 04.wav”)
local sound6 = audio.loadSound(“Metal Clang 02.wav”)
local sound7 = audio.loadSound(“Arcade Action 04.wav”)
local sound8 = audio.loadSound(“Space Gun 04.wav”)
local sound9 = audio.loadSound(“Arcade Chirp 05.wav”)
local sound10 = audio.loadSound(“Dog Barking 05.wav”)
local motionx = 0
local motiony = 0
local function moveBall(event)
soccer_ball.x = soccer_ball.x - motionx
soccer_ball.y = soccer_ball.y - motiony
end
Runtime:addEventListener(“enterFrame”, moveBall)
local remote = require(“remote”)
remote.startServer( “8080”)
local function updateAccelerometer()
motionx = 35 * remote.xGravity
motiony = 35 * remote.yGravity
end
– Add Enter Frame Listener
Runtime:addEventListener( “enterFrame” , updateAccelerometer )
function onHit(e)
if(e.phase == “began”) then
if(e.object1 == object1) then
audio.play(sound1)
end
end
end
Runtime:addEventListener(“collision”, onHit)
function onHit(e)
if(e.phase == “began”) then
if(e.object1 == object2) then
audio.play(sound2)
end
end
end
Runtime:addEventListener(“collision”, onHit)
function onHit(e)
if(e.phase == “began”) then
if(e.object1 == object3) then
audio.play(sound3)
end
end
end
Runtime:addEventListener(“collision”, onHit)
function onHit(e)
if(e.phase == “began”) then
if(e.object1 == object4) then
audio.play(sound4)
end
end
end
Runtime:addEventListener(“collision”, onHit)
function onHit(e)
if(e.phase == “began”) then
if(e.object1 == object5) then
audio.play(sound5)
end
end
end
Runtime:addEventListener(“collision”, onHit)
function onHit(e)
if(e.phase == “began”) then
if(e.object1 == object6) then
audio.play(sound6)
end
end
end
Runtime:addEventListener(“collision”, onHit)
function onHit(e)
if(e.phase == “began”) then
if(e.object1 == object7) then
audio.play(sound7)
end
end
end
Runtime:addEventListener(“collision”, onHit)
function onHit(e)
if(e.phase == “began”) then
if(e.object1 == object8) then
audio.play(sound8)
end
end
end
Runtime:addEventListener(“collision”, onHit)
function onHit(e)
if(e.phase == “began”) then
if(e.object1 == object9) then
audio.play(sound9)
end
end
end
Runtime:addEventListener(“collision”, onHit)
function onHit(e)
if(e.phase == “began”) then
if(e.object1 == object10) then
audio.play(sound10)
end
end
end
Runtime:addEventListener(“collision”, onHit)
score = require (“score”)
local border = 5
local scoreInfo = score.getInfo()
score.init({
x = 75,
y = 55}
)
score.setScore(0)
function onHit(e)
if(e.phase == “began”) then
if(e.object1 == object10) then
score.setScore (score.getScore()+10)
end
end
end
Runtime:addEventListener(“collision”, onHit)
function onHit(e)
if(e.phase == “began”) then
if(e.object1 == object9) then
score.setScore (score.getScore()+10)
end
end
end
Runtime:addEventListener(“collision”, onHit)
function onHit(e)
if(e.phase == “began”) then
if(e.object1 == object8) then
score.setScore (score.getScore()+20)
end
end
end
Runtime:addEventListener(“collision”, onHit)
function onHit(e)
if(e.phase == “began”) then
if(e.object1 == object7) then
score.setScore (score.getScore()+20)
end
end
end
Runtime:addEventListener(“collision”, onHit)
function onHit(e)
if(e.phase == “began”) then
if(e.object1 == object6) then
score.setScore (score.getScore()+20)
end
end
end
Runtime:addEventListener(“collision”, onHit)
function onHit(e)
if(e.phase == “began”) then
if(e.object1 == object5) then
score.setScore (score.getScore()+20)
end
end
end
Runtime:addEventListener(“collision”, onHit)
function onHit(e)
if(e.phase == “began”) then
if(e.object1 == object4) then
score.setScore (score.getScore()+20)
end
end
end
Runtime:addEventListener(“collision”, onHit)
function onHit(e)
if(e.phase == “began”) then
if(e.object1 == object3) then
score.setScore (score.getScore()+20)
end
end
end
Runtime:addEventListener(“collision”, onHit)
function onHit(e)
if(e.phase == “began”) then
if(e.object1 == object2) then
score.setScore (score.getScore()+20)
end
end
end
Runtime:addEventListener(“collision”, onHit)
function onHit(e)
if(e.phase == “began”) then
if(e.object1 == object1) then
score.setScore (score.getScore()+20)
end
end
end
Runtime:addEventListener(“collision”, onHit)
return localGroup
end
Hope you can help [import]uid: 51793 topic_id: 11505 reply_id: 311505[/import]

