Help Making game.

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]

Please read the forum rules and do not post gigantic walls of code without using the appropriate tags;
http://developer.anscamobile.com/forum/2011/05/05/forum-rules-and-guidelines

It makes it far too much of a headache to read - you will get more answers if you format it with other people in mind.

Peach [import]uid: 52491 topic_id: 11505 reply_id: 41881[/import]

I didn’t look at your code – like Peach said, it’s too hard when it’s not formatted as code. :slight_smile:

Plus, if you zip up the entire project and give people a link to it they can try it out. It’s usually much faster to fix problems and make suggestions when you can *see* what’s happening.

Today I spent a little time coming up with ways to make a Simon-type game and here’s a 77-second video showing what I did:

http://youtu.be/2nn10ukLfh4

I’m writing up a tutorial showing what I did in the code and I think there will be some pieces in there that will help you.

I should have that on the GameDevNation.com site by late tomorrow (Thursday) night (Alaska time). I’ll post here when it’s ready to go.

Jay
[import]uid: 9440 topic_id: 11505 reply_id: 42045[/import]

Hi guys. So sorry about the whole copy paste thing. I will know that for later. Thanks for the tutorial :wink:

jimmi [import]uid: 51793 topic_id: 11505 reply_id: 42292[/import]

Here’s a link to the Simon tutorial:

http://gamedevnation.com/?p=340

Hopefully there’s stuff in there that will help you out.

Jay


Corona Project Manager makes you a better Corona® SDK developer.
http://CoronaProjectManager.com
[import]uid: 9440 topic_id: 11505 reply_id: 42346[/import]

@J. A. Whye:
Just fyi for some reason even after signing up
verifying and logging out/back in no download link
for the project appears.
[import]uid: 67514 topic_id: 11505 reply_id: 42518[/import]

Hi Guys.
Thanks for all the help, I appreciate it a lot. Nice tutorial.

The thing is that i’m not that hell of a coder, I honestly youtubed and forum my way through to what I got now.
If there anyone who could give me a hind what to do. Mail, skype facetime anything would be awesome.

[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 someone can help
[import]uid: 51793 topic_id: 11505 reply_id: 46962[/import]

I looked through your code a little, I think it could be simplified alot… but i recommend starting off with something simlper than this… just work your way up to it.

But as far as a hint goes…

If your making a simon says type game

You need to randomly generate a sequence of colors. To do this I would make an array, populate it with a group of random numbers… an array with 120 numbers for instance… If you are using 4 colors… then you would need 4 numbers to populate that array… the array would look something like this. [1, 4, 3, 2, 4, 1, 4 etc…]

Then just iterate through the array, show the first color…
allow the user to select a color… test whatever the user selected against the first index in your array. If its correct… then iterate through 2 indecees in your array… and so on [import]uid: 28912 topic_id: 11505 reply_id: 47147[/import]