Je ne sais pas trop si c'est ici qu'il faut poster ce genre d’ânerie mais bon voila j'avais un peut de temps à perdre... Have fun !
(Je rajouterai une mort si j'ai 30 nouvelles minutes à perdre )
Code : Tout sélectionner
EnableExplicit
InitSprite()
InitKeyboard()
Enumeration ;GameStep
#Flapping
#Kabooming
#Attending
EndEnumeration
Structure wall
x.i
y1.i
y2.i
pt.i
EndStructure
Global A = 10, B = 24, x = 18, framerate, pushed, window, wall, flappy, rnd, flappyY, event, lasty, GameStep = #Attending, y , score
Global NewList wall.wall()
Declare init()
window = OpenWindow(#PB_Any,0,0,900,500,"Flappy",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
OpenWindowedScreen(WindowID(window),0,0,900,500)
flappy = CreateSprite(#PB_Any,50,50,#PB_Sprite_AlphaBlending|#PB_Sprite_PixelCollision)
wall = CreateSprite(#PB_Any,50,400,#PB_Sprite_AlphaBlending|#PB_Sprite_PixelCollision)
StartDrawing(SpriteOutput(flappy)) :Circle(25,25,25,$0033CC) : StopDrawing()
StartDrawing(SpriteOutput(wall)) : Box(0,0,50,400,$006600) : StopDrawing()
init()
framerate = ElapsedMilliseconds()
Repeat
event = WindowEvent()
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Space) And pushed = 0 : pushed = 1 : EndIf
Select GameStep
Case #Flapping
If pushed = 1 : x = 12 : EndIf
If ElapsedMilliseconds() >= framerate + 16
ClearScreen($CC0000)
If x < 25
x + 1
EndIf
y = A * Sin(2 * #PI / B * x)
flappyY + y
ForEach wall()
wall()\x = wall()\x -5
If wall()\x < 150 And wall()\pt = 0 : wall()\pt = 1: score + 1 : EndIf
If wall()\x < -50
wall()\x = 950
rnd = -Random(390,110)
If lasty - rnd < -200 : rnd = lasty + 200 : EndIf
lasty = rnd
wall()\y1 = rnd
wall()\y2 = rnd +600
wall()\pt = 0
EndIf
DisplaySprite(wall,wall()\x,wall()\y1)
DisplaySprite(wall,wall()\x,wall()\y2)
DisplaySprite(flappy,150,flappyY)
If SpritePixelCollision(flappy,150,flappyY,wall,wall()\x,wall()\y1) Or SpritePixelCollision(flappy,150,flappyY,wall,wall()\x,wall()\y2)
GameStep = #Kabooming
EndIf
Next
StartDrawing(ScreenOutput()) : DrawText(10,10,Str(score)) : StopDrawing()
EndIf
FlipBuffers()
Case #Kabooming
Debug "kaboom baby"
init()
GameStep = #Attending
FlipBuffers()
Case #Attending
If pushed : GameStep = #Flapping: pushed = 0 : EndIf
EndSelect
If pushed : pushed = 2 : EndIf
If KeyboardReleased(#PB_Key_Space) : pushed = 0 : EndIf
Delay(1)
Until event = #PB_Event_CloseWindow
Procedure init()
score = 0
ClearScreen($CC0000)
ClearList(wall())
AddElement(wall())
wall()\x = 500
wall()\y1 = -300
wall()\y2 = 300
AddElement(wall())
wall()\x = 1000
rnd = -Random(390,110)
wall()\y1 = rnd
wall()\y2 = rnd +600
lasty = rnd
FlappyY = 250
StartDrawing(ScreenOutput())
DrawingMode(#PB_2DDrawing_Transparent)
DrawText(450,250,"Space to Flapp !",$000000)
StopDrawing()
FlipBuffers()
EndProcedure