Au debut le jeu tourne correctement, au bout de 10 sec il se met à ralentir, et au bout de 20 il rame severement. je ne comprends pas pourquoi (d'autant qu'avec le meme code sur Pure Basic Mac le phenomene ne se produit pas).
Vous moquez pas de l'absence de sprites et autres abberations de programmation, je debute, c'est juste que je veux comprendre pourquoi le jeu ralenti alors qu'il tourne en boucle.
Code : Tout sélectionner
; ************* PARSEC ******************
InitKeyboard():InitSprite()
OpenScreen(800,600,16,"")
Dim etoilex(150):Dim etoiley(150)
Dim scrollbrique(42):Dim scrolltype(42)
Dim enx(20):Dim eny(20):Dim enaff(20):Dim endir(20):Dim enmort(20)
level=0
score=0
fuel.d=100
level=level+1
; ****************************************** JEU ***********************************
; **************************** données avant jeu
vx=50
vy=350
vitesse=1
surchauffe=0
pertevie=0
; definition du scrolling de base
For i=1 To 42
scrollbrique(i)=550-Random(30)
Next i
scrollx=0
; etoiles
For i=1 To 80
etoilex(i)=Random(800)
etoiley(i)=Random(480)+20
Next i
; creation des ennemis
entue=0
enatuer=20
For i=1 To enatuer
enmort(i)=0
enaff(i)=100+Random(300)
enx(i)=850+Random(50)
eny(i)=Random(380)
endir(i)=3-Random(5)
Next i
Repeat
; ***************************************** affichage ***********************************
; decor fond
ClearScreen (RGB(20,20,20))
StartDrawing(ScreenOutput())
; etoile
For i=1 To 100
FrontColor(RGB(255-Random(30), 255-Random(30), 255-Random(30)))
Box (etoilex(i),etoiley(i),3,3)
Next i
; affichage scroll
xx=-50+scrollx
For i=1 To 42
FrontColor(RGB(110, 0, 0))
xx=xx+20
Box (xx,scrollbrique(i),40,580-scrollbrique(i))
Next i
; affichage vaisseau
FrontColor(RGB(180,210-(surchauffe*2), 210-(surchauffe*2)))
Box (vx,vy,40,3)
Box (vx,vy-3,35,3)
Box (vx,vy-6,20,3)
Box (vx,vy-10,3,6)
FrontColor(RGB(255,0+(vitesse*80), 0))
Box (vx-3,vy-3,3,6)
FrontColor(RGB(255-Random(30), 255-Random(30), 255-Random(30)))
Box (vx-3-Random(2),vy-Random(5),3,3)
If vitesse=2
FrontColor (RGB(255,0,0))
Box (vx-8-Random(2),vy-Random(5),6,3)
EndIf
; affichage tir
If tir>0
FrontColor(RGB(Random(255),Random(255),Random(255)))
Box (vx+40,vy,710,3)
EndIf
; affichage vaisseaux ennemis
For i=1 To enatuer
If enmort(i)=0
FrontColor(RGB(180,210, 110))
Box (enx(i),eny(i),40,5)
Box (enx(i)+10,eny(i)-5,30,5)
Box (enx(i)+30,eny(i)-10,10,5)
Box (enx(i)+40,eny(i)-15,5,16)
FrontColor(RGB(Random(255), Random(255), Random(255))): Box (enx(i)+41+Random(2),eny(i)+Random(5),5,3)
EndIf
Next i
; affichage explosion
For i=1 To enatuer
If enmort(i)>1 And enmort(i)<30
FrontColor(RGB(Random(255), Random(55), Random(55))): Box (enx(i)+Random(40),eny(i)+10-Random(40), Random(5)+5,Random(5)+5)
EndIf
Next i
; aff donnees
FrontColor(RGB(255,255, 255))
; DrawText (100,100,Str(surchauffe))
DrawText (50,2,Str(level))
DrawText (650,2,Str(score))
FrontColor(RGB(255, 255, 255)): Box (100,25,600,10)
FrontColor(RGB(110, 30, 0)): Box (100,25,fuel.d*6,10)
; fin dessin
StopDrawing()
FlipBuffers ()
test=test+1
; ****************************************** calcul ******************************
; defilement etoiles
For i=1 To 100
etoilex(i)=etoilex(i)-1
If etoilex(i)<-2:etoilex(i)=802:EndIf
Next i
; diminution tir / surchauffe
If tir>0:tir=tir-1:EndIf
surchauffe=surchauffe-1
If surchauffe<0:surchauffe=0:EndIf
If surchauffe>100:level=level-1:EndIf
; acceleration
If vitesse=2
vx=vx+2
If vx>150:vx=150:EndIf
EndIf
If vitesse=1
vx=vx-1
If vx<50:vx=50:EndIf
EndIf
; defil scroll
scrollx=scrollx-vitesse
If scrollx<-19
scrollx=20+scrollx
For i=2 To 42
scrollbrique(i-1)=scrollbrique(i)
scrolltype(i-1)=scrolltype(i)
Next i
scrollbrique(42)=550-Random(100)
EndIf
; ennemis
For i=1 To enatuer
If level=1
If enmort(i)=0
enaff(i)=enaff(i)-1
If enaff(i)<1
enx(i)=enx(i)-4
If enx(i)<400:enx(i)=enx(i)-4:EndIf
If enx(i)<200:enx(i)=enx(i)-2:EndIf
eny(i)=eny(i)+endir(i)
If eny(i)>400:endir(i)=-1:EndIf
If eny(i)<30:endir(i)=1:EndIf
If enx(i)<-50:enx(i)=850+Random(50):eny(i)=30+Random(370):endir(i)=3-Random(5):enaff(i)=Random(500):EndIf
EndIf
EndIf
EndIf
Next i
; test duree explosion
For i=1 To enatuer
If enmort(i)>0 And enmort(i)<30
enmort(i)=enmort(i)+1
EndIf
Next i
; fuel
fuel.d=fuel.d-0.01
; test fin level
If entue=enatuer:EndIf
; test clavier *****************
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Up) And vy>30
vy=vy-2
EndIf
If KeyboardPushed(#PB_Key_Down) And vy<580
vy=vy+2
EndIf
If KeyboardPushed(#PB_Key_Right)
vitesse=2
EndIf
If KeyboardPushed(#PB_Key_Left)
vitesse=1
EndIf
If KeyboardPushed(#PB_Key_Space)
tir=5
surchauffe=surchauffe+3
EndIf
Until KeyboardPushed(#PB_Key_Escape)
End