It looks like you're new here. If you want to get involved, click one of these buttons!
This is My first game made With codea
-- Flappy spaceship
function setup()
flappy=readImage("Planet Cute:Enemy Bug")
pipe=readImage("Dropbox:pipe up")
pipe2=readImage("Dropbox:pipedown")
background=readImage("Dropbox:mlg")
flappyX=100
flappyY=HEIGHT/2
flappySpeed=1
pipeSpeed=-3
pipeHeight=10
x1=100
y1=500
w=125
pipeX=WIDTH
pipeY=math.random(-15,15)*10
pipeA=pipeX+375
pipeB=math.random(-15,15)*10
pipeC=pipeA+375
pipeD=math.random(-15,15)*10
gamestate=1
score=0
crash=0
end --all of the above are random useful variables for this code, some for the pipes and some for the flappy, all very helpful.
function draw()
sprite("SpaceCute:Background",WIDTH/2, HEIGHT/2, WIDTH, HEIGHT)
flappyY=flappyY+flappySpeed
flappySpeed=flappySpeed-0.11 --this is what makes flappy down on the y axis
sprite("SpaceCute:Rocketship",x1,flappyY,w) --this is the actual pic of the flappy
if flappyY>=HEIGHT-19 then flappyY=HEIGHT-19 --roof
flappySpeed=-3
end
if flappyY<=15 then flappyY=15 --floor
flappySpeed=3
end
sprite("Platformer Art:Crate",pipeX,pipeY+765,75,550) --this is the first section of the top and bottom pipe, it makes the pipes move on the x axis and you score when you pass them. It also has it so the gap is always in different spots.
sprite("Platformer Art:Crate",pipeX,pipeY,75,550)
pipeX=pipeX+pipeSpeed
if pipeX<=-75 then
pipeX=pipeC+350
pipeY=math.random(-15,15)*10
score=score+1
end
sprite("Platformer Art:Crate",pipeA,pipeB+765,75,550) --this is both of the second pipes and it does the same as I explained above
sprite("Platformer Art:Crate",pipeA,pipeB,75,550)
pipeA=pipeA+pipeSpeed
if pipeA<=-75 then
pipeA=pipeX+350
pipeB=math.random(-15,15)*10
score=score+1
end
sprite("Platformer Art:Crate",pipeC,pipeD+765,75,550) --this is both of the third pipes
sprite("Platformer Art:Crate",pipeC,pipeD,75,550)
pipeC=pipeC+pipeSpeed
if pipeC<=-75 then
pipeC=pipeA+350
pipeD=math.random(-15,15)*10
score=score+1
end
function touched(touch)
if touch.state==BEGAN then flappySpeed=flappySpeed+5.5 end --this is what makes the flappy go up with touch incorporated
end
if flappyX>=pipeX-70 and flappyX<=pipeX+70 and flappyY<=pipeY+310 then --This here is the first of the collition detection, this is the bottom pipe of the first two that gives its defined collition detection.
gamestate=crash
end
if flappyX>=pipeA-70 and flappyX<=pipeA+70 and flappyY<=pipeB+310 then --This is the second row of the bottom pipe
gamestate=crash
end
if flappyX>=pipeC-70 and flappyX<=pipeC+70 and flappyY<=pipeD+310 then --This is the third row of the bottom pipe
gamestate=crash
end
if flappyX>=pipeX-70 and flappyX<=pipeX+70 and flappyY>=pipeY+460 then --This is the collition detection of the top pipe of the first row, all was changed was the height of the collition detection because they are both in the same spot.
gamestate=crash
end
if flappyX>=pipeA-70 and flappyX<=pipeA+70 and flappyY>=pipeB+460 then --This is the second row of the top pipe
gamestate=crash
end
if flappyX>=pipeC-70 and flappyX<=pipeC+70 and flappyY>=pipeD+460 then --This is the third row of the top pipe
gamestate=crash
end
if gamestate==crash then
flappySpeed=flappySpeed*0
pipeSpeed=pipeSpeed*0
text("HAHA! Du fick bara "..(score).." poƤng.",WIDTH/2,350)
--Fill with red
c = color( 255, 0, 0 )
fill( c )
--all of this here simply says if you die then everything stops and a text pops up saying you failed and your score.
-- play a track and control the volume
-- with a parameter
-- play a looping music track
music( "A Hero's Quest:Battle", true )
-- Getting
vol=music.volume
-- Setting
music.volume=0.5
end
end
Comments
Read the FAQ to find out how to post code in the forum:
https://codea.io/talk/discussion/275/faq-please-read#latest
@yojimbo2000, some code blocks are created ;-)
@nivek2000, welcome to the forums!
To make code blocks in this forum, use this on start and on the end of your project!
@nivek2000 I added the ~'s to your above code. You can edit your code above and see how it was done. Learn how to use them before you post code again.
@nivek2000 - this isn't actually your own game code, though, is it?
It's mostly code created by a class and teacher as a school project, which has been posted before on this forum, and you should have said that.
Claiming credit for other people's code is NOT good.
What part of the code did you write yourself?
@Ignatz That's true i only changed the texture on the game , the Color of the fonts and add Some music. So it is'nt me that coded the game
I'm closing this thread.
Please don't ever claim credit again for other people's work.