PoussPouss

Programmation avancée de jeux en PureBasic
Avatar de l’utilisateur
SPH
Messages : 4726
Inscription : mer. 09/nov./2005 9:53

Re: PoussPouss

Message par SPH »

venom a écrit :Ah !!! Il faut faire tous les items pour voir le score ? ou juste 1 item comme sur mon screen ?
Tous

C'est long a finir (j'ai mis plus de 23 minutes !) :idea:
http://HexaScrabble.com/
!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Intel Core i7 4770 64 bits - GTX 650 Ti
Version de PB : 6.00 - 64 bits
Avatar de l’utilisateur
SPH
Messages : 4726
Inscription : mer. 09/nov./2005 9:53

Re: PoussPouss

Message par SPH »

Tiens, j'ai mis un timer en bas de l'ecran (ca t'aidera à voir si tu me bat sur 1 serie (j'en fait une en 1 minute 20 environ))

Code : Tout sélectionner

; PB 5.70LTS x86
;
; Code : SPH
; Codé le 1 mai 2020
; (c)2020
;
; Mon score : 1419 secondes pour tout finir =)


If InitSprite() = 0
  MessageRequester("Erreur", "Impossible d'ouvrir l'écran & l'environnement nécessaire aux sprites !", 0)
  End
EndIf
If InitMouse() = 0
  MessageRequester("Erreur", "Impossible d'activer la souris !", 0)
  End
EndIf
If InitKeyboard() = 0
  MessageRequester("Erreur", "Impossible d'activer le clavier !", 0)
  End
EndIf

LoadFont(1000, "Arial", 18)
LoadFont(1001, "Arial", 30)


OpenWindow(0, 0, 0, 1024, 768+30, "PoussPouss", #PB_Window_ScreenCentered)

OpenWindowedScreen(WindowID(0), 0, 0, 1024, 768+30)

LoadSprite(0,"bmp/pointeur.bmp")
LoadSprite(1,"bmp/pilone.bmp")
LoadSprite(2,"bmp/mur.bmp")
LoadSprite(3,"bmp/trou.bmp")
LoadSprite(4,"bmp/vide.bmp")

For i=100 To 208
  LoadSprite(i,"bmp/"+Str(i)+".bmp")
Next
;;;
Dim n(108)
For i=0 To 108
  n(i)=i+100
Next
For i=1 To 2000
  Swap n(Random(108)),n(Random(108))
Next

x=0
nb=0
Dim p(15,11)
For u=0 To 11
  For i=0 To 15
    p(i,u)=n(x) : nb+1
    If nb>8
      nb=0
      x+1
    EndIf
  Next
Next
For i=4 To 12
  p(i,11)=2
Next
p(13,11)=1
p(14,11)=1
p(15,11)=3
;;;
For i=1 To 2000
  Swap p(Random(15),Random(11)),p(Random(15),Random(11))
Next

Dim x(1)
Dim y(1)

ClearScreen(RGB(0,15,26))
DisplaySprite(1,350,390)
DisplaySprite(2,350,470)
StartDrawing(ScreenOutput())
DrawingFont(FontID(1001))
BackColor(RGB(0,15,26))
DrawText(400,150,"PoussPouss", RGB(255,0,0))
DrawText(100,300,"Alignez entre les pylônes neuf items identiques", RGB(255,255,255))
DrawText(450,403,"Un pylône", RGB(255,255,255))
DrawText(450,483,"Un mur inamovible", RGB(255,255,255))

DrawingFont(FontID(1000))
BackColor(RGB(0,15,26))
DrawText(440,640,"Code : SPH", RGB(60,60,60))
DrawText(406,672,"HexaScrabble.com", RGB(60,60,60))
StopDrawing()
FlipBuffers()

Repeat
  Delay(1)
  ExamineMouse() ; Etat de la souris
 
Until MouseButton(1)=1


;*****************************************************************************************************
;*****************************************************************************************************
;*****************************************************************************************************
time=ElapsedMilliseconds()
;*****************************************************************************************************
;*****************************************************************************************************
;*****************************************************************************************************

Repeat
 
  While WindowEvent():Wend  ;<<-----------------------------
  
  ClearScreen(RGB(0,15,26))
  ;;;
  ExamineMouse() ; Etat de la souris
  xm = MouseX()  ; Position en x de la souris                     
  ym = MouseY()  ; Position en y de la souris
                 ;;;
  xx=xm/64
  yy=ym/64
  
 If yy<12
  If MouseButton(1)=1 And p(xx,yy)<>2
    If xx>0
      If p(xx-1,yy)=3
        Swap p(xx,yy),p(xx-1,yy)
      EndIf
    EndIf
    If xx<15
      If p(xx+1,yy)=3
        Swap p(xx,yy),p(xx+1,yy)
      EndIf
    EndIf
    If yy>0
      If p(xx,yy-1)=3
        Swap p(xx,yy),p(xx,yy-1)
      EndIf
    EndIf
    If yy<11
      If p(xx,yy+1)=3
        Swap p(xx,yy),p(xx,yy+1)
      EndIf
    EndIf
   
   
    nb=0
    For u=0 To 11
      For i=0 To 15
        If p(i,u)=1
          x(nb)=i
          y(nb)=u
          nb+1
        EndIf
      Next
    Next
   
   
    If (Abs(x(0)-x(1))=10 And Abs(y(0)-y(1))=0)
      If x(0)>x(1)
        Swap x(0),x(1)
      EndIf
      nb=0
      kel=p(x(0)+1,y(0))
      For i=x(0)+1 To x(1)-1
        If p(i,y(0))=kel
          nb+1
        EndIf
        ;;;       
      Next
      If nb=9 And kel<>4
        For i=x(0)+1 To x(1)-1
          p(i,y(0))=4             
        Next
        total+1
        If total=20
          Goto fin
        EndIf
      EndIf   
    EndIf
   
    If Abs(y(0)-y(1))=10 And Abs(x(0)-x(1))=0
      If y(0)>y(1)
        Swap y(0),y(1)
      EndIf
      nb=0
      kel=p(x(0),y(0)+1)
      For i=y(0)+1 To y(1)-1
        If p(x(0),i)=kel
          nb+1
        EndIf
        ;;;       
      Next
      If nb=9 And kel<>4
        For i=y(0)+1 To y(1)-1
          p(x(0),i)=4             
        Next
        total+1
        If total=20
          Goto fin
        EndIf
       
      EndIf   
     
    EndIf
   
  EndIf
  EndIf
 
  For u=0 To 11
    For i=0 To 15
      DisplaySprite(p(i,u),i*64,u*64)
    Next
  Next
  
  
  ;;;;;;;;;;;;;;;
StartDrawing(ScreenOutput())
DrawingFont(FontID(1000))
BackColor(RGB(0,15,26))
DrawText(30,770,Str((ElapsedMilliseconds()-time)/1000)+" secondes", RGB(255,0,255))
StopDrawing()
;;;;;;;;;;;;;;;;
  
  DisplayTransparentSprite(0,xm,ym)
 
  FlipBuffers()
  Delay(1)
  ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)

End

;#############
;#############
;#############
;#############
;#############


fin:
ClearScreen(RGB(0,15,26))
StartDrawing(ScreenOutput())
DrawingFont(FontID(1001))
BackColor(RGB(0,15,26))
DrawText(400,200,"Félicitations", RGB(255,0,0))
DrawText(300,400,"Tu as mis "+Str((ElapsedMilliseconds()-time)/1000)+" secondes", RGB(255,255,255))
DrawText(370,448,"pour finir le jeu...", RGB(255,255,255))
StopDrawing()
FlipBuffers()

Repeat
  While WindowEvent():Wend  ;<<-----------------------------
 
  Delay(1)
  ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
End
http://HexaScrabble.com/
!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Intel Core i7 4770 64 bits - GTX 650 Ti
Version de PB : 6.00 - 64 bits
Répondre