Code : Tout sélectionner
InitSprite()
InitKeyboard()
InitMouse()
OpenScreen(1024, 768, 32, "")
Dim tableau(1500)
Dim tableau2(1500)
X1.f
Y1.f
posi.f
a.f
emp = -100 ; amplitude de depart
negampli = -140 ; amplitude inferieur
posampli = 140 ; amplitude superieur
decomp = 0 ; vitesse
z = 0
posi = 1
limite = posi * 80
zoom = 200
Repeat
ClearScreen(RGB(0, 0, 0))
;Initialise les données
prem = 0
x = 150
y = 500
a = 0
X1 = -150
Y1 = -150
emp + decomp
If emp > posampli Or emp < negampli
decomp = -decomp
EndIf
For i = 1 To 1000
tableau(i) = 1000
tableau2(i) = 0
Next
;Tracé
StartDrawing(ScreenOutput())
While a < limite
;Pour le Test des points à afficher ( gestion des points cachés ) ?
If prem = 0 Or tableau2(x) < y + z
tableau2(x) = y + z
EndIf
If tableau(x) >= y + z
tableau(x) = y + z
EndIf
x + 1
X1 + 0.5
z1 = (Cos((Sqr((X1 * X1) / zoom + (Y1 * Y1) / zoom)))) * emp
z = z1
If x < 760 + a
If y + z < tableau(x) Or y + z > tableau2(x) ; test les points à afficher
Plot(x, y + z, RGB( 0 , 255 , 255))
EndIf
Else
prem = 1
x = 150
X1 = -150
Y1 + 3.8
a + posi
y - 2
x + a
EndIf
Wend
StopDrawing()
;Gestion du clavier
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Left)
posampli + 1
negampli - 1
emp + 1
ElseIf KeyboardPushed(#PB_Key_Right)
posampli - 1
negampli + 1
emp - 1
EndIf
If KeyboardPushed(#PB_Key_Up)
zoom + 3
ElseIf KeyboardPushed(#PB_Key_Down)
zoom - 3
EndIf
;Affiche le résultat
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)