Code-Beispiel
Animation mit PUT
Lizenz: | Erster Autor: | Letzte Bearbeitung: |
k. A. | Lothar Schirm | 19.08.2015 |
Eine kleine Animation: Drei Monde umkreisen den SATURN
'Kreiszahl pi:
Const pi = 4 * ATn(1)
'RGB-Farbkonstanten der Farbindizes 0 bis 15:
Const black = &H000000, blue = &H0000AA, green = &H00AA00, cyan = &H00AAAA, _
red = &HAA0000, magenta = &HAA00AA, brown = &HAA5500, grey = &HAAAAAA, _
darkgrey = &H555555, lightblue = &H5555FF, lightgreen = &H55FF55, _
lightcyan = &H55FFFF, lightred = &HFF5555, lightmagenta = &HFF55FF, _
yellow = &HFFFF55, white = &HFFFFFF
Dim As Any Ptr Buffer0, Buffer1, Buffer2, Buffer3
Dim As Single x, y, dphi1, dphi2, dphi3, phi1, phi2, phi3, r1, r2, r3, x1, _
y1, x2, y2, x3, y3
Dim As Integer i
Screenres 640, 480, 32, 2
WindowTitle "Saturn"
'Bildhintergrund:
Buffer0 = ImageCreate(640, 480, 0)
'Sternenhimmel:
Randomize Timer
For i = 0 To 1000
x = 640 * Rnd(1)
y = 480 * Rnd(1)
PSet Buffer0, (x, y)
Next i
'Saturn-Himmelskoerper (gelb):
Circle Buffer0, (320, 240), 75, yellow,,,,F
'Saturn-Ringe (braun):
For i = 0 To 10 Step 2
Circle Buffer0, (320, 240), 150 + 3 * i, brown, (0.66 - .003 * i) * pi, (0.34 + .003 * i) * pi, .2
Next i
'Roter Satellit:
Buffer1 = ImageCreate(32, 32)
Circle Buffer1, (16, 16), 15, red,,,,F
'Blauer Satellit:
Buffer2 = ImageCreate(42, 42)
Circle Buffer2, (21, 21), 20, lightblue,,,,F
'Gruener Satellit:
Buffer3 = ImageCreate(36, 36)
Circle Buffer3, (18, 18), 17, green,,,,F
'Parameter fuer Satellitenbahnen:
dphi1 = 2 * pi / 500
dphi2 = .7 * dphi1
dphi3 = .3 * dphi1
r1 = 195
r2 = 210
r3 = 230
phi1 = 0
phi2 = 2 * pi / 3
phi3 = 4 * pi / 3
ScreenSet 1, 0
Do
Cls
'Speicherinhalte in Bild einfuegen:
Put (0, 0), Buffer0, PSet
x1 = 320 + r1 * Sin(phi1)
y1 = 240 + 0.6 * r1 * Cos(phi1)
Put(x1 - 15, y1 - 15), Buffer1, Trans
x2 = 320 + r2 * Sin(phi2)
y2 = 240 + 0.7 * r2 * Cos(phi2)
Put(x2 - 20, y2 - 20), Buffer2, Trans
x3 = 320 + r3 * Sin(phi3)
y3 = 240 + 0.8 * r3 * Cos(phi3)
Put(x3 - 25, y3 - 17), Buffer3, Trans
ScreenSync
ScreenCopy
'
phi1 = phi1 + dphi1
phi2 = phi2 + dphi2
phi3 = phi3 + dphi3
Loop Until InKey = Chr(255, 107)
ImageDestroy Buffer0
ImageDestroy Buffer1
ImageDestroy Buffer2
ImageDestroy Buffer3
End
Zusätzliche Informationen und Funktionen | |||||||
---|---|---|---|---|---|---|---|
|
|