Re: Birthday PurePunch
Publié : sam. 19/sept./2015 17:06
VIVEMENT que je matte ca de mes propres yeuxMicheao a écrit :je travail sur un Birthday PurePunch pour le concours

VIVEMENT que je matte ca de mes propres yeuxMicheao a écrit :je travail sur un Birthday PurePunch pour le concours
j'ai commencer à crée mon BackGround et j'ai codé une fenetre pour commencerSPH a écrit :VIVEMENT que je matte ca de mes propres yeuxMicheao a écrit :je travail sur un Birthday PurePunch pour le concours
Et bien si. Tu es même obligé de tout mettre dans un fichier compressé car la règle stipule qu'il est possible d'utiliser plusieurs images et un fichier sons.Spock a écrit :en principe, on ne devrai pas etre obligé de telecharger un fichier Zip pour acceder a ton prg
@Micheao : Ne met pas l'exe dans ton zip. Met le source PB stpExtrait de la régle a écrit :Seules les fichiers "Image" max 1920x1080 autorisés, ainsi qu'un fichier "musical" reconnu nativement par PureBasic (ogg/mp3/wav/xm/s3m/mod) 1Mo max.
Mercifalsam a écrit :Et bien si. Tu es même obligé de tout mettre dans un fichier compressé car la règle stipule qu'il est possible d'utiliser plusieurs images et un fichier sons.Spock a écrit :en principe, on ne devrai pas etre obligé de telecharger un fichier Zip pour acceder a ton prg@Micheao : Ne met pas l'exe dans ton zip. Met le source PB stpExtrait de la régle a écrit :Seules les fichiers "Image" max 1920x1080 autorisés, ainsi qu'un fichier "musical" reconnu nativement par PureBasic (ogg/mp3/wav/xm/s3m/mod) 1Mo max.
Code : Tout sélectionner
;*****************************************************************************
;*
;* Birthday Punch : PureBasic 15 years of happiness
;* PureBasic 5.xx
;* 192 lines of 80 chars of code or data as you want
;*
;* Name : Michaeo
;* Author : Jean-Bernard
;* Date : 22/09/2015
;* Notes :
;*
;*****************************************************************************
EnableExplicit
UseJPEGImageDecoder()
InitSprite()
InitMouse()
InitKeyboard()
InitMovie()
InitSound()
Enumeration
#Main_Form
#Open
#Music
#Sound
EndEnumeration
Global Close_Main,ScreenW.i=800,ScreenH.i=600,x.i,y.i,fond
x.i=ScreenW + 34
y.i=Int(ScreenH/2)
LoadImage(0,"Data/Images/Bouton.jpg")
LoadImage(1,"Data/Images/Lettre.jpg")
LoadSound(#Sound,"Data/Sound/Sound.wav")
Procedure Carte()
If OpenScreen(ScreenW,ScreenH,32,"Carte Anniversaire")
LoadMovie(#Music, "Data/Sound/Happy.mp3")
PlayMovie(#Music,#Null)
;Sprite de fond
LoadSprite(1,"Data/Images/Background.jpg") ; création du sprite
;Sprite défilant
CreateSprite(0,225,64,#PB_Sprite_AlphaBlending)
StartDrawing(SpriteOutput(0))
DrawingMode(#PB_2DDrawing_AlphaChannel)
Box(0,0,225,64,RGBA(0,0,0,0))
DrawingMode(#PB_2DDrawing_AlphaBlend)
DrawText(5,10,"Bon Anniversaire PureBasic.... ",RGBA(255,255,255,255),RGBA(0,0,0,0));
StopDrawing()
Repeat
DisplaySprite(1, 0, 0)
DisplayTransparentSprite(0, X, Y, 255)
ExamineKeyboard()
ExamineMouse()
x-2
If x<-225 ;Largeur du sprite
x=ScreenWidth()
EndIf
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or MouseButton(#PB_MouseButton_Left)
EndIf
End
EndProcedure
Procedure Message()
If OpenWindow(#Main_Form,0,0,579,386,"VOUS AVEZ UN MESSAGE ",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
ImageGadget(#Open,270, 215, 5 ,5, ImageID(0))
ImageGadget(1, 5, 0, 570 ,386, ImageID(1))
EndIf
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
Select EventGadget()
Case #Open:
PlaySound(#Sound)
carte()
EndSelect
Case #PB_Event_CloseWindow
Close_Main =#True
EndSelect
Until Close_Main
EndProcedure
Message()
Code : Tout sélectionner
Structure e:px.d:py.d:vx.f:vy.f:ml.b:mr.b:og.b:j.b:jh.f:tx.l:ty.l:lx.f:ly.f
EndStructure:Macro mm(v,i,j):If v < i : v = i : EndIf:If v > j : v = j :EndIf
EndMacro:Macro kp(k):KeyboardPushed(k):EndMacro:Macro di(i):
DrawImage(ImageID(i):EndMacro:Macro dai(i):DrawAlphaImage(ImageID(i):EndMacro
RandomSeed(15081982):Structure tile:id.l:collide.l:autotile.b:time.l:clock.l
take.b:EndStructure:Structure pt:px.f:py.f:ox.f:oy.f:v.f:a.f:t.f:ttl.l
EndStructure:Global NewList p.pt():Global NewList d.pt():UsePNGImageDecoder()
LoadImage(0,"sheet.png"):Global Dim level.tile(512,128)
Global Dim foreground.tile(512,128):Global Dim Background.tile(512,128)
Global NewList ennemy.e():StartDrawing(ImageOutput(0)):For y = 0 To 127
For x = 0 To 511:If Point(x,y) = $FFFFFF:level(x,y)\collide = 1
level(x,y)\autotile = 1:EndIf:If Point(x,y) = $FF0000:level(x,y)\collide = 2
level(x,y)\autotile = 0:level(x,y)\id = 256:EndIf:If Point(x,y) = $00FF00
level(x,y)\collide = 3:level(x,y)\autotile = 0:level(x,y)\id = 258:EndIf
If Point(x,y) = $FFFF00:level(x,y)\collide = 4:level(x,y)\autotile = 0
level(x,y)\id = 259:EndIf:If Point(x,y) = $00FFFF:level(x,y)\collide = 5
level(x,y)\autotile = 0:level(x,y)\id = 260:EndIf:If Point(x,y) = $FFFF80
level(x,y)\autotile = 0:level(x,y)\id = 300:EndIf:If Point(x,y) = $FF8080
level(x,y)\autotile = 0:level(x,y)\collide = 6:level(x,y)\id = 301:EndIf
If Point(x,y) = $FF00FF:AddElement(ennemy()):ennemy()\px = (x*32)+16
ennemy()\py = (y*32)+16:ennemy()\ml = 1:EndIf:If Point(x+512,y) = $FF
Background(x,y)\autotile = 1:EndIf:Next:Next:StopDrawing()
GrabImage(0,1,0,600,640,480):For i = 0 To 15:GrabImage(0,16+i,gx,128,32,32)
GrabImage(0,64+i,gx,128+32,32,32):gx+32:Next:GrabImage(0,256,0,256,32,32)
GrabImage(0,257,32,256,32,32):GrabImage(0,258,64,256,32,32)
GrabImage(0,259,96,256,32,32):GrabImage(0,300,608,224,32,32)
GrabImage(0,301,608,192,32,32):For i = 0 To 6
GrabImage(0,302+i,640+(i*32),192,32,32):Next:For i = 0 To 5
GrabImage(0,260+i,i*32,300,32,32):GrabImage(0,266+i,i*32,332,32,32):Next:gx=0
For i = 0 To 14:GrabImage(0,32+i,gx,192,32,32):gx+32:Next:gx=0:For i = 0 To 18
GrabImage(0,128+i,gx,192+32,32,32):gx+32:Next:GrabImage(0,512,379,944,1,1)
GrabImage(0,513,374,910,1,1):For y = 0 To 127:For x = 0 To 511
If level(x,y)\autotile:tile_value.l = 0
If y-1 =>0 : If level(x,y-1)\autotile = 1 : tile_value + 1 : EndIf : EndIf
If y+1 <128 : If level(x,y+1)\autotile = 1 : tile_value + 4 : EndIf : EndIf
If x-1 =>0 : If level(x-1,y)\autotile = 1 : tile_value + 8 : EndIf : EndIf
If x+1 <512 : If level(x+1,y)\autotile = 1 : tile_value + 2 : EndIf : EndIf
level(x,y)\id = 16+tile_value:EndIf:If Background(x,y)\autotile:tile_value.l = 0
If y-1 =>0 : If Background(x,y-1)\autotile = 1 : tile_value + 1 : EndIf : EndIf
If y+1 <128 : If Background(x,y+1)\autotile = 1 : tile_value + 4 : EndIf : EndIf
If x-1 =>0 : If Background(x-1,y)\autotile = 1 : tile_value + 8 : EndIf : EndIf
If x+1 <512 : If Background(x+1,y)\autotile = 1 : tile_value + 2 : EndIf : EndIf
Background(x,y)\id = 64+tile_value:EndIf:lid = level(x,y)\id:If lid = 16+15
id = Random(25):If id<15 : foreground(x,y)\id = 32+id : EndIf:EndIf
If y-1>=0 And ((lid=14+16) Or (lid=6+16) Or (lid=12+16)):id = Random(25)
If id<19 : foreground(x,y-1)\id = 128+id : EndIf:EndIf:Next:Next
InitSprite() : InitKeyboard():ExamineDesktops():Macro ww: With : EndMacro
OpenScreen(DesktopWidth(0),DesktopHeight(0),32,""):CreateSprite(0,320,240)
Player.e:Player\og = #False:Player\px = 6*32:Player\py = 70*32:Player\lx = 6*32
Player\ly = 70*32:deltatime.f = 0:ox.f=0:oy.f=0:jumpFlag.b=1:While 1
TimeCapture = ElapsedMilliseconds():ExamineKeyboard():If(kp(#PB_Key_Escape)):End
EndIf:With Player
If(kp(#PB_Key_Right)) : \mr = #True : EndIf
If(kp(#PB_Key_Left)) : \ml = #True : EndIf
If(kp(#PB_Key_Space)) And \og And jumpFlag ::\j = #True:jumpFlag+1:jumpFlag%2
EndIf:If Not kp(#PB_Key_Space):jumpFlag = 1:EndIf:If \mr And kp(#PB_Key_Right)
\vx + 768 * deltatime:ElseIf \mr And Not kp(#PB_Key_Right):\vx - 512 * deltatime
If \vx < 0:\vx =0:\mr = #False:EndIf:EndIf:If \ml And kp(#PB_Key_Left)
\vx - 768 * deltatime:ElseIf \ml And Not kp(#PB_Key_Left):\vx + 512 * deltatime
If \vx > 0:\vx =0:\ml = #False:EndIf:EndIf:\tx = ((\px)) / 32:\ty = ((\py)) / 32
mm(\tx,0,511):mm(\ty,0,127):by = (\py+16) / 32:If by>127 : by=127 : EndIf
If by<0 : by=0: EndIf:For i = -4 To 4 Step 4:bx = ((\px)+i) / 32
If(level(bx,by)\collide=1 And Not \j):\og = #True:\vy = 0:\py = (by*32)-4-16
ElseIf(level(\tx,by)\collide = 0 And Not \j):\og = #False
ElseIf(level(\tx,by)\collide = 2 And Not \j):\og = #False
ElseIf (level(bx,by)\collide = 3 And Not \j):\px = \lx:\py = \ly:\vy = 0:\vx = 0
\ml = 0:\mr = 0:\og = #True:\tx = 0:\ty = 0:Break:EndIf:byy = (\py) / 32
If(level(\tx, byy )\collide=2 And Not \j):jumpFlag = 0:\jh = 768:\og = #False
\j = #True:level(\tx,by)\time = ElapsedMilliseconds()+500:EndIf:Next
by = (\py-16) / 32:If by<0 : by=0 : EndIf:If(level(\tx,by)\collide=1 And \j)
\j = #False:\jh = 0:\vy = 0:\py = ((by*32)+16+4):EndIf
If(level(\tx,by)\collide=4 And \j):\px = \lx:\py = \ly:\vy = 0:\vx = 0:\ml = 0
\mr = 0:\og = #True:\tx = 0:\ty = 0:\j = #False:\jh = 0:EndIf:bx = (\px+8) / 32
mm(bx,0,511)
If(level(bx,\ty)\collide>=1 And level(bx,\ty)\collide<5 And \mr=#True):\vx = 0
\mr = #False:If level(bx,\ty)\collide=2 And \og=#True:\px = (bx*32)-16-4-0.1
ElseIf level(bx,\ty)\collide<>2:\px = (bx*32)-16-4-0.1:EndIf:EndIf
bx = (\px-8) / 32:mm(bx,0,511)
If(level(bx,\ty)\collide>=1 And level(bx,\ty)\collide<5 And \ml=#True):\vx = 0
\ml = #False:If level(bx,\ty)\collide=2 And \og=#True:\px = (bx*32)+16+4+0.1
ElseIf level(bx,\ty)\collide<>2:\px = (bx*32)+16+4+0.1:EndIf:EndIf
If level(\tx,\ty)\collide=5:level(\tx,\ty)\take = 1:level(\tx,\ty)\id = 266
level(\tx,\ty)\collide=0:EndIf
If level(\tx,\ty)\collide=6 And level(\tx,\ty)\take = 0:level(\tx,\ty)\take = 1
level(\tx,\ty)\id = 302:\lx = \tx*32:\ly = \ty*32:EndIf:If \j And \og:\jh = 512
\og = #False:EndIf:If Not \og And \jh = 0:\vy + 1500 * deltatime:EndIf:If \j
\vy=-\jh:\jh - 1024 * deltatime:If \jh < 0:\j = #False:\jh = 0:\vy = 0:EndIf
EndIf:mm(\vx,-192,192):mm(\vy,-1024,1024):\px + \vx * deltatime
\py + \vy * deltatime:ox = (-\px) + 160:oy = (-\py) + 120:If ox>0 : ox=0 : EndIf
If oy>0 : oy=0 : EndIf:sx = ((\px)/32)-10:sy = ((\py)/32)-7
DD = 25 + 75 * Cos(ElapsedMilliseconds()/100)+75:If t<ElapsedMilliseconds()
t=ElapsedMilliseconds()+ DD:For i = 0 To 10:AddElement(p())
p()\ox = 381-Random(5)+Random(5):p()\oy = 341-Random(5)+Random(5)
p()\a = Random(70):p()\v = 50+Random(150)
p()\ttl = ElapsedMilliseconds() + 10000:AddElement(d())
d()\ox = 381-Random(5)+Random(5):d()\oy = 341-Random(5)+Random(5)
d()\a = (-135+Random(90))-180:d()\v = 50+Random(150)
d()\ttl = ElapsedMilliseconds() + 5000:Next:EndIf:EndWith:ForEach p() : With p()
\px = \ox + (\v*Cos((360-\a)*#PI/180)* \t)
\py = \oy + (\v*Sin((360-\a)*#PI/180)* \t)+(0.5*90.81*(\t*\t))
\t + 0.25 * deltatime:If(\ttl<ElapsedMilliseconds()):DeleteElement(p(),1)
Continue:EndIf:Next : EndWith:ForEach d() : With d()
\px = \ox + (\v*Cos((360-\a)*#PI/180)* \t)
\py = \oy + (\v*Sin((360-\a)*#PI/180)* \t)+(0.5*9.81*(\t*\t))
\t + 0.25 * deltatime:If(\ttl<ElapsedMilliseconds()):DeleteElement(d(),1)
Continue:EndIf:Next: EndWith:ForEach ennemy():ennemy()\tx=(ennemy()\px-12)/32
ennemy()\ty=(ennemy()\py-12)/32:lid = level(ennemy()\tx+1,ennemy()\ty+1)\id
If ennemy()\mr And (lid = 30 Or lid = 24 Or lid = 18 Or lid=28 Or lid=22)
ennemy()\vx = 24:Else:ennemy()\ml=1:ennemy()\mr=0:EndIf
lid = level(ennemy()\tx-1,ennemy()\ty+1)\id
If ennemy()\ml And (lid = 30 Or lid = 24 Or lid = 18 Or lid=28 Or lid=22)
ennemy()\vx = -24:Else:ennemy()\ml=0:ennemy()\mr=1:EndIf
ennemy()\px + ennemy()\vx * deltatime:Next:For y = 0 To 127:For x = 0 To 511
If level(x,y)\collide = 2:If level(x,y)\clock < ElapsedMilliseconds()
level(x,y)\clock = ElapsedMilliseconds() + 60:level(x,y)\id+1
If level(x,y)\id = 258:level(x,y)\id = 256:EndIf:EndIf
If level(x,y)\time < ElapsedMilliseconds():level(x,y)\id = 256:EndIf:EndIf
If level(x,y)\collide = 5
If level(x,y)\clock < ElapsedMilliseconds() And level(x,y)\take = 0
level(x,y)\clock = ElapsedMilliseconds() + 60:level(x,y)\id+1
If level(x,y)\id = 266:level(x,y)\id = 260:EndIf:EndIf:EndIf
If level(x,y)\collide = 0 And level(x,y)\take = 1
If level(x,y)\clock < ElapsedMilliseconds()
level(x,y)\clock = ElapsedMilliseconds() + 20:level(x,y)\id+1
If level(x,y)\id = 272:level(x,y)\id = 0:level(x,y)\collide = 0
level(x,y)\take = 0:EndIf:EndIf:EndIf:If level(x,y)\collide = 6
If level(x,y)\clock < ElapsedMilliseconds() And level(x,y)\take = 1
level(x,y)\clock = ElapsedMilliseconds() + 60:level(x,y)\id+1
If level(x,y)\id = 309:level(x,y)\id = 302:EndIf:EndIf:EndIf:Next:Next
With Player
ClearScreen(0):StartDrawing(SpriteOutput(0)):Box(0,0,640,480,0)
srx.i = ox/10:srx%640:sry = (oy * 480)/4096:If sry<-240 : sry = -240 : EndIf
di(1),srx,sry):di(1),640+srx,sry):di(1),-640+srx,sry):ForEach p()
di(512),p()\px+srx,p()\py+sry):di(512),640+p()\px+srx,p()\py+sry)
di(512),-640+p()\px+srx,p()\py+sry):Next:ForEach d()
di(513),d()\px+srx,d()\py+sry):di(513),640+d()\px+srx,d()\py+sry)
di(513),-640+d()\px+srx,d()\py+sry):Next:For y = sy To sy+15:For x = sx To sx+20
If x>=0 And x<512 And y>=0 And y<128:If Background(x,y)\autotile = 1
dai(Background(x,y)\id),((x*32)+ox)-16,((y*32)+oy)-16):EndIf:EndIf:Next:Next
ForEach ennemy():Box((ennemy()\px-24)+ox, (ennemy()\py-24)+oy,24,24,$FF00FF)
Next:For y = sy To sy+15:For x = sx To sx+20
If x>=0 And x<512 And y>=0 And y<128:If level(x,y)\id <>0
dai(level(x,y)\id),((x*32)+ox)-16,((y*32)+oy)-16):EndIf:EndIf:Next:Next
For y = sy To sy+15:For x = sx To sx+20:If x>=0 And x<512 And y>=0 And y<128
If foreground(x,y)\id <>0:dai(foreground(x,y)\id),((x*32)+ox)-16,((y*32)+oy)-16)
EndIf:EndIf:Next:Next:Box((\px-4)+ox, (\py-4)+oy,8,8,Random($FFFFFF))
StopDrawing():EndWith:ZoomSprite(0,1680,1050):DisplaySprite(0,0,0):FlipBuffers()
deltatime = (ElapsedMilliseconds() - TimeCapture) / 1000:Wend
Pas du tout, la différence réside déjà dans la gestion de la map , ici , c'est de l'autotilling, pas dans Flam & les déplacements sont plus smooth aussi , et l'anim du perso n'existe pas encore.TazNormand a écrit :Dis donc G-Rom, ce ne serait pas un condensé de "Flam", ça ?