Autor: Sven Bader (---.versanet.de)
Datum: 06.09.21 13:48
Hallo Markus,
falls es für dich noch relevant ist, hier ein funktionierender Code.
Ich habe die Frames zwischen den Bildwechseln berchnet sodass ich mit einem einfachen Modulo arbeiten kann. Dann stoppt die Rotation per if/elseif und die Animation des gewünschten Bildes erfolgt.
Etwas vorsichtig musst du sein bei einer evnetuellen Framerate Anpassung, da zumindest die "Physik" nun darauf angewiesen ist, dass du keinen Frame auslässt.
Declare fps%, tmr&, frm%, rT!, xFps&, yFps&, x&, y&, count&,x!,y!,z!,pics%,step!,frame&,framesperpic&,zoom&,animate%
CLS
oGL("Init", %hWnd, 0, 0, 0, 0)
Set("oGLDepth", 512)
oGL("PosMode", 1)
xFps& = create("Font", "Curier", 12, 0, 0, 0, 0)
yFps& = oGL("OutlineFont", xFps&, 0.0)
DeleteObject xFps&, yFps&
pics% = 30
framesperpic& = 10
step! = 2*Pi()/ pics% * (1/framesperpic&)
zoom& = -1
SetTimer 20
While 1
If &GetTickCount - tmr& >= 1000
fps% = frm%
tmr& = &GetTickCount
frm% = 0
EndIf
if zoom& = -1
'nur drehen, wenn gerade kein Bild gezoomt wird
inc frame&
rT! = rT! + step! : If rT! >=(Pi()*2): rT! = 0.0 : EndIf
endif
oGL("Clear")
oGL("Origin", 50, 40, -100)
oGL("Print", yFps&, str$(y&))
oGL("Fog", 2, 0.04, 0)
oGL("BlendMode",2)
oGL("Origin", 0, 0, -30)
For x&,0,pics%-1
oGL("push")
oGL("Texture", 0, 1)
x! = 10.1*sin(rT!+(x&*(2*Pi()/pics%)))
if (x& = zoom&)
inc animate%
z! = 17*cos(rT!+(x&*(2*Pi()/pics%))) + (sin(animate%*(Pi()*0.01)) * 11)
else
z! = 17*cos(rT!+(x&*(2*Pi()/pics%)))
endif
oGL("Move", x! , 0, z!)
oGL("Quad", 1.6, 1)
oGL("pop")
EndFor
if (animate% = 100)
animate% = 0
zoom& = -1
elseif (zoom& = -1) AND (frame& MOD framesperpic& = 0)
inc y& : if y& = pics% : y& = 0 : EndIf
zoom& = pics% -y&
endif
oGL("Show")
If IsKey(27)
End
EndIf
EndWhile
KillTimer
End
Grüße
Sven
|
|