Page 1 sur 1

[Jeu] Sugar

Publié : mar. 13/déc./2011 14:35
par djes
Un de plus ! Dédidace spéciale à Elodie W. qui m'a donné le concept de ce mini-jeu intégré à PureBreaker 3... A télécharger là : http://djes.free.fr/purebasic/minigames/ ou là : https://docs.google.com/open?id=0B5nDvK ... RlNTliZjdh

Voici le code incomplet pour archive :

Code : Tout sélectionner

;****************************************************************************************************** 
;* 
;* PUREBR3AKER (c)BGAMES 2005
;* Lead coder : djes@free.fr - http://djes.free.fr
;* 
;* http://www.shootingcrew.com/ 
;* 
;****************************************************************************************************** 

DebugLevel 2

#CREATEPACKS = #True

XIncludeFile "packlib_release.pbi"

;****************************************************************************************************** 
;- *** CONSTANTS *** 
;****************************************************************************************************** 

;- Games sprites
Enumeration #PB_Compiler_EnumerationValue Step 1
	#SUGAR_BALLOON_BLUE
	#SUGAR_BALLOON_CYAN
	#SUGAR_BALLOON_YELLOW
	#SUGAR_BALLOON_ROSE
	#SUGAR_BALLOON_RED
	#SUGAR_BALLOON_GREEN
	#SUGAR_ANNEAU
	#SUGAR_BISCUIT
	#SUGAR_BISCUIT2
	#SUGAR_BONBON_EMBALL
	#SUGAR_CHOCO
	#SUGAR_GEL
	#SUGAR_GEL2
	#SUGAR_GEL3
	#SUGAR_GEL4
	#SUGAR_LOUKOUM
	#SUGAR_TEDDY_BLUE
	#SUGAR_TEDDY_YELLOW
	#SUGAR_TEDDY_ROSE
	#SUGAR_TEDDY_RED
	#SUGAR_TEDDY_GREEN
	#SUGAR_REGLISSE
	#SUGAR_REGLISSE2
	#SUGAR_REGLISSE3
	#SUGAR_REGLISSE4
	#SUGAR_REGLISSE5
	#SUGAR_REGLISSE6
	#SUGAR_SNAKE
	#SUGAR_SUCETTE
	#SUGAR_SUCETTE2
	#SUGAR_SUCETTE3
	#SUGAR_STAR
	#SUGAR_ARROW
	#SUGAR_BALL
	#SUGAR_CLAC
EndEnumeration

;- Sprites Fonts
Enumeration #PB_Compiler_EnumerationValue Step 256
  #SILVERFONT
EndEnumeration

;- Sounds
Enumeration 
  #M2EXPLOSION
  #EXTRALIFE
  #NEXTLEVELSND
  #CREDITS
  #CLOCK
  #TOC
EndEnumeration

;****************************************************************************************************** 
;- *** STRUCTURES *** 
;****************************************************************************************************** 

Structure SugarBalloon
	x.f
	y.l
	XSpeed.f
	SpriteNB.l
	Candy.l
	BalloonCandyFlag.l
EndStructure

Structure Anim
  x.f
  XSpeed.f
  y.f
  YSpeed.f
  Zoom.f
  Zoom_speed.f
  CurrentSpriteNB.f
  AnimSpeed.f
  FirstSprite.l
  LastSprite.l
  CurrentFade.f
  FadeSpeed.f
  CurrentTime.l
  Duration.l	;in frames
  PauseIn.l		;before Anim start
  PauseOut.l	;after Anim
EndStructure

;****************************************************************************************************** 
;- *** GLOBALS *** 
;****************************************************************************************************** 

Global Dim SilverFont.l(255)
Global NewList Anims.anim()

Global ScreenWidth = 1024
Global ScreenHeight = 768
Global ScreenDepth = 32
Global RefreshRate = 60
Global IngameMusic
Global IngameSound

;****************************************************************************************************** 
;- *** PROCEDURES *** 
;****************************************************************************************************** 

Procedure.i RealRound(nb.f)
  !cvtss2si eax, [p.v_nb]
  ProcedureReturn
EndProcedure

Procedure.f Radians(angle.f)
;!FLDPI

 ProcedureReturn (angle * 2.0 * #PI) / 360.0
EndProcedure

Procedure.f Lenght(x1.f, y1.f, x2.f, y2.f)
  Protected Result.f
  Result = Sqr( (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) )
  ProcedureReturn Result
EndProcedure

;****************************************************************************************************** 

Procedure LoadMidi(Nb, file.s)
  i = mciSendString_("open " + file.s + " type sequencer alias mid" + Str(Nb), 0, 0, 0)
  ProcedureReturn i
EndProcedure
Procedure PlayMidi(Nb)
  i = mciSendString_("play mid" + Str(Nb), 0, 0, 0)
  ProcedureReturn i
EndProcedure
Procedure StopMidi(Nb)
  i = mciSendString_("stop mid" + Str(Nb), 0, 0, 0)
  ProcedureReturn i
EndProcedure
Procedure FreeMidi(Nb)
  i = mciSendString_("close mid" + Str(Nb), 0, 0, 0)
  ProcedureReturn i
EndProcedure
Procedure SetMidivolume(Nb, volume)
  i = mciSendString_("set volume" + Str(Nb) + " volume " + Str(volume), 0, 0, 0)
  ProcedureReturn i
EndProcedure

;****************************************************************************************************** 
;Draw an Animated screen centered text
Procedure CenteredText(text.s, PauseIn.l)
  
  xs = 0 + ScreenWidth / 2 - ((Len(text) - 1) * 40) / 2
  ys = 0 + ScreenHeight / 2 - 19
  
  For u = 1 To Len(text)
    
    AddElement(Anims())
    Anims()\x = xs
    Anims()\XSpeed = 0
    Anims()\y = ys
    Anims()\YSpeed = 2
    Anims()\CurrentSpriteNB = #SILVERFONT + Asc(Mid(text, u, 1))
    Anims()\AnimSpeed = 0
    Anims()\CurrentTime = - PauseIn
    Anims()\Duration = 85 ;(255 / 3)
    Anims()\CurrentFade = 255
    Anims()\FadeSpeed = - 3
    Anims()\PauseIn = 1.5 * RefreshRate
    Anims()\PauseOut = 0
    Anims()\Zoom = 1
    Anims()\Zoom_speed = 0
    
    AddElement(Anims())
    Anims()\x = xs
    Anims()\XSpeed = 0
    Anims()\y = ys
    Anims()\YSpeed = - 2
    Anims()\CurrentSpriteNB = #SILVERFONT + Asc(Mid(text, u, 1))
    Anims()\AnimSpeed = 0
    Anims()\CurrentTime = - PauseIn
    Anims()\Duration = 85 ;(255 / 3)
    Anims()\CurrentFade = 255
    Anims()\FadeSpeed = - 3
    Anims()\PauseIn = 1.5 * RefreshRate
    Anims()\PauseOut = 0
    Anims()\Zoom = 1
    Anims()\Zoom_speed = 0
    xs + 40
    
  Next u
  
EndProcedure

Procedure TextXY(text.s, x.l, y.l)
  
  For u = 1 To Len(text)
    s.l = #SILVERFONT + Asc(Mid(text, u, 1))
    ZoomSprite3D(s, 64, 64)
    RotateSprite3D(s, 0, 0)
    DisplaySprite3D(s, x, y)
    x + 32
  Next u
  
EndProcedure

;****************************************************************************************************** 
;play specified Sound specifying parameters
Procedure MyPlaySound(Sound.l, pan.l = - 1, volume.l = - 1, frequency.l = - 1)
  If IngameSound
    If pan<> - 1
      SoundPan(Sound, pan)
    EndIf
    If volume<> - 1
      SoundVolume(Sound, volume)
    EndIf
    If frequency<> - 1
      SoundFrequency(Sound, frequency)
    EndIf
    PlaySound(Sound, #PB_Sound_MultiChannel)
  EndIf
EndProcedure

;****************************************************************************************************** 

Procedure GameLoading()
  
  PackInit("packs/sugar.pak")

  Media$ = ""
	PackLoadSprite3D(#SUGAR_ANNEAU, Media$ + "gfx/anneau.png")
	PackLoadSprite3D(#SUGAR_BALLOON_BLUE, Media$ + "gfx/ballon_bleu.png")
	PackLoadSprite3D(#SUGAR_BALLOON_CYAN, Media$ + "gfx/ballon_cyan.png")
	PackLoadSprite3D(#SUGAR_BALLOON_YELLOW, Media$ + "gfx/ballon_jaune.png")
	PackLoadSprite3D(#SUGAR_BALLOON_ROSE, Media$ + "gfx/ballon_rose.png")
	PackLoadSprite3D(#SUGAR_BALLOON_RED, Media$ + "gfx/ballon_rouge.png")
	PackLoadSprite3D(#SUGAR_BALLOON_GREEN, Media$ + "gfx/ballon_vert.png")
	PackLoadSprite3D(#SUGAR_BISCUIT, Media$ + "gfx/biscuit.png")
	PackLoadSprite3D(#SUGAR_BISCUIT2, Media$ + "gfx/biscuit2.png")
	PackLoadSprite3D(#SUGAR_BONBON_EMBALL, Media$ + "gfx/bonbon_emballe.png")
	PackLoadSprite3D(#SUGAR_CHOCO, Media$ + "gfx/choco.png")
	PackLoadSprite3D(#SUGAR_GEL, Media$ + "gfx/gel.png")
	PackLoadSprite3D(#SUGAR_GEL2, Media$ + "gfx/gel2.png")
	PackLoadSprite3D(#SUGAR_GEL3, Media$ + "gfx/gel3.png")
	PackLoadSprite3D(#SUGAR_GEL4, Media$ + "gfx/gel4.png")
	PackLoadSprite3D(#SUGAR_LOUKOUM, Media$ + "gfx/loukoum.png")
	PackLoadSprite3D(#SUGAR_TEDDY_BLUE, Media$ + "gfx/nounours_bleu.png")
	PackLoadSprite3D(#SUGAR_TEDDY_YELLOW, Media$ + "gfx/nounours_jaune.png")
	PackLoadSprite3D(#SUGAR_TEDDY_ROSE, Media$ + "gfx/nounours_rose.png")
	PackLoadSprite3D(#SUGAR_TEDDY_RED, Media$ + "gfx/nounours_rouge.png")
	PackLoadSprite3D(#SUGAR_TEDDY_GREEN, Media$ + "gfx/nounours_vert.png")
	PackLoadSprite3D(#SUGAR_REGLISSE, Media$ + "gfx/reglisse.png")
	PackLoadSprite3D(#SUGAR_REGLISSE2, Media$ + "gfx/reglisse2.png")
	PackLoadSprite3D(#SUGAR_REGLISSE3, Media$ + "gfx/reglisse3.png")
	PackLoadSprite3D(#SUGAR_REGLISSE4, Media$ + "gfx/reglisse4.png")
	PackLoadSprite3D(#SUGAR_REGLISSE5, Media$ + "gfx/reglisse5.png")
	PackLoadSprite3D(#SUGAR_REGLISSE6, Media$ + "gfx/reglisse6.png")
	PackLoadSprite3D(#SUGAR_SNAKE, Media$ + "gfx/serpent.png")
	PackLoadSprite3D(#SUGAR_SUCETTE, Media$ + "gfx/sucette.png")
	PackLoadSprite3D(#SUGAR_SUCETTE2, Media$ + "gfx/sucette2.png")
	PackLoadSprite3D(#SUGAR_SUCETTE3, Media$ + "gfx/sucette3.png")
	PackLoadSprite3D(#SUGAR_STAR, Media$ + "gfx/star.png")
	PackLoadSprite3D(#SUGAR_ARROW, Media$ + "gfx/fleche.png")
	PackLoadSprite3D(#SUGAR_BALL, Media$ + "gfx/balle.png")
	PackLoadSprite3D(#SUGAR_CLAC, Media$ + "gfx/clac.png")

  n.l = 1
  For u = Asc("A") To Asc("Z")
    SilverFont(u) = n
    n + 1
  Next u
  SilverFont(Asc("!")) = n : n + 1
  SilverFont(Asc("'")) = n : n + 1
  SilverFont(Asc("(")) = n : n + 1
  SilverFont(Asc(")")) = n : n + 1
  SilverFont(Asc(" - ")) = n : n + 1
  SilverFont(Asc(".")) = n : n + 1
  SilverFont(Asc("?")) = n : n + 1
  SilverFont(Asc(":")) = n : n + 1
  SilverFont(Asc("0")) = n : n + 1
  SilverFont(Asc("1")) = n : n + 1
  SilverFont(Asc("2")) = n : n + 1
  SilverFont(Asc("3")) = n : n + 1
  SilverFont(Asc("4")) = n : n + 1
  SilverFont(Asc("5")) = n : n + 1
  SilverFont(Asc("6")) = n : n + 1
  SilverFont(Asc("7")) = n : n + 1
  SilverFont(Asc("8")) = n : n + 1
  SilverFont(Asc("9")) = n : n + 1
  SilverFont(Asc(", ")) = n : n + 1
  SilverFont(Asc(" ")) = n : n + 1
  
  For u = 0 To 255
    If SilverFont(u)<>0
      PackLoadSprite3D(#SILVERFONT + u, "gfx/fonts/silver/silver-" + StrU(SilverFont(u), #PB_Byte) + ".png")
    EndIf
  Next u
  
  ClosePack()
  
  PackName = "packs/Sounds.pak"
  PackCounter = 0 
  
  PackLoadSound(#M2EXPLOSION, "sfx/m2fire.wav")
  PackLoadSound(#EXTRALIFE, "sfx/HAPPYBEL.WAV")
  PackLoadSound(#NEXTLEVELSND, "sfx/Sound827.WAV")
  PackLoadSound(#CLOCK, "sfx/inter.WAV")
  PackLoadSound(#TOC, "sfx/bounce1.wav")
  ClosePack()
  
EndProcedure

;****************************************************************************************************** 

Procedure FullScreenCheck()
  If IngameMusic
    StopMidi(1) 
  EndIf
  
  ReleaseMouse(1)
  CloseScreen()
  
  OpenWindow(0, 0, 0, 256, 256, "Sugar", #PB_Window_Minimize)
  
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_ActivateWindow
  
  CloseWindow(0)
  OpenScreen(ScreenWidth, ScreenHeight, ScreenDepth, "Ducks")
  ReleaseMouse(0)
  
  GameLoading()
  
  If IngameMusic
    playMidi(1) 
  EndIf
EndProcedure

;****************************************************************************************************** 
;- *** INIT ***
;****************************************************************************************************** 

UsePNGImageDecoder()
UseTIFFImageDecoder()
UseJPEGImageDecoder()
UseOGGSoundDecoder()

If (InitSprite() And InitSprite3D() And InitKeyboard() And InitMouse() And InitSound()) = #False
  End
EndIf

Define.f LaunchXSpeed, LaunchYSpeed

OpenScreen(ScreenWidth, ScreenHeight, ScreenDepth, "Sugar", #PB_Screen_WaitSynchronization, RefreshRate)

Sprite3DQuality(1)

;****************************************************************************************************** 
;- *** MAIN *** 
;****************************************************************************************************** 

START_SUGAR:

Global NewList SugarBalloons.SugarBalloon()

SugarScore = 20
Speedup.f = 1
Launched = #False
SugarArrowDirection.f = 0
SugarBallX.f = 0
SugarBallY.f = 0
ExplosionX = 0
ExplosionY = 0
ExplosionDuration = 0
SugarWin = #False
IngameMusic = #True

GameLoading()

If IngameMusic
  LoadMidi(1, "packs\elephant.pak")
  SetMidivolume(1, 150)
  PlayMidi(1)
EndIf

ClearList(Anims())
CenteredText("MINIGAME !", 2 * RefreshRate)

Repeat	

  If Not IsScreenActive()
    FullScreenCheck()   
  Else
    Gosub INPUTS
    Gosub GAME_LOGIC
  EndIf
  
  If SugarScore = 50 And SugarWin = #False
    Lives + 1
    MyPlaySound(#EXTRALIFE, 0, 100, 20000)
    SugarWin = #True
  EndIf
  
	FlipBuffers()
	FrameCounter + 1
	
Until Quit = 1 Or SugarScore = 0

ClearList(Anims())

Quit = 0

If IngameMusic
  
  StopMidi(1)  ;stop la lecture
  FreeMidi(1) ;libere la ram

EndIf

If SugarWin = #False And IngameSound
  MyPlaySound(#NEXTLEVELSND)
  Delay(3000)
EndIf

End

;****************************************************************************************************** 
;- *** SUBROUTINES *** 
;****************************************************************************************************** 

;****************************************************************************************************** 
;- INPUTS
INPUTS:
  	ExamineKeyboard()
  	ExamineMouse()
  
    If JoystickSwitch
      joyGetPosEx_(#JOYSTICKID1, joyInfoEx.JOYINFOEX)
    EndIf
  
  	If KeyboardReleased(#PB_Key_J)
      JoystickSwitch = ~JoystickSwitch
    EndIf
  	
  	If KeyboardReleased(#PB_Key_Escape)
  		Quit = 1
  	EndIf
  
  	If KeyboardReleased(#PB_Key_S)
  		u = GrabSprite(#PB_Any, 0, 0, 1024, 768)
  		SaveSprite(u, "c:\screenshot.bmp")
  	EndIf
  
  	If mb = #True And (MouseButton(1) = 0 Or ((joyInfoEx\dwButtons&1 = 0) And JoystickSwitch))
  		;évite la répétition
  		mb = #False
  	EndIf
  
  	If (MouseButton(1) Or KeyboardReleased(#PB_Key_Return) Or ((joyInfoEx\dwButtons&1) And JoystickSwitch)) And mb = #False And Launched = #False
  		Launched = #True
      MyPlaySound(#M2EXPLOSION)
;     Beep_(1000, 2)
  		mb = #True
  		LaunchXSpeed.f = 16 * Cos(Radians(SugarArrowDirection) + #PI / 2 + #PI)
  		LaunchYSpeed.f = 16 * Sin(Radians(SugarArrowDirection) + #PI / 2 + #PI)
  	EndIf
  	
  	      ;Joystick or mouse control
      If KeyboardPushed(#PB_Key_Left) 
        KeyXSpeed - 1
      ElseIf KeyboardPushed(#PB_Key_Right) 
        KeyXSpeed + 1
      Else
        KeyXSpeed / 2
      EndIf

      If JoystickSwitch
        If JoyXamp<>0
          u = RealRound((joyInfoEx\dwXpos - (JoyXamp / 2)) / 2048)  ;this little operation to optimise precision
          SugarArrowDirection = SugarArrowDirection + ((u * 2048) * 32) / JoyXamp
        EndIf
      Else
        SugarArrowDirection = SugarArrowDirection + MouseDeltaX() + KeyXSpeed
      EndIf
    Return

;****************************************************************************************************** 
;- ANIMATIONS_DISPLAY
;Multi purposes (why not for explosions? maybe later ;)

ANIMATIONS_DISPLAY:

  Sprite3DQuality(1)
  
  With Anims()
    ;If FirstElement(Anims())<>0
    ;ResetList(Anims())
    ForEach Anims()
      If \CurrentTime<\Duration
        
        ;hint to start displaying after a while : make CurrentTime negative
        If \CurrentTime<0
          
          \CurrentTime + 1
          
        Else
          
          u = \CurrentSpriteNB
          sw.f = \Zoom * SpriteWidth(u)
          sh.f = \Zoom * SpriteHeight(u)
          ZoomSprite3D(u, sw, sh)
          DisplaySprite3D(u, \x - sw / 2, \y - sh / 2, \CurrentFade)
          ;DisplaySprite3D(u, \x - SpriteWidth(u) / 2, \y - SpriteHeight(u) / 2, \CurrentFade)
          
          ;pause before Anim?
          If \PauseIn = 0
            
            ;anim
            \CurrentSpriteNB + \AnimSpeed
            If \LastSprite<>\FirstSprite
              ;if sprite is Animated, and for a certain amount of frames, test boundaries
              If \CurrentSpriteNB>\LastSprite
                \CurrentSpriteNB = \FirstSprite
              EndIf
            EndIf
            \CurrentFade + \FadeSpeed
            \CurrentTime + 1
            \x + \XSpeed
            \y + \YSpeed
            \Zoom + \Zoom_speed
          Else
            \PauseIn - 1
          EndIf
          
        EndIf
        
      Else
        If \PauseOut<>0
          ;pause after Anim?
          u = \CurrentSpriteNB
          sw.f = \Zoom * SpriteWidth(u)
          sh.f = \Zoom * SpriteHeight(u)
          ZoomSprite3D(u, sw, sh)
          DisplaySprite3D(u, \x - sw / 2, \y - sh / 2, \CurrentFade)
          ;DisplaySprite3D(u, \x - SpriteWidth(u) / 2, \y - SpriteHeight(u) / 2, \CurrentFade)
          \PauseOut - 1
        Else
          ;no, delete
          DeleteElement(Anims())
        EndIf
      EndIf
      ;EndIf
    Next
  EndWith

Return

;****************************************************************************************************** 
;-GAME_LOGIC

GAME_LOGIC:

  	;new BALLOON
  	If FrameCounter%(RefreshRate * 4) = 0
  		AddElement(SugarBalloons())
  		SugarBalloons()\y = 128 + Random(128)
  		SugarBalloons()\SpriteNB = #SUGAR_BALLOON_BLUE + Random(5)
  		SugarBalloons()\Candy = #SUGAR_ANNEAU + Random(24)
  		SugarBalloons()\BalloonCandyFlag = 1 ;BALLOON + Candy
  		If Random(10)<5
  			SugarBalloons()\x = - SpriteWidth(#SUGAR_BALLOON_BLUE) / 2
  			SugarBalloons()\XSpeed = 0.5
  		Else
  			SugarBalloons()\x = 1023 + SpriteWidth(#SUGAR_BALLOON_BLUE) / 2
  			SugarBalloons()\XSpeed = - 0.5
  		EndIf
  	EndIf
  
  	;every 30 secs, Speedup
  	If FrameCounter%(RefreshRate * 30) = 0
  		Speedup + 0.05
  	EndIf
  	 
  	ClearScreen($F0BEF3)
  
  	If Start3D()
  
  		Gosub ANIMATIONS_DISPLAY
  
  		For y = 32 To 767 Step 256
  			For x = 0 To 1023 + 128 Step 128
  				DisplaySprite3D(#SUGAR_STAR, x + StarX, y + 20 * Sin((x + StarX + FrameCounter) / 128), 32 + y / 8)
  				RotateSprite3D(#SUGAR_STAR, FrameCounter, 0)
  			Next x
  		Next y
  		For y = 32 + 128 To 767 Step 256
  			For x = 0 To 1023 + 255 Step 128
  				DisplaySprite3D(#SUGAR_STAR, 1023 + 64 - x - StarX, y + 20 * Sin((x + StarX + FrameCounter) / 128), 32 + y / 8)
  				RotateSprite3D(#SUGAR_STAR, FrameCounter, 0)
  			Next x
  		Next y
  		StarX = (StarX - 4)%128
  
  		;déplace les BALLOONs et gère les collisions BALLOONs et Candys
  		ForEach SugarBalloons()
  			Select SugarBalloons()\BalloonCandyFlag
  			;BALLOON + Candy
  			Case 1
  				SugarBalloons()\x = SugarBalloons()\x + SugarBalloons()\XSpeed * Speedup
  				If SugarBalloons()\x> = (1024 + SpriteWidth(#SUGAR_BALLOON_BLUE) / 2 + 2) Or SugarBalloons()\x<( - SpriteWidth(#SUGAR_BALLOON_BLUE) / 2 - 2)
  					DeleteElement(SugarBalloons(), 1)
  				Else
  					ZoomSprite3D(SugarBalloons()\SpriteNB, SpriteWidth(#SUGAR_BALLOON_BLUE) + 10 * Sin(SugarBalloons()\x / 64), SpriteHeight(#SUGAR_BALLOON_BLUE) + 10 * Sin(SugarBalloons()\x / 64))
  					RotateSprite3D(SugarBalloons()\SpriteNB, 10 * Sin(SugarBalloons()\x / 32), 0)
  					SugarXB.f = SugarBalloons()\x
  					SugarYB.f = SugarBalloons()\y + 32 * Sin(SugarBalloons()\x / 64)
  					DisplaySprite3D(SugarBalloons()\SpriteNB, SugarXB - SpriteWidth(#SUGAR_BALLOON_BLUE) / 2, SugarYB - SpriteHeight(#SUGAR_BALLOON_BLUE) / 2, 230)
  					ZoomSprite3D(SugarBalloons()\Candy, SpriteWidth(SugarBalloons()\Candy) + 10 * Sin(SugarBalloons()\x / 64), SpriteHeight(SugarBalloons()\Candy) + 10 * Sin(SugarBalloons()\x / 64))
  					RotateSprite3D(SugarBalloons()\Candy, 10 * Sin(SugarBalloons()\x / 64), 0)
  					CandyX = SugarXB + 60 * Cos(Radians(10 * Sin(SugarBalloons()\x / 32)) + #PI / 2)
  					CandyY = SugarYB + 60 * Sin(Radians(10 * Sin(SugarBalloons()\x / 32)) + #PI / 2)
  					DisplaySprite3D(SugarBalloons()\Candy, CandyX - SpriteWidth(SugarBalloons()\Candy) / 2, CandyY - SpriteHeight(SugarBalloons()\Candy) / 2)
  					If Launched
  						If Lenght(CandyX, CandyY, SugarBallX, SugarBallY)<32
  							ExplosionX = CandyX
  							ExplosionY = CandyY
  							ExplosionDuration = 5
  							SugarBalloons()\BalloonCandyFlag = 2 ;plus de Candy!
                MyPlaySound(#TOC, -1, -1, 2500 )
  							SugarScore - 5
  							Launched = #False
  						ElseIf Lenght(SugarXB, SugarYB, SugarBallX, SugarBallY)<64
  							ExplosionX = SugarXB
  							ExplosionY = SugarYB
  							ExplosionDuration = 5
  							SugarBalloons()\x = CandyX	;position du Candy						
  							SugarBalloons()\y = CandyY 
  							SugarBalloons()\BalloonCandyFlag = 3 ;plus de BALLOON!
                MyPlaySound(#TOC, -1, -1, 5000 )
  							Launched = #False
  						EndIf
  					EndIf
  				EndIf
  
  			;BALLOON
  			Case 2
  				SugarBalloons()\x = SugarBalloons()\x + SugarBalloons()\XSpeed * Speedup
  				SugarBalloons()\y - 1 ;le BALLOON remonte
  				If SugarBalloons()\x> = (1024 + SpriteWidth(#SUGAR_BALLOON_BLUE) / 2 + 2) Or SugarBalloons()\x<( - SpriteWidth(#SUGAR_BALLOON_BLUE) / 2 - 2) Or SugarBalloons()\y< = - 64
  					DeleteElement(SugarBalloons(), 1)
  				Else
  					ZoomSprite3D(SugarBalloons()\SpriteNB, SpriteWidth(#SUGAR_BALLOON_BLUE) + 10 * Sin(SugarBalloons()\x / 64), SpriteHeight(#SUGAR_BALLOON_BLUE) + 10 * Sin(SugarBalloons()\x / 64))
  					RotateSprite3D(SugarBalloons()\SpriteNB, 10 * Sin(SugarBalloons()\x / 32), 0)
  					SugarXB.f = SugarBalloons()\x
  					SugarYB.f = SugarBalloons()\y + 32 * Sin(SugarBalloons()\x / 64)
  					DisplaySprite3D(SugarBalloons()\SpriteNB, SugarXB - SpriteWidth(#SUGAR_BALLOON_BLUE) / 2, SugarYB - SpriteHeight(#SUGAR_BALLOON_BLUE) / 2, 230)
  					If Launched
  						If Lenght(SugarXB, SugarYB, SugarBallX, SugarBallY)<64
  							DeleteElement(SugarBalloons()) ;plus rien!
                MyPlaySound(#TOC, -1, -1, 5000 )
  							ExplosionX = SugarXB
  							ExplosionY = SugarYB
  							ExplosionDuration = 5
  							Launched = #False
  							SugarScore + 5
  						EndIf
  					EndIf
  				EndIf
  
  			;Candy
  			Case 3
  				SugarBalloons()\y * 1.01 ;le Candy chute
  				If SugarBalloons()\y> = 768
  					DeleteElement(SugarBalloons(), 1)
  					SugarScore + 10
  				Else
  					CandyX = SugarBalloons()\x
  					CandyY = SugarBalloons()\y
  					DisplaySprite3D(SugarBalloons()\Candy, CandyX - SpriteWidth(SugarBalloons()\Candy) / 2, CandyY - SpriteHeight(SugarBalloons()\Candy) / 2)
  					If Launched
  						If Lenght(CandyX, CandyY, SugarBallX, SugarBallY)<32
  							DeleteElement(SugarBalloons(), 1) ;plus rien!
  							SugarScore - 5
                MyPlaySound(#TOC, -1, -1, 2500 )
  							ExplosionX = CandyX
  							ExplosionY = CandyY
  							ExplosionDuration = 5
  							Launched = #False
  						EndIf
  					EndIf
  				EndIf
  
  			EndSelect
  		Next
   
  		RotateSprite3D(#SUGAR_ARROW, SugarArrowDirection, 0)
  		DisplaySprite3D(#SUGAR_ARROW, 512 - SpriteWidth(#SUGAR_ARROW) / 2, 705 - SpriteHeight(#SUGAR_ARROW) / 2)
  		If Launched = #False
  			SugarBallX.f = 512 + 48 * Cos(Radians(SugarArrowDirection) + #PI / 2)
  			SugarBallY.f = 705 + 48 * Sin(Radians(SugarArrowDirection) + #PI / 2)
  			DisplaySprite3D(#SUGAR_BALL, SugarBallX - SpriteWidth(#SUGAR_BALL) / 2, SugarBallY - SpriteHeight(#SUGAR_BALL) / 2)
  		Else
  			SugarBallX = SugarBallX + LaunchXSpeed
  			SugarBallY = SugarBallY + LaunchYSpeed
  			If SugarBallX< = 0 Or SugarBallX> = 1023
  				LaunchXSpeed * - 1
  			EndIf
  			If SugarBallY< = 0 Or SugarBallY> = 767
  				Launched = #False
  			EndIf
  			DisplaySprite3D(#SUGAR_BALL, SugarBallX - SpriteWidth(#SUGAR_BALL) / 2, SugarBallY - SpriteHeight(#SUGAR_BALL) / 2)
  		EndIf
  
  		If ExplosionDuration>0
  			ExplosionDuration - 1
  			DisplaySprite3D(#SUGAR_CLAC, ExplosionX - SpriteWidth(#SUGAR_CLAC) / 2, ExplosionY - SpriteHeight(#SUGAR_CLAC) / 2)
  		EndIf
  
  		TextXY(Str(SugarScore), 900 - Len(Str(SugarScore)) * 32 / 2, 768 - 100)
  
  		Stop3D()
  
  	EndIf
  
  Return

Re: [Jeu] Sugar

Publié : mar. 13/déc./2011 16:40
par Kwai chang caine
Rigolo ce jeu :D
Et pour une fois j'ai tout compris tout de suite...enfin presque :?
Au debut je tirais sur la "bouftance" et les "beloune" y montaient et pas de points :oops:

Mais je me suis vite repris...et j'ai du prendre 10 kilos :lol:
Je suppose que c'est un jeu fait pour les personnes de mon age :mrgreen:

En tout cas merci, pour ce joli cadeau 8)

Re: [Jeu] Sugar

Publié : mar. 13/déc./2011 17:52
par Ar-S
ouééé sympa ! merci pour le partage !

Re: [Jeu] Sugar

Publié : mar. 13/déc./2011 21:56
par flaith
Merci djes :D
Tirer sur les ballons avec une flêche, ca me rappelle pooyan sur Apple :wink:

Re: [Jeu] Sugar

Publié : mar. 13/déc./2011 22:00
par djes
Tiens, je ne connaissais pas, mais c'est bien sympa :)