Page 1 sur 2
Flappy
Publié : lun. 13/févr./2017 19:35
par boby
Bicose waie note...
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
Re: Flappy
Publié : lun. 13/févr./2017 19:55
par falsam
J’espère que tu auras d'autres moments à perdre ^^
Profites en pour travailler la transparences des sprites.
Re: Flappy
Publié : lun. 13/févr./2017 20:03
par djes
Pas mal pour quelqu'un qui ne sait pas programmer

Re: Flappy
Publié : lun. 13/févr./2017 21:58
par Ar-S
Sympa pour le partage.
Flap Flap heu Clap clap

Re: Flappy
Publié : mar. 14/févr./2017 9:46
par Guillot
c'est court, fonctionnel
ça fait un bon didacticiel
Re: Flappy
Publié : mar. 14/févr./2017 10:15
par Kwai chang caine
Pas si facile que ça le jeu

Merci pour le partage

Re: Flappy
Publié : mar. 14/févr./2017 23:22
par vurvur
Avec transparence:
Code : Tout sélectionner
EnableExplicit
InitSprite()
InitKeyboard()
Enumeration
#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_PixelCollision)
wall = CreateSprite(#PB_Any,50,400, #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)
DisplayTransparentSprite(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()) : DrawingMode(#PB_2DDrawing_Transparent ) : 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
Re: Flappy
Publié : mer. 15/févr./2017 11:41
par JohnJohnsonSHERMAN
Exellent
Pt'être un peu facile??

Enfin, il ne manque plus que quelques skins et c'est bon, Flappy Bird 2 est là

Re: Flappy
Publié : mer. 15/févr./2017 11:56
par vurvur
JohnJohnsonSHERMAN a écrit :Exellent
Pt'être un peu facile??

Enfin, il ne manque plus que quelques skins et c'est bon, Flappy Bird 2 est là

Suffit de demander
Maintenant avec difficulté croissante... Mon record: 44
Code : Tout sélectionner
EnableExplicit
InitSprite()
InitKeyboard()
Enumeration
#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_PixelCollision)
wall = CreateSprite(#PB_Any,50,400, #PB_Sprite_PixelCollision)
StartDrawing(SpriteOutput(flappy))
Circle(25,25,25,$0033CC)
Circle(35,25,5 ,$8899CC)
Circle(45,25,5 ,$8899CC)
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($CC3C3C)
If x < 25
x + 1
EndIf
y = A * Sin(2 * #PI / B * x)
flappyY + y
ForEach wall()
wall()\x = wall()\x - 6 - score / 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)
DisplayTransparentSprite(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()) : DrawingMode(#PB_2DDrawing_Transparent ) : DrawText(10,10,Str(score)) : StopDrawing()
EndIf
FlipBuffers()
Case #Kabooming
Debug "kaboom baby - " + score
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($CC3C3C)
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
Re: Flappy
Publié : mer. 15/févr./2017 12:53
par djes
Excellent

Re: Flappy
Publié : mer. 15/févr./2017 14:12
par Kwai chang caine
Ca commence à prendre forme

Re: Flappy
Publié : mer. 15/févr./2017 17:59
par Ar-S
Centrage du texte, embellissement du sprite et petite animation tant qu'on y est
Images + code :
http://share.ldvmultimedia.com/FlappyV3.zip
Code seule
Code : Tout sélectionner
EnableExplicit
InitSprite()
InitKeyboard()
UsePNGImageDecoder()
Enumeration
#Flapping
#Kabooming
#Attending
#T
EndEnumeration
Structure wall
x.i
y1.i
y2.i
pt.i
EndStructure
Global Count = 0, A = 10, B = 24, x = 18, framerate, pushed, window, wall, flappy, flappy1,flappy2, LenT, rnd, flappyY, event, lasty, GameStep = #Attending, y , score
Global NewList wall.wall()
Declare init()
Declare Flap()
window = OpenWindow(#PB_Any,0,0,900,500,"Flappy",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
AddWindowTimer(window,#T,100)
BindEvent(#PB_Event_Timer, @flap())
OpenWindowedScreen(WindowID(window),0,0,900,500)
wall = CreateSprite(#PB_Any,50,400, #PB_Sprite_PixelCollision)
flappy1 = LoadSprite(#PB_Any, "i1.png",#PB_Sprite_AlphaBlending|#PB_Sprite_PixelCollision)
flappy2 = LoadSprite(#PB_Any, "i2.png",#PB_Sprite_AlphaBlending|#PB_Sprite_PixelCollision)
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($CC3C3C)
If x < 25
x + 1
EndIf
y = A * Sin(2 * #PI / B * x)
flappyY + y
ForEach wall()
wall()\x = wall()\x - 6 - score / 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)
DisplayTransparentSprite(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()) : DrawingMode(#PB_2DDrawing_Transparent ) : DrawText(10,10,Str(score)) : StopDrawing()
EndIf
FlipBuffers()
Case #Kabooming
Debug "kaboom baby - " + score
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($CC3C3C)
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)
LenT = TextWidth("Space to Flapp !")
DrawText(450-(Lent/2),250,"Space to Flapp !",$000000)
StopDrawing()
FlipBuffers()
EndProcedure
Procedure Flap()
; Ar-S
Count+1
If count=1
flappy = flappy2
Else
flappy = flappy1
count = 0
EndIf
EndProcedure
Re: Flappy
Publié : mer. 15/févr./2017 18:55
par boby
Qu'est-ce que j'ai fait... XD Vous êtes de grand malades
Vurvur je n'arrive pas à voir la différence qui fait que la transparence fonctionne chez toi... Quelqu'un pourrait m'éclairer ?
J'ai pas trop eu le temps de bosser dessus mais j'en était rendu là avant de venir sur le forum, j'ai visiblement pas du tout comprendre...
Code : Tout sélectionner
InitSprite()
OpenWindow(0,0,0,500,500,"",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0),0,0,500,500)
TransparentSpriteColor(#PB_Default,$000000)
CreateSprite(0,50,50,#PB_Sprite_AlphaBlending)
StartDrawing(SpriteOutput(0))
Circle(25,25,25,$0000CC)
StopDrawing()
;TransparentSpriteColor(0,$000000)
Repeat
ClearScreen($cc0000)
DisplayTransparentSprite(0,250,250)
FlipBuffers()
Delay(1)
Until WindowEvent() = #PB_Event_CloseWindow
#Sprite The sprite to use. If #PB_Default is used, then the default color (black - RGB(0,0,0)) is changed to the new given one and all future loaded or created sprites will use this color as the transparent one.
Je suis en pure 5.51, je ne vois pas ce qui n'est pas bon...
Re: Flappy
Publié : mer. 15/févr./2017 19:57
par Ar-S
DisplaySprite(flappy,150,flappyY) => DisplayTransparentSprite(flappy,150,flappyY)
Re: Flappy
Publié : mer. 15/févr./2017 21:01
par boby
Bah ça je l'avais essayé, mais ça ne suffit pas, il y a visiblement quelque chose que j'ai loupé...