Synchro ? Bug ? Probleme de clignotement
Publié : jeu. 25/mai/2006 16:12
j'ai un problème de clignotement de mon image dans le jeu que je suis en train de programmé. Et je comprends pas bien d'ou ça vient.
J'ai simplifié au maximum le programme pour vous faire la demonstration.
Je me demande si ce n'est pas un pb de FlipBuffer() ou de clearscreen()...
Mais c'est tres currieux.
A votre avis ?
J'ai simplifié au maximum le programme pour vous faire la demonstration.
Je me demande si ce n'est pas un pb de FlipBuffer() ou de clearscreen()...
Mais c'est tres currieux.
A votre avis ?
Code : Tout sélectionner
If InitSprite() = 0 Or InitKeyboard()=0 Or InitMouse()=0
MessageRequester("Error","DirectX 7+ is needed.",0)
EndIf
OpenScreen(800, 600, 32, "Aliens")
CreateSprite(0,288,217)
StartDrawing(SpriteOutput(0))
Global Address=DrawingBuffer()
Global Pitch=DrawingBufferPitch()
Global PixelFormat=DrawingBufferPixelFormat()
StopDrawing()
Procedure DrawLine(x1,y1,x2,y2,col)
x=x1:y=y1:D=0
hx=x2-x1
hy=y2-y1
xinc=1:yinc=1
If hx<0
xinc=-1:hx=-hx
EndIf
If hy<0
yinc=-1:hy=-hy
EndIf
If hy<=hx
c=2*hx:m=2*hy
L1:
;col=col(Int(x*255/320))
If x>0 And x<288 And y>0 And y<217
PokeL(Address+x*4+Pitch*y,col)
EndIf
If x=x2:Goto BR1:EndIf
x=x+xinc
d=d+m
If d>hx : y=y+yinc : d=d-c : EndIf
Goto L1
BR1:
Else
c=2*hy:m=2*hx
L2:
;col=col(Int(x*255/320))
If x>0 And x<288 And y>0 And y<217
PokeL(Address+x*4+Pitch*y,col)
EndIf
If y=y2 : Goto BR2 : EndIf
y=y+yinc
d=d+m
If d>hy : x=x+xinc : d=d-c : EndIf
Goto L2
BR2:
EndIf
EndProcedure
Procedure ArcCircle(x,y,angle1,angle2,Rayon,col)
Xo=0:
Yo=0:
For a=angle1 To angle2 Step 10
Xp = x + Rayon * Cos(a*2*3.1415/360)
Yp = y + Rayon * Sin(a*2*3.1415/360)
If (Xo>0 Or Yo>0)
DrawLine(Xo,Yo,Xp,Yp,col)
EndIf
Xo=Xp
Yo=Yp
Next
EndProcedure
Macro DMLine(a,rd,rf)
If a >360:a=a-360:EndIf
If a<0:a=a+360:EndIf
Xa = 144 + rd * Cos(a*2*3.1415/360)
Ya = 217+ rd * Sin(a*2*3.1415/360)
Xb = 144 + rf * Cos(a*2*3.1415/360)
Yb = 217 + rf * Sin(a*2*3.1415/360)
DrawLine(Xa,Ya,Xb,Yb,RGB(0,255,0))
EndMacro
Procedure UscmDraw()
Static Time.l=0
Static Rayon.l=0
Static A.l
UscmWidth=144
UscmHeight=217
UscmSpeed=40; pixel par second
UscmRayMax=Sqr(Pow(Int(288/2),2)+Pow(217,2))
;A=A+1
If A>360:A=0:EndIf
;UseBuffer(#DM)
;ClearScreen(0)
ArcCircle(144,217,180,360,190,RGB(0,255,0))
Angle1=A-20
Angle2=A+20
;ArcCircle(144,217,Angle1,Angle2,180,RGB(0,255,0))
Angle1=A-50
Angle2=A-20
;ArcCircle(144,217,Angle1,Angle2,120,RGB(0,255,0))
Angle1=A+20
Angle2=A+50
;ArcCircle(144,217,Angle1,Angle2,120,RGB(0,255,0))
ArcCircle(144,217,180,360,110,RGB(0,255,0))
DMLine(A,90,200)
DMLine(A+90,90,200)
DMLine(A+180,90,200)
DMLine(A+270,90,200)
DMLine(A+45,110,200)
DMLine(A+315,110,200)
DMLine(A+135,110,200)
DMLine(A+225,110,200)
If Time=0:Time=ElapsedMilliseconds():EndIf
t.l=(ElapsedMilliseconds()-Time)
Time=ElapsedMilliseconds()
;ArcCircle(144,217,180,360,Rayon,RGB(0,255,0))
Rayon=Rayon+(UscmSpeed*t/100)
If Rayon>UscmRayMax:Rayon=0:EndIf
EndProcedure
Repeat
ExamineMouse()
ExamineKeyboard()
UseBuffer(0)
ClearScreen(RGB(100,100,100))
UscmDraw()
UseBuffer(-1)
ClearScreen(0)
DisplaySprite(0,0,0)
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)
End