autre Space invalideur

Programmation avancée de jeux en PureBasic
Avatar de l’utilisateur
graph100
Messages : 1318
Inscription : sam. 21/mai/2005 17:50

autre Space invalideur

Message par graph100 »

voila voila un autre jeu

Code : Tout sélectionner

;- bullet
Structure bullet
  x.l
  y.l
  a.l
  b.l
  arm.l
  type.l
EndStructure

;- pointfloat
Structure pointfloat
  x.f
  y.f
EndStructure

;- star
Structure star
  x.l
  y.l
  lum.l
  sens.l
EndStructure

Case_depart :

;- police
Global FontID1
FontID1 = LoadFont(1, "Arial", 36, #PB_Font_Underline)
Global FontID2
FontID2 = LoadFont(2, "Bookman Old Style", 18)
Global FontID3
FontID3 = LoadFont(3, "Arial", 12, #PB_Font_Underline)
Global FontID4
FontID4 = LoadFont(4, "Bookman Old Style", 16)

Procedure SaveHightScore(filename.s, score, niveau, podium) ; sauvegarde le score et le niveau des x meilleurs dans un fichier
  Protected place, a, score, podium, filename, name.s, niveau
  If OpenFile(0, filename)
    
    Dim nom.s(podium)
    Dim score.s(podium)
    Dim niveau.s(podium)
    
    place = 0
    
    For a = 1 To podium
      nom(a) = ReadString()
      score(a) = ReadString()
      niveau(a) = ReadString()
      If score > Val(score(a)) And place = 0
        place = a
      EndIf
      If score(a) = "" : score(a) = "0" : EndIf
      If niveau(a) = "" : niveau(a) = "0" : EndIf
    Next
    
    CloseFile(0)
    
    If place <> 0
      name.s = InputRequester("Vous êtes " + Str(place) + " ème", "Entrez votre nom", "")
      For a = podium To 1 Step -1
        If a = place
          nom(a) = name
          score(a) = Str(score)
          niveau(a) = Str(niveau)
        EndIf
        If a > place
          nom(a) = nom(a - 1)
          score(a) = score(a - 1)
          niveau(a) = niveau(a - 1)
        EndIf
      Next
      
      If CreateFile(0, filename)
        For a = 1 To podium
          WriteStringN(nom(a))
          WriteStringN(score(a))
          WriteStringN(niveau(a))
        Next
        CloseFile(0)
      EndIf
      
    EndIf
  EndIf
  
  ProcedureReturn place
EndProcedure

Procedure window0()
  If OpenWindow(0, 0, 0, 600, 300, #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered, "Space")
    If CreateGadgetList(WindowID())
      TextGadget(0, 140, 5, 320, 65, "Space Impact", #PB_Text_Center | #PB_Text_Border)
      SetGadgetFont(0, FontID1)
      TrackBarGadget(1, 5, 155, 590, 35, 0, 19, #PB_TrackBar_Ticks)
      TextGadget(2, 100, 105, 400, 35, "Selectionnez la difficulté:", #PB_Text_Center | #PB_Text_Border)
      SetGadgetFont(2, FontID2)
      TextGadget(3, 5, 190, 50, 20, "+ facile")
      SetGadgetFont(3, FontID3)
      TextGadget(4, 545, 190, 50, 20, "- facile")
      SetGadgetFont(4, FontID3)
      ButtonGadget(5, 165, 215, 270, 40, "Go")
      SetGadgetFont(5, FontID4)
    EndIf
  EndIf
  SetGadgetState(1, 9)
EndProcedure

window0()

Repeat
  event = WaitWindowEvent()
Until event = #pb_event_closewindow Or EventGadgetID() = 5

If event = #pb_event_closewindow : End : EndIf

difficult = GetGadgetState(1)
CloseWindow(0)

If InitMouse() = 0 Or InitSprite() = 0 Or InitKeyboard() = 0
  MessageRequester("Error", "Can't open DirectX 7", 0)
  End
EndIf

If OpenWindow(0, 0, 0, 640, 500, #PB_Window_ScreenCentered, "Space") And OpenWindowedScreen(WindowID(), 0, 20, 640, 480, 0, 0, 0) = 0
  MessageRequester("Attention", "l'ecran n'a pas pus être ouvert")
  End
EndIf

If CreateGadgetList(WindowID())
  TextGadget(0, 0, 0, 640, 20, "", #PB_Text_Center | #PB_Text_Border)
EndIf


For a = 0 To 1
  If a = 0 : Restore vaisseau : EndIf
  If a = 1 : Restore vaisseau1 : EndIf
  
  Read width
  Read height
  
  CreateSprite(a, width, height)
  
  If StartDrawing(SpriteOutput(a))
      For y2 = 0 To height - 1
        For x2 = 0 To width - 1
          Read color
          Plot(x2, y2, color)
        Next
      Next
    StopDrawing()
  EndIf
Next

TransparentSpriteColor(0, 0, 0, 0)
TransparentSpriteColor(1, 0, 0, 0)

;- init
autorise = 300 - 10 * difficult
az = 0
vie = 480
q = 40
s = 420
bullet = 0
bulletmoi = 0
vitbullet = 2 + difficult / 3
degat = 10
arme = 0
limitvitesse = difficult / 2 + 1
enfonc = 0
vitesse.pointfloat\x = 0
vitesse.pointfloat\Y = 0

Dim bullet.bullet(1010)
Dim bulletmoi.bullet(310)
Dim stars.star(1010)

star = 0
For a = 0 To 480 Step 2
  For b = 0 To 2
    stars(star)\x = Random(640)
    stars(star)\y = a
    stars(star)\lum = Random(255)
    stars(star)\sens = Random(11) - 6
    star = star + 1
  Next
Next

debut :
az = az + 1
az1.f = az * 2 / 10
If az1 = 0 : vitbullet = vitbullet + 1 : EndIf
DataSection
  niv1 :
    Data.l 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
    Data.l 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
    Data.l 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
  deplacement :
    Data.l - 1, 270, 270, -1, 270, -1
    Data.l 80, 80, -1, -1, 80, -1
EndDataSection

Dim vais(15, 3)
Dim deplacementx(6)
Dim deplacementy(6)

Restore niv1

For ligne = 1 To 3
  For colonne = 1 To 15
    Read z
    vais(colonne, ligne) = z * az
  Next
Next

Restore deplacement

For a = 1 To 6
  Read deplacementx(a)
Next
For a = 1 To 6
  Read deplacementy(a)
Next

a = -1
b = -150
c = 1
win = 0

Repeat
  event = WindowEvent()
  Delay(2)
  ExamineKeyboard()
  ClearScreen(0, 0, 0)
  restant = 0
  For g = 1 To 3
    For h = 1 To 15
      
      If vais(h, g) >= 1
        restant = restant + 1
        DisplayTransparentSprite(1, 24 * h + a - 20, 36 * g + b - 34)
        
        If Random(autorise) = 0 And bullet(bullet)\x = 0
          If Random(1) = 0
            bullet(bullet)\x = 24 * h + a - 10
            bullet(bullet)\y = 36 * g + b - 4
            bullet(bullet)\arm = 0
            bullet = bullet + 1
            If bullet >= 1001 : bullet = 1 : EndIf
          Else
            bullet(bullet)\x = 24 * h + a - 20
            bullet(bullet)\y = 36 * g + b - 4
            bullet(bullet)\arm = 1
            bullet = bullet + 1
            If bullet >= 1001 : bullet = 1 : EndIf
            If bullet(bullet)\x = 0
              bullet(bullet)\x = 24 * h + a
              bullet(bullet)\y = 36 * g + b - 4
              bullet(bullet)\arm = 1
              bullet = bullet + 1
              If bullet >= 1001 : bullet = 1 : EndIf
            EndIf
          EndIf
        EndIf
        
      EndIf
      
      ; explosion
      If vais(h, g) <= 0 And vais(h, g) > - 15
        If StartDrawing(ScreenOutput())
            For ae = 1 To 40
              Repeat
                xplot = 24 * h + a - 22 + Random(34)
                yplot = 36 * g + b - 36 + Random(34)
                xplota = (xplot - (24 * h + a - 11)) * (xplot - (24 * h + a - 11))
                yplota = (yplot - (36 * g + b - 20)) * (yplot - (36 * g + b - 20))
              Until Sqr(xplota + yplota) < 15
              Circle(xplot, yplot, 1, RGB(255, Random(255), 0))
            Next
          StopDrawing()
        EndIf
        vais(h, g) = vais(h, g) - 1
      EndIf
      
    Next
  Next
  
  viereste.f = (vie / 480) * 100
  SetGadgetText(0, "Niveau = " + Str(az) + "        Ennemis vaincus = " + Str(45 * az - restant) + "        Vie restante = " + Str(viereste) + "%")
  
  If StartDrawing(ScreenOutput())
      
      ;- fond etoile
      For z = 0 To 1000
        Circle(stars(z)\x, stars(z)\y, 1, RGB(stars(z)\lum, stars(z)\lum, stars(z)\lum))
        stars(z)\lum = stars(z)\lum + stars(z)\sens
        stars(z)\y = stars(z)\y + 2
        If stars(z)\y > 480
          stars(z)\x = Random(640)
          stars(z)\y = 0
        EndIf
        If stars(z)\lum > 248 Or stars(z)\lum < 7 : stars(z)\sens = -stars(z)\sens : EndIf
      Next
      
      ;- vie
      vert.f = ((vie / 480) * 255)
      Box(633, 480, 7, -vie, RGB(99, vert, 156))
      
      ;- tir moi
      For z = 1 To 300
        If bulletmoi(z)\x <> 0
          If bulletmoi(z)\type = 0
            Box(bulletmoi(z)\x - 1, bulletmoi(z)\y, 2, 2, RGB($FF, $28, $00))
            Box(bulletmoi(z)\x - 1, bulletmoi(z)\y + 2, 2, 2, RGB($FF, $6D, $00))
            Box(bulletmoi(z)\x - 1, bulletmoi(z)\y + 4, 2, 2, RGB($FF, $9E, $00))
          ElseIf bulletmoi(z)\type = 1
            DrawingMode(4)
            For ar = 1 To bulletmoi(z)\arm
              Ellipse(bulletmoi(z)\x - 1, bulletmoi(z)\y, ar / 2, ar, RGB(255, ar * 5, 0))
            Next
            DrawingMode(0)
          EndIf
          t.f = (-a + 20 + bulletmoi(z)\x) / 24
          y.f = (-b + 34 + bulletmoi(z)\y) / 36
          t1.l = t
          y1.l = y
          If t1 > 0 And y1 > 0 And t1 < 16 And y1 < 4 And bulletmoi(z)\type = 0
            If vais(t1, y1) > 0
              bulletmoi(z)\x = 0
              vais(t1, y1) = vais(t1, y1) - bulletmoi(z)\arm - 1
            EndIf
          ElseIf bulletmoi(z)\type = 1
            
          EndIf
          bulletmoi(z)\y = bulletmoi(z)\y + bulletmoi(z)\b
          bulletmoi(z)\x = bulletmoi(z)\x + bulletmoi(z)\a
        EndIf
        If bulletmoi(z)\y < - 2 Or bulletmoi(z)\x < 5 Or bulletmoi(z)\x > 650
          bulletmoi(z)\x = 0
        EndIf
      Next
      
      For z = 1 To 1000
        If bullet(z)\x <> 0
          Box(bullet(z)\x - 1, bullet(z)\y, 2, 2, RGB($00, $18, $FF))
          Box(bullet(z)\x - 1, bullet(z)\y - 2, 2, 2, RGB($00, $82, $FF))
          Box(bullet(z)\x - 1, bullet(z)\y - 4, 2, 2, RGB($00, $DF, $FF))
        EndIf
        If bullet(z)\x + 2 > q And bullet(z)\x - 2 < q + 19 And bullet(z)\y + 2 > s And bullet(z)\y - 2 < s + 29
          vie = vie - degat * (bullet(z)\arm + 1)
          bullet(z)\x = 0
          If vie <= 0
            mort = 45 * az - restant
            MessageRequester("Dommage", "Vous avez perdu")
          StopDrawing()
          win = 2
          Gosub perdu
        EndIf
      Else
        bullet(z)\y = bullet(z)\y + vitbullet
      EndIf
      If bullet(z)\y > 480
        bullet(z)\x = 0
      EndIf
      If win = 2 : Break : EndIf
    Next
    
    If restant = 0
      win = 1
    EndIf
    
  StopDrawing()
EndIf
DisplayTransparentSprite(0, q, s)
FlipBuffers()

;- deplacement ennemis
If b <= -2
  b = b + 2
Else
  e = deplacementx(c)
  f = deplacementy(c)
  If (a = e Or a = e + 1) And (b = f Or b = f + 1) : c = c + 1 : EndIf
  If c = 7 : c = 1 : EndIf
  If a <> e And a <> e + 1 : a = a + 2 * (Abs(e) / e) : EndIf
  If b <> f And b <> f + 1 : b = b + 2 * (Abs(f) / f) : EndIf
EndIf

;- deplacement
delai = delai - 1
If KeyboardPushed(#pb_key_left)
  If vitesse\x > - limitvitesse : vitesse\x = vitesse\x - 0.4 : EndIf
EndIf
If KeyboardPushed(#pb_key_right)
  If vitesse\x < limitvitesse : vitesse\x = vitesse\x + 0.4 : EndIf
EndIf
If KeyboardPushed(#pb_key_up)
  If vitesse\y > - limitvitesse : vitesse\y = vitesse\y - 0.4 : EndIf
EndIf
If KeyboardPushed(#pb_key_down)
  If vitesse\y < limitvitesse : vitesse\y = vitesse\y + 0.4 : EndIf
EndIf

q = q + vitesse\x
s = s + vitesse\y
If vitesse\x < 0 : vitesse\x = vitesse\x + 0.2 : EndIf
If vitesse\x > 0 : vitesse\x = vitesse\x - 0.2 : EndIf
If vitesse\y < 0 : vitesse\y = vitesse\y + 0.2 : EndIf
If vitesse\y > 0 : vitesse\y = vitesse\y - 0.2 : EndIf

If q < 5 : q = 5 : EndIf
If q > 600 : q = 600 : EndIf
If s < 250 : s = 250 : EndIf
If s > 445 : s = 445 : EndIf

If KeyboardPushed(#PB_Key_1) : arme = 0 : enfonc = 0 : EndIf
If KeyboardPushed(#PB_Key_2) : arme = 1 : enfonc = 0 : EndIf
If KeyboardPushed(#PB_Key_3) : arme = 2 : enfonc = 0 : EndIf
If KeyboardPushed(#PB_Key_4) : arme = 3 : enfonc = 0 : EndIf
If KeyboardPushed(#pb_key_space) = 0 And arme = 3 And enfonc <> 0
  If enfonc > 51 : enfonc = 51 : EndIf
  bulletmoi(bulletmoi)\x = q + 10
  bulletmoi(bulletmoi)\y = s
  bulletmoi(bulletmoi)\a = 0
  bulletmoi(bulletmoi)\b = -1.2 * vitbullet
  bulletmoi(bulletmoi)\arm = enfonc
  bulletmoi(bulletmoi)\type = 1
  enfonc = 0
  bulletmoi = bulletmoi + 1
  If bulletmoi >= 301 : bulletmoi = 1 : EndIf
EndIf
If KeyboardPushed(#pb_key_space) And bulletmoi(bulletmoi)\x = 0 And delai <= 0
  If arme = 0
    bulletmoi(bulletmoi)\x = q + 10
    bulletmoi(bulletmoi)\y = s
    bulletmoi(bulletmoi)\a = 0
    bulletmoi(bulletmoi)\b = -vitbullet
    bulletmoi(bulletmoi)\arm = 0
    bulletmoi = bulletmoi + 1
    If bulletmoi >= 301 : bulletmoi = 1 : EndIf
    delai = 5
  EndIf
  If arme = 1
    bulletmoi(bulletmoi)\x = q
    bulletmoi(bulletmoi)\y = s
    bulletmoi(bulletmoi)\a = 0
    bulletmoi(bulletmoi)\b = -vitbullet
    bulletmoi(bulletmoi)\arm = 1
    bulletmoi = bulletmoi + 1
    If bulletmoi >= 301 : bulletmoi = 1 : EndIf
    If bulletmoi(bulletmoi)\x = 0
      bulletmoi(bulletmoi)\x = q + 20
      bulletmoi(bulletmoi)\y = s
      bulletmoi(bulletmoi)\a = 0
      bulletmoi(bulletmoi)\b = -vitbullet
      bulletmoi(bulletmoi)\arm = 1
      bulletmoi = bulletmoi + 1
      If bulletmoi >= 301 : bulletmoi = 1 : EndIf
    EndIf
    delai = 5
  EndIf
  If arme = 2
    bulletmoi(bulletmoi)\x = q + 10
    bulletmoi(bulletmoi)\y = s
    bulletmoi(bulletmoi)\a = 0
    bulletmoi(bulletmoi)\b = -vitbullet
    bulletmoi(bulletmoi)\arm = 2
    bulletmoi = bulletmoi + 1
    If bulletmoi >= 301 : bulletmoi = 1 : EndIf
    If bulletmoi(bulletmoi)\x = 0
      bulletmoi(bulletmoi)\x = q + 10
      bulletmoi(bulletmoi)\y = s
      bulletmoi(bulletmoi)\a = -2
      bulletmoi(bulletmoi)\b = -vitbullet
      bulletmoi(bulletmoi)\arm = 2
      If bulletmoi >= 301 : bulletmoi = 1 : EndIf
      bulletmoi = bulletmoi + 1
    EndIf
    If bulletmoi(bulletmoi)\x = 0
      bulletmoi(bulletmoi)\x = q + 10
      bulletmoi(bulletmoi)\y = s
      bulletmoi(bulletmoi)\a = 2
      bulletmoi(bulletmoi)\b = -vitbullet
      bulletmoi(bulletmoi)\arm = 2
      bulletmoi = bulletmoi + 1
      If bulletmoi >= 301 : bulletmoi = 1 : EndIf
    EndIf
    delai = 5
  EndIf
  If arme = 3
    enfonc = enfonc + 1
  EndIf
EndIf

Until KeyboardPushed(#pb_key_escape) Or win <> 0

perdu :

If win = 2 Or KeyboardPushed(#pb_key_escape)
CloseScreen()
CloseWindow(0)

SaveHightScore("Space.pref", mort, az, 10)

If OpenWindow(1, 0, 0, 380, 390, #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered, "Space Meilleurs Scores") And CreateGadgetList(WindowID())
  If OpenFile(0, "Space.pref")
    TextGadget(1, 20, 20, 200, 17, "PLACE : NOM")
    TextGadget(1, 240, 20, 50, 17, "SCORE")
    TextGadget(1, 310, 20, 50, 17, "NIVEAU")
    For aze = 1 To 10
      TextGadget(0, 20, aze * 30 + 20, 200, 17, Str(aze) + "  :  " + ReadString(), #PB_Text_Border)
      TextGadget(0, 240, aze * 30 + 20, 50, 17, ReadString(), #PB_Text_Border | #PB_Text_Right)
      TextGadget(0, 310, aze * 30 + 20, 50, 17, ReadString(), #PB_Text_Border | #PB_Text_Right)
    Next
    CloseFile(0)
    ButtonGadget(4, 20, 350, 160, 20, "REJOUER")
    ButtonGadget(5, 200, 350, 160, 20, "QUITTER")
  EndIf
EndIf

Repeat
  event = WaitWindowEvent()
  If event = #pb_event_gadget
    Select EventGadgetID()
      Case 4
        CloseWindow(1)
        Gosub Case_depart
      Case 5
        End
    EndSelect
  EndIf
Until event = #pb_event_closewindow

End

EndIf

Gosub debut

Return


DataSection
vaisseau :
  Data.l 20, 30
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2697257, 0, 0, 0, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3224625, 0, 0, 0, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7563627, 0, 0, 0, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8680827, 0, 0, 0, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8680827, 0, 0, 0, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 1024, 8681860, 0, 0, 0, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 2169880, 9734796, 2697257, 0, 0, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 5392714, 16750228, 7563635, 0, 0, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 1052688, 8089971, 16764886, 8680827, 1052688, 0, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 4868426, 8680827, 16756397, 9207172, 8089979, 0, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 5920090, 7564659, 11377317, 11904685, 11377317, 0, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 526344, 2697257, 13023933, 4866370, 1052688, 0, 526344, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 1580056, 11379373, 3748913, 0, 0, 3749945, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 526344, 4340802, 8681860, 11378341, 1052688, 0, 4343106, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 1581097, 3748921, 3223601, 15692147, 10261140, 10262172, 2171937, 4868426, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 3225657, 3757411, 4339769, 2170913, 15179420, 9734804, 10854053, 9734796, 7037283, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 3748921, 6514027, 5927291, 4339769, 1053712, 7037283, 10261148, 11904685, 10851996, 10261148, 11904693, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 4867402, 6513003, 5399923, 3222577, 1024, 7561595, 9208460, 10261140, 9207172, 8681851, 11907765, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 1024, 1579032, 1581089, 1052688, 527368, 4866411, 4867402, 3222577, 2697257, 2170913, 526344, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 1024, 4342082, 8089971, 5919058, 0, 0, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 1024, 4867402, 9197923, 14059140, 10846852, 5921114, 0, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 527368, 4867394, 7036259, 14049635, 16748180, 14068397, 9208460, 3748921, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 1024, 4339769, 5920090, 6511971, 6510938, 6510938, 8681851, 8681860, 10260116, 8680836, 10851988, 4340802, 0, 0, 0, 0
  Data.l 0, 0, 0, 527384, 5392714, 6511971, 7563627, 7038315, 4340802, 3748913, 7563635, 8681860, 8088955, 8680827, 10262172, 9735836, 8089971, 8, 0, 0
  Data.l 0, 0, 0, 1024, 1580056, 3749945, 5393746, 5394770, 4340802, 1051664, 5393746, 7037283, 7563635, 7563635, 5394778, 5919058, 3223601, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 526344, 527368, 2170913, 6511971, 4866378, 1052688, 526344, 1024, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 1024, 5920090, 9734804, 9733780, 0, 0, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 1024, 7037283, 10853020, 10853029, 0, 0, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 1024, 1052688, 1024, 0, 0, 0, 0, 0, 0, 0, 0

vaisseau1 :
  Data.l 20, 30
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 1024, 1052688, 1024, 0, 0, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 1024, 7037283, 10853020, 10853029, 0, 0, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 1024, 5920090, 9734804, 9733780, 0, 0, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 526344, 527368, 2170913, 6511971, 4866378, 1052688, 526344, 1024, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 1024, 1580056, 3749945, 5393746, 5394770, 4340802, 1051664, 5393746, 7037283, 7563635, 7563635, 5394778, 5919058, 3223601, 0, 0, 0
  Data.l 0, 0, 0, 527384, 5392714, 6511971, 7563627, 7038315, 4340802, 3748913, 7563635, 8681860, 8088955, 8680827, 10262172, 9735836, 8089971, 8, 0, 0
  Data.l 0, 0, 0, 0, 1024, 4339769, 5920090, 6511971, 6510938, 6510938, 8681851, 8681860, 10260116, 8680836, 10851988, 4340802, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 527368, 4867394, 7036259, 14049635, 16748180, 14068397, 9208460, 3748921, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 1024, 4867402, 9197923, 14059140, 10846852, 5921114, 0, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 1024, 4342082, 8089971, 5919058, 0, 0, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 1024, 1579032, 1581089, 1052688, 527368, 4866411, 4867402, 3222577, 2697257, 2170913, 526344, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 4867402, 6513003, 5399923, 3222577, 1024, 7561595, 9208460, 10261140, 9207172, 8681851, 11907765, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 3748921, 6514027, 5927291, 4339769, 1053712, 7037283, 10261148, 11904685, 10851996, 10261148, 11904693, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 3225657, 3757411, 4339769, 2170913, 15179420, 9734804, 10854053, 9734796, 7037283, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 1581097, 3748921, 3223601, 15692147, 10261140, 10262172, 2171937, 4868426, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 526344, 4340802, 8681860, 11378341, 1052688, 0, 4343106, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 1580056, 11379373, 3748913, 0, 0, 3749945, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 526344, 2697257, 13023933, 4866370, 1052688, 0, 526344, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 5920090, 7564659, 11377317, 11904685, 11377317, 0, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 4868426, 8680827, 16756397, 9207172, 8089979, 0, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 1052688, 8089971, 16764886, 8680827, 1052688, 0, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 5392714, 16750228, 7563635, 0, 0, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 2169880, 9734796, 2697257, 0, 0, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 1024, 8681860, 0, 0, 0, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8680827, 0, 0, 0, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8680827, 0, 0, 0, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7563627, 0, 0, 0, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3224625, 0, 0, 0, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2697257, 0, 0, 0, 0, 0, 0, 0, 0, 0
  Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
EndDataSection
le probleme est que l'arme 4 ne marche pas : j'arrive pas a faire que les vaisseau englobe dedans meurt

on change d'arme avec "1", "2", "3", "4"
et on tire avec espace pour la 4 il faut rester appuie puis relacher
tout et acepté :D
Dr. Dri
Messages : 2527
Inscription : ven. 23/janv./2004 18:10

Message par Dr. Dri »

sympa comme tout
un peu simple tout de même...

y faudrait d'autres armes qui ne puissent pas être tirées en rafale

Dri :10:
Backup
Messages : 14526
Inscription : lun. 26/avr./2004 0:40

Message par Backup »

le probleme est que l'arme 4 ne marche pas : j'arrive pas a faire que les vaisseau englobe dedans meurt

j'ai obtenu un resultat en ajoutant une ligne de code , mais c'est pas parfait , cela devrai quand meme t'eguiller ! :D
apres la ligne ajouté j'ai mis un commentaire avec ":<----- j'ai ajouté ça ..... DOBRO " (ligne 333)


question : pourquoi ne pas utiliser les collision du pure ?
c'est fort de ta part d'utiliser les matrices , mais les collision t'aurai permis un travail beaucoup plus clair !! , c'est dur de débugger un programme comme le tien , car les variable ne sont pas explicite , :D
on dirai que tu voulais rendre ton code tres obscur !! est-ce voulu ??

sinon bon boulot ! chapeau ! :D

:D


Code : Tout sélectionner

;- bullet
Structure bullet
        x.l
        y.l
        a.l
        b.l
        arm.l
        type.l
EndStructure

;- pointfloat
Structure pointfloat
        x.f
        y.f
EndStructure

;- star
Structure star
        x.l
        y.l
        lum.l
        sens.l
EndStructure

Case_depart :

;- police
Global FontID1
FontID1 = LoadFont(1, "Arial", 36, #PB_Font_Underline)
Global FontID2
FontID2 = LoadFont(2, "Bookman Old Style", 18)
Global FontID3
FontID3 = LoadFont(3, "Arial", 12, #PB_Font_Underline)
Global FontID4
FontID4 = LoadFont(4, "Bookman Old Style", 16)

Procedure SaveHightScore(filename.s, score, niveau, podium) ; sauvegarde le score et le niveau des x meilleurs dans un fichier
        Protected place, a, score, podium, filename, name.s, niveau
        If OpenFile(0, filename)
                
                Dim nom.s(podium)
                Dim score.s(podium)
                Dim niveau.s(podium)
                
                place = 0
                
                For a = 1 To podium
                        nom(a) = ReadString()
                        score(a) = ReadString()
                        niveau(a) = ReadString()
                        If score > Val(score(a)) And place = 0
                                place = a
                        EndIf
                        If score(a) = "" : score(a) = "0" : EndIf
                        If niveau(a) = "" : niveau(a) = "0" : EndIf
                Next
                
                CloseFile(0)
                
                If place <> 0
                        name.s = InputRequester("Vous êtes " + Str(place) + " ème", "Entrez votre nom", "")
                        For a = podium To 1 Step -1
                                If a = place
                                        nom(a) = name
                                        score(a) = Str(score)
                                        niveau(a) = Str(niveau)
                                EndIf
                                If a > place
                                        nom(a) = nom(a - 1)
                                        score(a) = score(a - 1)
                                        niveau(a) = niveau(a - 1)
                                EndIf
                        Next
                        
                        If CreateFile(0, filename)
                                For a = 1 To podium
                                        WriteStringN(nom(a))
                                        WriteStringN(score(a))
                                        WriteStringN(niveau(a))
                                Next
                                CloseFile(0)
                        EndIf
                        
                EndIf
        EndIf
        
        ProcedureReturn place
EndProcedure

Procedure window0()
        If OpenWindow(0, 0, 0, 600, 300, #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered, "Space")
                If CreateGadgetList(WindowID())
                        TextGadget(0, 140, 5, 320, 65, "Space Impact", #PB_Text_Center | #PB_Text_Border)
                        SetGadgetFont(0, FontID1)
                        TrackBarGadget(1, 5, 155, 590, 35, 0, 19, #PB_TrackBar_Ticks)
                        TextGadget(2, 100, 105, 400, 35, "Selectionnez la difficulté:", #PB_Text_Center | #PB_Text_Border)
                        SetGadgetFont(2, FontID2)
                        TextGadget(3, 5, 190, 50, 20, "+ facile")
                        SetGadgetFont(3, FontID3)
                        TextGadget(4, 545, 190, 50, 20, "- facile")
                        SetGadgetFont(4, FontID3)
                        ButtonGadget(5, 165, 215, 270, 40, "Go")
                        SetGadgetFont(5, FontID4)
                EndIf
        EndIf
        SetGadgetState(1, 9)
EndProcedure

window0()

Repeat
        event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow Or EventGadgetID() = 5

If event = #PB_Event_CloseWindow : End : EndIf

difficult = GetGadgetState(1)
CloseWindow(0)

If InitMouse() = 0 Or InitSprite() = 0 Or InitKeyboard() = 0
        MessageRequester("Error", "Can't open DirectX 7", 0)
        End
EndIf

If OpenWindow(0, 0, 0, 640, 500, #PB_Window_ScreenCentered, "Space") And OpenWindowedScreen(WindowID(), 0, 20, 640, 480, 0, 0, 0) = 0
        MessageRequester("Attention", "l'ecran n'a pas pus être ouvert")
        End
EndIf

If CreateGadgetList(WindowID())
        TextGadget(0, 0, 0, 640, 20, "", #PB_Text_Center | #PB_Text_Border)
EndIf


For a = 0 To 1
        If a = 0 : Restore vaisseau : EndIf
        If a = 1 : Restore vaisseau1 : EndIf
        
        Read width
        Read height
        
        CreateSprite(a, width, height)
        
        If StartDrawing(SpriteOutput(a))
                For y2 = 0 To height - 1
                        For x2 = 0 To width - 1
                                Read color
                                Plot(x2, y2, color)
                        Next
                Next
                StopDrawing()
        EndIf
Next

TransparentSpriteColor(0, 0, 0, 0)
TransparentSpriteColor(1, 0, 0, 0)

;- init
autorise = 300 - 10 * difficult
az = 0
vie = 480
q = 40
s = 420
bullet = 0
bulletmoi = 0
vitbullet = 2 + difficult / 3
degat = 10
arme = 0
limitvitesse = difficult / 2 + 1
enfonc = 0
vitesse.pointfloat\x = 0
vitesse.pointfloat\y = 0

Dim bullet.bullet(1010)
Dim bulletmoi.bullet(310)
Dim stars.star(1010)

star = 0
For a = 0 To 480 Step 2
        For b = 0 To 2
                stars(star)\x = Random(640)
                stars(star)\y = a
                stars(star)\lum = Random(255)
                stars(star)\sens = Random(11) - 6
                star = star + 1
        Next
Next

debut :
az = az + 1
az1.f = az * 2 / 10
If az1 = 0 : vitbullet = vitbullet + 1 : EndIf
DataSection
niv1 :
Data.l 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
Data.l 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
Data.l 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
deplacement :
Data.l - 1, 270, 270, -1, 270, -1
Data.l 80, 80, -1, -1, 80, -1
EndDataSection

Dim vais(15, 3)
Dim deplacementx(6)
Dim deplacementy(6)

Restore niv1

For ligne = 1 To 3
        For colonne = 1 To 15
                Read z
                vais(colonne, ligne) = z * az
        Next
Next

Restore deplacement

For a = 1 To 6
        Read deplacementx(a)
Next
For a = 1 To 6
        Read deplacementy(a)
Next

a = -1
b = -150
c = 1
win = 0

Repeat
        event = WindowEvent()
        Delay(2)
        ExamineKeyboard()
        ClearScreen(0, 0, 0)
        restant = 0
        For g = 1 To 3
                For h = 1 To 15
                        
                        If vais(h, g) >= 1
                                restant = restant + 1
                                DisplayTransparentSprite(1, 24 * h + a - 20, 36 * g + b - 34)
                                
                                If Random(autorise) = 0 And bullet(bullet)\x = 0
                                        If Random(1) = 0
                                                bullet(bullet)\x = 24 * h + a - 10
                                                bullet(bullet)\y = 36 * g + b - 4
                                                bullet(bullet)\arm = 0
                                                bullet = bullet + 1
                                                If bullet >= 1001 : bullet = 1 : EndIf
                                        Else
                                                bullet(bullet)\x = 24 * h + a - 20
                                                bullet(bullet)\y = 36 * g + b - 4
                                                bullet(bullet)\arm = 1
                                                bullet = bullet + 1
                                                If bullet >= 1001 : bullet = 1 : EndIf
                                                If bullet(bullet)\x = 0
                                                        bullet(bullet)\x = 24 * h + a
                                                        bullet(bullet)\y = 36 * g + b - 4
                                                        bullet(bullet)\arm = 1
                                                        bullet = bullet + 1
                                                        If bullet >= 1001 : bullet = 1 : EndIf
                                                EndIf
                                        EndIf
                                EndIf
                                
                        EndIf
                        
                        ; explosion
                        If vais(h, g) <= 0 And vais(h, g) > - 15
                                If StartDrawing(ScreenOutput())
                                        For ae = 1 To 40
                                                Repeat
                                                        xplot = 24 * h + a - 22 + Random(34)
                                                        yplot = 36 * g + b - 36 + Random(34)
                                                        xplota = (xplot - (24 * h + a - 11)) * (xplot - (24 * h + a - 11))
                                                        yplota = (yplot - (36 * g + b - 20)) * (yplot - (36 * g + b - 20))
                                                Until Sqr(xplota + yplota) < 15
                                                Circle(xplot, yplot, 1, RGB(255, Random(255), 0))
                                        Next
                                        StopDrawing()
                                EndIf
                                vais(h, g) = vais(h, g) - 1
                        EndIf
                        
                Next
        Next
        
        viereste.f = (vie / 480) * 100
        SetGadgetText(0, "Niveau = " + Str(az) + "        Ennemis vaincus = " + Str(45 * az - restant) + "        Vie restante = " + Str(viereste) + "%")
        
        If StartDrawing(ScreenOutput())
                
                ;- fond etoile
                For z = 0 To 1000
                        Circle(stars(z)\x, stars(z)\y, 1, RGB(stars(z)\lum, stars(z)\lum, stars(z)\lum))
                        stars(z)\lum = stars(z)\lum + stars(z)\sens
                        stars(z)\y = stars(z)\y + 2
                        If stars(z)\y > 480
                                stars(z)\x = Random(640)
                                stars(z)\y = 0
                        EndIf
                        If stars(z)\lum > 248 Or stars(z)\lum < 7 : stars(z)\sens = -stars(z)\sens : EndIf
                Next
                
                ;- vie
                vert.f = ((vie / 480) * 255)
                Box(633, 480, 7, -vie, RGB(99, vert, 156))
                
                ;- tir moi
                For z = 1 To 300
                        If bulletmoi(z)\x <> 0
                                If bulletmoi(z)\type = 0 
                                        Box(bulletmoi(z)\x - 1, bulletmoi(z)\y, 2, 2, RGB($FF, $28, $00))
                                        Box(bulletmoi(z)\x - 1, bulletmoi(z)\y + 2, 2, 2, RGB($FF, $6D, $00))
                                        Box(bulletmoi(z)\x - 1, bulletmoi(z)\y + 4, 2, 2, RGB($FF, $9E, $00))
                                ElseIf bulletmoi(z)\type = 1
                                        DrawingMode(4)
                                        For ar = 1 To bulletmoi(z)\arm
                                                Ellipse(bulletmoi(z)\x - 1, bulletmoi(z)\y, ar / 2, ar, RGB(255, ar * 5, 0))
                                        Next
                                        DrawingMode(0)
                                EndIf
                                t.f = (-a + 20 + bulletmoi(z)\x) / 24
                                y.f = (-b + 34 + bulletmoi(z)\y) / 36
                                t1.l = t
                                y1.l = y
                                If t1 > 0 And y1 > 0 And t1 < 16 And y1 < 4 And bulletmoi(z)\type = 0
                                        If vais(t1, y1) > 0
                                                bulletmoi(z)\x = 0
                                                vais(t1, y1) = vais(t1, y1) - bulletmoi(z)\arm - 1
                                        EndIf
                                ElseIf bulletmoi(z)\type = 1 
                                        vais(t1, y1) = vais(t1, y1) -  1 ; <----- j'ai ajouté ça ..... DOBRO 
                                EndIf 
                                        bulletmoi(z)\y = bulletmoi(z)\y + bulletmoi(z)\b
                                        bulletmoi(z)\x = bulletmoi(z)\x + bulletmoi(z)\a 
                        EndIf
                        If bulletmoi(z)\y < - 2 Or bulletmoi(z)\x < 5 Or bulletmoi(z)\x > 650
                                bulletmoi(z)\x = 0
                        EndIf
                Next
                
                For z = 1 To 1000
                        If bullet(z)\x <> 0
                                Box(bullet(z)\x - 1, bullet(z)\y, 2, 2, RGB($00, $18, $FF))
                               Box(bullet(z)\x - 1, bullet(z)\y - 2, 2, 2, RGB($00, $82, $FF))
                                Box(bullet(z)\x - 1, bullet(z)\y - 4, 2, 2, RGB($00, $DF, $FF))
                        EndIf
                        If bullet(z)\x + 2 > q And bullet(z)\x - 2 < q + 19 And bullet(z)\y + 2 > s And bullet(z)\y - 2 < s + 29
                                vie = vie - degat * (bullet(z)\arm + 1)
                                bullet(z)\x = 0
                                If vie <= 0
                                        mort = 45 * az - restant
                                        MessageRequester("Dommage", "Vous avez perdu")
                                        StopDrawing()
                                        win = 2
                                        Gosub perdu
                                EndIf
                        Else
                                bullet(z)\y = bullet(z)\y + vitbullet
                        EndIf
                        If bullet(z)\y > 480
                                bullet(z)\x = 0
                        EndIf
                        If win = 2 : Break : EndIf
                Next
                
                If restant = 0
                        win = 1
                EndIf
                
                StopDrawing()
        EndIf
        DisplayTransparentSprite(0, q, s)
        FlipBuffers()
        
        ;- deplacement ennemis
        If b <= -2
                b = b + 2
        Else
                e = deplacementx(c)
                f = deplacementy(c)
                If (a = e Or a = e + 1) And (b = f Or b = f + 1) : c = c + 1 : EndIf
                If c = 7 : c = 1 : EndIf
                If a <> e And a <> e + 1 : a = a + 2 * (Abs(e) / e) : EndIf
                If b <> f And b <> f + 1 : b = b + 2 * (Abs(f) / f) : EndIf
        EndIf
        
        ;- deplacement
        delai = delai - 1
        If KeyboardPushed(#PB_Key_Left)
                If vitesse\x > - limitvitesse : vitesse\x = vitesse\x - 0.4 : EndIf
        EndIf
        If KeyboardPushed(#PB_Key_Right)
                If vitesse\x < limitvitesse : vitesse\x = vitesse\x + 0.4 : EndIf
        EndIf
        If KeyboardPushed(#PB_Key_Up)
                If vitesse\y > - limitvitesse : vitesse\y = vitesse\y - 0.4 : EndIf
        EndIf
        If KeyboardPushed(#PB_Key_Down)
                If vitesse\y < limitvitesse : vitesse\y = vitesse\y + 0.4 : EndIf
        EndIf
        
        q = q + vitesse\x
        s = s + vitesse\y
        If vitesse\x < 0 : vitesse\x = vitesse\x + 0.2 : EndIf
        If vitesse\x > 0 : vitesse\x = vitesse\x - 0.2 : EndIf
        If vitesse\y < 0 : vitesse\y = vitesse\y + 0.2 : EndIf
        If vitesse\y > 0 : vitesse\y = vitesse\y - 0.2 : EndIf
        
        If q < 5 : q = 5 : EndIf
        If q > 600 : q = 600 : EndIf
        If s < 250 : s = 250 : EndIf
        If s > 445 : s = 445 : EndIf
        
        If KeyboardPushed(#PB_Key_1) : arme = 0 : enfonc = 0 : EndIf
        If KeyboardPushed(#PB_Key_2) : arme = 1 : enfonc = 0 : EndIf
        If KeyboardPushed(#PB_Key_3) : arme = 2 : enfonc = 0 : EndIf
        If KeyboardPushed(#PB_Key_4) : arme = 3 : enfonc = 0 : EndIf
        If KeyboardPushed(#PB_Key_Space) = 0 And arme = 3 And enfonc <> 0
                If enfonc > 51 : enfonc = 51 : EndIf
                bulletmoi(bulletmoi)\x = q + 10
                bulletmoi(bulletmoi)\y = s
                bulletmoi(bulletmoi)\a = 0
                bulletmoi(bulletmoi)\b = -1.2 * vitbullet
                bulletmoi(bulletmoi)\arm = enfonc
                bulletmoi(bulletmoi)\type = 1
                enfonc = 0
                bulletmoi = bulletmoi + 1
                If bulletmoi >= 301 : bulletmoi = 1 : EndIf
        EndIf
        If KeyboardPushed(#PB_Key_Space) And bulletmoi(bulletmoi)\x = 0 And delai <= 0
                If arme = 0
                        bulletmoi(bulletmoi)\x = q + 10
                        bulletmoi(bulletmoi)\y = s
                        bulletmoi(bulletmoi)\a = 0
                        bulletmoi(bulletmoi)\b = -vitbullet
                        bulletmoi(bulletmoi)\arm = 0
                        bulletmoi = bulletmoi + 1
                        If bulletmoi >= 301 : bulletmoi = 1 : EndIf
                        delai = 5
                EndIf
                If arme = 1
                        bulletmoi(bulletmoi)\x = q
                        bulletmoi(bulletmoi)\y = s
                        bulletmoi(bulletmoi)\a = 0
                        bulletmoi(bulletmoi)\b = -vitbullet
                        bulletmoi(bulletmoi)\arm = 1
                        bulletmoi = bulletmoi + 1
                        If bulletmoi >= 301 : bulletmoi = 1 : EndIf
                        If bulletmoi(bulletmoi)\x = 0
                                bulletmoi(bulletmoi)\x = q + 20
                                bulletmoi(bulletmoi)\y = s
                                bulletmoi(bulletmoi)\a = 0
                                bulletmoi(bulletmoi)\b = -vitbullet
                                bulletmoi(bulletmoi)\arm = 1
                                bulletmoi = bulletmoi + 1
                                If bulletmoi >= 301 : bulletmoi = 1 : EndIf
                        EndIf
                        delai = 5
                EndIf
                If arme = 2
                        bulletmoi(bulletmoi)\x = q + 10
                        bulletmoi(bulletmoi)\y = s
                        bulletmoi(bulletmoi)\a = 0
                        bulletmoi(bulletmoi)\b = -vitbullet
                        bulletmoi(bulletmoi)\arm = 2
                        bulletmoi = bulletmoi + 1
                        If bulletmoi >= 301 : bulletmoi = 1 : EndIf
                        If bulletmoi(bulletmoi)\x = 0
                                bulletmoi(bulletmoi)\x = q + 10
                                bulletmoi(bulletmoi)\y = s
                                bulletmoi(bulletmoi)\a = -2
                                bulletmoi(bulletmoi)\b = -vitbullet
                                bulletmoi(bulletmoi)\arm = 2
                                If bulletmoi >= 301 : bulletmoi = 1 : EndIf
                                bulletmoi = bulletmoi + 1
                        EndIf
                        If bulletmoi(bulletmoi)\x = 0
                                bulletmoi(bulletmoi)\x = q + 10
                                bulletmoi(bulletmoi)\y = s
                                bulletmoi(bulletmoi)\a = 2
                                bulletmoi(bulletmoi)\b = -vitbullet
                                bulletmoi(bulletmoi)\arm = 2
                                bulletmoi = bulletmoi + 1
                                If bulletmoi >= 301 : bulletmoi = 1 : EndIf
                        EndIf
                        delai = 5
                EndIf
                If arme = 3 
                        enfonc = enfonc + 1                   
                EndIf
        EndIf
        
Until KeyboardPushed(#PB_Key_Escape) Or win <> 0

perdu :

If win = 2 Or KeyboardPushed(#PB_Key_Escape)
        CloseScreen()
        CloseWindow(0)
        
        SaveHightScore("Space.pref", mort, az, 10)
        
        If OpenWindow(1, 0, 0, 380, 390, #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered, "Space Meilleurs Scores") And CreateGadgetList(WindowID())
                If OpenFile(0, "Space.pref")
                        TextGadget(1, 20, 20, 200, 17, "PLACE : NOM")
                        TextGadget(1, 240, 20, 50, 17, "SCORE")
                        TextGadget(1, 310, 20, 50, 17, "NIVEAU")
                        For aze = 1 To 10
                                TextGadget(0, 20, aze * 30 + 20, 200, 17, Str(aze) + "  :  " + ReadString(), #PB_Text_Border)
                                TextGadget(0, 240, aze * 30 + 20, 50, 17, ReadString(), #PB_Text_Border | #PB_Text_Right)
                                TextGadget(0, 310, aze * 30 + 20, 50, 17, ReadString(), #PB_Text_Border | #PB_Text_Right)
                        Next
                        CloseFile(0)
                        ButtonGadget(4, 20, 350, 160, 20, "REJOUER")
                        ButtonGadget(5, 200, 350, 160, 20, "QUITTER")
                EndIf
        EndIf
        
        Repeat
                event = WaitWindowEvent()
                If event = #PB_Event_Gadget
                        Select EventGadgetID()
                                Case 4
                                        CloseWindow(1)
                                        Gosub Case_depart
                                Case 5
                                        End
                        EndSelect
                EndIf
        Until event = #PB_Event_CloseWindow
        
        End
        
EndIf

Gosub debut

Return


DataSection
vaisseau :
Data.l 20, 30
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2697257, 0, 0, 0, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3224625, 0, 0, 0, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7563627, 0, 0, 0, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8680827, 0, 0, 0, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8680827, 0, 0, 0, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 1024, 8681860, 0, 0, 0, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 2169880, 9734796, 2697257, 0, 0, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 5392714, 16750228, 7563635, 0, 0, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 1052688, 8089971, 16764886, 8680827, 1052688, 0, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 4868426, 8680827, 16756397, 9207172, 8089979, 0, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 5920090, 7564659, 11377317, 11904685, 11377317, 0, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 526344, 2697257, 13023933, 4866370, 1052688, 0, 526344, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 1580056, 11379373, 3748913, 0, 0, 3749945, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 526344, 4340802, 8681860, 11378341, 1052688, 0, 4343106, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 1581097, 3748921, 3223601, 15692147, 10261140, 10262172, 2171937, 4868426, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 3225657, 3757411, 4339769, 2170913, 15179420, 9734804, 10854053, 9734796, 7037283, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 3748921, 6514027, 5927291, 4339769, 1053712, 7037283, 10261148, 11904685, 10851996, 10261148, 11904693, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 4867402, 6513003, 5399923, 3222577, 1024, 7561595, 9208460, 10261140, 9207172, 8681851, 11907765, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 1024, 1579032, 1581089, 1052688, 527368, 4866411, 4867402, 3222577, 2697257, 2170913, 526344, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 1024, 4342082, 8089971, 5919058, 0, 0, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 1024, 4867402, 9197923, 14059140, 10846852, 5921114, 0, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 527368, 4867394, 7036259, 14049635, 16748180, 14068397, 9208460, 3748921, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 1024, 4339769, 5920090, 6511971, 6510938, 6510938, 8681851, 8681860, 10260116, 8680836, 10851988, 4340802, 0, 0, 0, 0
Data.l 0, 0, 0, 527384, 5392714, 6511971, 7563627, 7038315, 4340802, 3748913, 7563635, 8681860, 8088955, 8680827, 10262172, 9735836, 8089971, 8, 0, 0
Data.l 0, 0, 0, 1024, 1580056, 3749945, 5393746, 5394770, 4340802, 1051664, 5393746, 7037283, 7563635, 7563635, 5394778, 5919058, 3223601, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 526344, 527368, 2170913, 6511971, 4866378, 1052688, 526344, 1024, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 1024, 5920090, 9734804, 9733780, 0, 0, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 1024, 7037283, 10853020, 10853029, 0, 0, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 1024, 1052688, 1024, 0, 0, 0, 0, 0, 0, 0, 0

vaisseau1 :
Data.l 20, 30
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 1024, 1052688, 1024, 0, 0, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 1024, 7037283, 10853020, 10853029, 0, 0, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 1024, 5920090, 9734804, 9733780, 0, 0, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 526344, 527368, 2170913, 6511971, 4866378, 1052688, 526344, 1024, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 1024, 1580056, 3749945, 5393746, 5394770, 4340802, 1051664, 5393746, 7037283, 7563635, 7563635, 5394778, 5919058, 3223601, 0, 0, 0
Data.l 0, 0, 0, 527384, 5392714, 6511971, 7563627, 7038315, 4340802, 3748913, 7563635, 8681860, 8088955, 8680827, 10262172, 9735836, 8089971, 8, 0, 0
Data.l 0, 0, 0, 0, 1024, 4339769, 5920090, 6511971, 6510938, 6510938, 8681851, 8681860, 10260116, 8680836, 10851988, 4340802, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 527368, 4867394, 7036259, 14049635, 16748180, 14068397, 9208460, 3748921, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 1024, 4867402, 9197923, 14059140, 10846852, 5921114, 0, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 1024, 4342082, 8089971, 5919058, 0, 0, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 1024, 1579032, 1581089, 1052688, 527368, 4866411, 4867402, 3222577, 2697257, 2170913, 526344, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 4867402, 6513003, 5399923, 3222577, 1024, 7561595, 9208460, 10261140, 9207172, 8681851, 11907765, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 3748921, 6514027, 5927291, 4339769, 1053712, 7037283, 10261148, 11904685, 10851996, 10261148, 11904693, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 3225657, 3757411, 4339769, 2170913, 15179420, 9734804, 10854053, 9734796, 7037283, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 1581097, 3748921, 3223601, 15692147, 10261140, 10262172, 2171937, 4868426, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 526344, 4340802, 8681860, 11378341, 1052688, 0, 4343106, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 1580056, 11379373, 3748913, 0, 0, 3749945, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 526344, 2697257, 13023933, 4866370, 1052688, 0, 526344, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 5920090, 7564659, 11377317, 11904685, 11377317, 0, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 4868426, 8680827, 16756397, 9207172, 8089979, 0, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 1052688, 8089971, 16764886, 8680827, 1052688, 0, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 5392714, 16750228, 7563635, 0, 0, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 2169880, 9734796, 2697257, 0, 0, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 1024, 8681860, 0, 0, 0, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8680827, 0, 0, 0, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8680827, 0, 0, 0, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7563627, 0, 0, 0, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3224625, 0, 0, 0, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2697257, 0, 0, 0, 0, 0, 0, 0, 0, 0
Data.l 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
EndDataSection 
 
Dr. Dri
Messages : 2527
Inscription : ven. 23/janv./2004 18:10

Message par Dr. Dri »

ta ligne de code en plus a fait planter mon PC :-?

Dri
Marcus
Messages : 187
Inscription : jeu. 22/janv./2004 19:08
Contact :

Message par Marcus »

tres bien :)
dommage en plein écran ce serait bien mieu :wink:
Backup
Messages : 14526
Inscription : lun. 26/avr./2004 0:40

Message par Backup »

Dr. Dri a écrit :ta ligne de code en plus a fait planter mon PC :-?

Dri

:lol: :lol: j'ai bien dit que c'etait pas parfait !!

mais je lui signale comment faire disparaitre ces vaisseaux avec l'arme numero 4, a lui de trouver la solution, moi je lui montre ou peut etre son erreur , je cherchai pas vraiment a entrer dans son listing tres illisible par ailleurs ! :D

:D
Marcus
Messages : 187
Inscription : jeu. 22/janv./2004 19:08
Contact :

Message par Marcus »

son listing tres illisible par ailleurs
tu pourrais t'abstenir de ce genre de reflexion :roll:
Backup
Messages : 14526
Inscription : lun. 26/avr./2004 0:40

Message par Backup »

si tu avait lu plus haut tu saurai que par illisible j'entend qu'il a utilisé des variable pas tres explicite !! pas qu'il programme comme un manche !!

je lui ai par ailleur dit "
c'est dur de débugger un programme comme le tien , car les variable ne sont pas explicite , Very Happy
on dirai que tu voulais rendre ton code tres obscur !! est-ce voulu ??

sinon bon boulot ! chapeau ! Very Happy
je vais pas me repeter parceque Mr Marcus lit que les dernier post dans les forum !! :? :lol: :lol: :D
Marcus
Messages : 187
Inscription : jeu. 22/janv./2004 19:08
Contact :

Message par Marcus »

j'avais bien lu le post entier... mais il est peu etre plus sympa de faire remarquer que le code manque de commentaires plutot que je dire quel est illisible !

enfin bref suis pas là pour me prendre le bec :wink:
dlolo
Messages : 118
Inscription : ven. 18/févr./2005 16:29

Message par dlolo »

@graph100

tiens... j'ai déjà vu le sprite quelque pars ... :wink:

(Mon petit sapin de noel :wink: )
Avatar de l’utilisateur
graph100
Messages : 1318
Inscription : sam. 21/mai/2005 17:50

Message par graph100 »

@dlolo

euh... oui j'ai repris le dessin car je ne sais absolument pas dessiner :oops:
si tu veut pas dis le moi je les enleve
au debut le vaisseau etais de gros rectangles bleus
pas génial génial

@Dobro

je suis desole de ne pas avoir commenter on me l'a deja dis
par contre les nom des variable est pas clair 8O
la variable " bullet " signifie les boulet ennemis et
" bulletmoi " signifie mes boulet :roll:
enfin ..
j'ai regarder la ligne que tu as rajoute 8O
c'est obliger de planter

je n'ai pas compris les collision . de quoi parle tu ??
en fait j'ai utiliser les matrice uniquement pour que tous les vaisseaux bougent en meme temps ca m'a plutot embeté pour detecter quand il sont touché
Avatar de l’utilisateur
graph100
Messages : 1318
Inscription : sam. 21/mai/2005 17:50

Message par graph100 »

Dobro a écrit :si tu avait lu plus haut tu saurai que par illisible j'entend qu'il a utilisé des variable pas tres explicite !! pas qu'il programme comme un manche !!
:D :lol:
Backup
Messages : 14526
Inscription : lun. 26/avr./2004 0:40

Message par Backup »

par variable pas tres explicite je cite :

Code : Tout sélectionner

t.f = (-a + 20 + bulletmoi(z)\x) / 24
                                y.f = (-b + 34 + bulletmoi(z)\y) / 36
                                t1.l = t
                                y1.l = y 
pris au hazard !! pourquoi "t" ?? le "-a" est pas tres parlant ainsi que "-b"
le "t1" ect .... :D

sache que je ne critique pas ta façon de programmer ! car si toit tu t'y retrouve c'est l'essentiel :D
mais a partir du moment ou tu demande une aide pour t'aider a retrouver un bug , n'ayant pas tes references en matiere de variables et ta façon de programmer (respectable au demeurant ! )
j'entrevoi une dificulté pour reprendre le listing , c'est comme vouloir dechifrer des manuscrit anciens :D pas vraiment facile sans pierre de rosette :D

la ligne que j'ai ajouté met en évidence un moyen concret pour faire disparaitre les vaisseaux en fonction de l'arme numero 4 !
j'admet que les vaisseaux disparaissent avant le contact effectif
et que cette ligne fait planter au bout d'un moment , mais je voulais atirer ton attention , sur l'endroit ou doit etre le probleme , il manque manifestement un test dans ce coin du listing (celui ou j'ai mis la ligne)

je n'ai pas compris les collision . de quoi parle tu ??
d'une fonction merveilleuse fourni par le purebasic

je cite : Resultat = SpritePixelCollision(#Sprite1, x1, y1, #Sprite2, x2, y2)

a moins d'etre passé a coté , il ne me semble pas l'avoir vu dans ton programme ; mais la fatigue aidant (regarder le tour de france m'epuise :D )
je l'ai peut etre pas vu .....



:lol:
Backup
Messages : 14526
Inscription : lun. 26/avr./2004 0:40

Message par Backup »

par variable pas tres explicite je cite :

Code : Tout sélectionner

t.f = (-a + 20 + bulletmoi(z)\x) / 24
                                y.f = (-b + 34 + bulletmoi(z)\y) / 36
                                t1.l = t
                                y1.l = y 
pris au hazard !! pourquoi "t" ?? le "-a" est pas tres parlant ainsi que "-b"
le "t1" ect .... :D

sache que je ne critique pas ta façon de programmer ! car si toi tu t'y retrouve c'est l'essentiel :D
mais a partir du moment ou tu demande une aide pour t'aider a retrouver un bug , n'ayant pas tes references en matiere de variables et ta façon de programmer (respectable au demeurant ! )
j'entrevoi une dificulté pour reprendre le listing , c'est comme vouloir dechifrer des manuscrit anciens :D pas vraiment facile sans pierre de rosette :D

la ligne que j'ai ajouté met en évidence un moyen concret pour faire disparaitre les vaisseaux en fonction de l'arme numero 4 !
j'admet que les vaisseaux disparaissent avant le contact effectif
et que cette ligne fait planter au bout d'un moment , mais je voulais atirer ton attention , sur l'endroit ou doit etre le probleme , il manque manifestement un test dans ce coin du listing (celui ou j'ai mis la ligne)

je n'ai pas compris les collision . de quoi parle tu ??
d'une fonction merveilleuse fourni par le purebasic

je cite : Resultat = SpritePixelCollision(#Sprite1, x1, y1, #Sprite2, x2, y2)

a moins d'etre passé a coté , il ne me semble pas l'avoir vu dans ton programme ; mais la fatigue aidant (regarder le tour de france m'epuise :D )
je l'ai peut etre pas vu .....



:lol:
Avatar de l’utilisateur
graph100
Messages : 1318
Inscription : sam. 21/mai/2005 17:50

Message par graph100 »

Salut Champollion :D
non tu n'est pas assez fatiqué pour lire mal :D
je n'est pas utilisé la fonction de collision car je n'utilise des sprite uniquement pour les vaisseaux ... pas pour les tir

pour les variables je suis desolé comme je peut pas allez sur le pc
tous le temps j'ai commencer a rpogrammer et tester le deplacement des vaisseaux adverses sur ma calculatrice :D
et on peut pas avoi des variable differentes des lettres de l'alphabet . voila l'histoire :D
Répondre