Mosaic + explosion
Publié : mer. 12/oct./2005 11:04
Vala un ptit code que j'ai fait histoire de m'amuser.
Il vous faut l'image compris dans le zip pour faire fonctionner le programme
Il suffit de le mettre dans le repertoire du code, on lance et on attends que ca se passe lol.
Appuyez sur ECHAP pour sortir du programme.
Voici l'image à prendre :
http://www.telegaga.com/pb/pingouin.zip
et voici le code
Bon le code n'est peut être pas optimisé mais j'aime bien l'effet.
J'attends vos commentaires ^^
Il vous faut l'image compris dans le zip pour faire fonctionner le programme

Appuyez sur ECHAP pour sortir du programme.
Voici l'image à prendre :
http://www.telegaga.com/pb/pingouin.zip
et voici le code
Code : Tout sélectionner
;Effet mosaic + explosion
;Initialisation des composants
InitSprite()
InitKeyboard()
InitMouse()
UseJPEGImageDecoder()
;Constantes
#Pingouin = 0
;Variables Globales
Global Mosaic
;Création de la fenêtre principale
SetRefreshRate(60)
MaFenetre = OpenScreen(800,600,32,"Test")
If MaFenetre = 0
MessageRequester("Erreur", "Impossible d'ouvrir une fenêtre DirectX", #PB_MessageRequester_Ok)
EndIf
;Chargement des images
LoadSprite(#Pingouin,"pingouin.jpg")
;Creation de la structure
Structure Morceau
x.f
y.f
sourcex.f
sourcey.f
Explox.f
Exploy.f
EndStructure
NewList Ping.Morceau()
;Procedures du programme
Procedure Mosaic()
For posx = 0 To 400 Step 8
For posy = 0 To 300 Step 8
AddElement(Ping())
Ping()\x = posx + 200
Ping()\y = posy + 150
Ping()\sourcex = Sourcex
Ping()\sourcey = Sourcey
Ping()\Explox = Random(30) - 15
Ping()\Exploy = Random(30) - 15
Sourcey = Sourcey + 8
Next
Sourcex = sourcex + 8
Sourcey = 0
Next
EndProcedure
Procedure AfficheExplo()
ResetList(Ping())
While NextElement(Ping())
Ping()\x = Ping()\x + Ping()\Explox
Ping()\y = Ping()\y + Ping()\Exploy
ClipSprite(0,Ping()\sourcex,Ping()\sourcey,8,8)
DisplaySprite(0,Ping()\x,Ping()\y)
If Ping()\x > 800 Or Ping()\x < 0 Or Ping()\y > 600 Or Ping()\y < 0
DeleteElement(Ping())
EndIf
Wend
EndProcedure
Procedure AfficheMos()
ResetList(Ping())
While NextElement(Ping())
ClipSprite(0,Ping()\sourcex,Ping()\sourcey,8,8)
DisplaySprite(0,Ping()\x,Ping()\y)
Wend
EndProcedure
Procedure AfficheCrack()
ResetList(Ping())
While NextElement(Ping())
a = Random(4) - 2
b = Random(4) - 2
Ping()\x = Ping()\x + a
Ping()\y = Ping()\y + b
ClipSprite(0,Ping()\sourcex,Ping()\sourcey,8,8)
DisplaySprite(0,Ping()\x,Ping()\y)
Wend
EndProcedure
Mosaic()
AfficheMos()
FlipBuffers()
Delay(2500)
AfficheCrack()
StartDrawing(ScreenOutput())
BackColor(0,0,0)
FrontColor(255,255,255)
Locate(300,500)
DrawText("Attention ca va péter !")
StopDrawing()
FlipBuffers()
Delay(2000)
Repeat
ClearScreen(0,0,0)
AfficheExplo()
ExamineKeyboard()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)
J'attends vos commentaires ^^