It looks like you're new here. If you want to get involved, click one of these buttons!
Hello I am new to codea as well as coding I am trying to make a game similar to bit invader only horizontal. So far I have created a spaceship sprite which is movable as well as a background with some stars.
-- Use this function to perform your initial setup
function setup()
x = WIDTH/2
y = HEIGHT/2
c = color(0, 0, 0, 255)
end
-- This function gets called once every frame
function draw()
background(0, 0, 0, 225)
sprite("SpaceCute:Star",374,374)
sprite("SpaceCute:Star",100,150)
sprite("SpaceCute:Star",400,550)
sprite("SpaceCute:Star",600,200)
sprite("SpaceCute:Star",150,650)
sprite("SpaceCute:Star",650,700)
-- Do your drawing here
sprite("SpaceCute:Rocketship",150,y)
end
function touched(touch)
x = x
y = touch.y
end
I am looking to have objects come on to the screen horizontally and have you control the spaceship to avoid them. However I am a stuck at how to get the objects to come onto the screen infinitely and how to get them to come on at random points in the right hand side. I believe you use something called math.random seed then enter coordinates. For example, (math.randomseed1,100) and then it will randomly chose between the 1 and 100 coordinates to come on. Deos anyone know how to apply this to my game. Please keep it as simple as possible and any help is greatly appreciated.
Comments
@Frazamataza
I added some code to your program to just give you an idea of what you can do. You'll have to use a table to have multiple objects going at once. If you have questions, just ask.
Good stuff guys. Thanks for sharing.
thanks dave, very helpful, just got to figure out collision then I am done.