Frame unabhängig Bewegen/Animieren...usw
Übersicht

D²OBetreff: Frame unabhängig Bewegen/Animieren...usw |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Hallo, ich hoffe es ist für den einen oder anderen nützlich.
Man kann die fps ausgeben, die zeit einer Bewegung messen, in diesem Fall wie lange das oval vom pixel 0 bis Pixel 800 braucht und die zeitdauer ist bei 35 Fps genauso lange als wie bei 500 Fps. Info: Benutzt man bei der Methode mlooptime für L_tune den wert 2, sollten die Fps nicht über 600 sein, es funktioniert dann nicht mehr richtig, sollte aber eigendlich egal sein. Der Code ist nicht besonders Kommentiert, aber es sollte eigendlich jeder damit Klarkommen. Code: [AUSKLAPPEN] 'This application was written with BLIde http://www.blide.org 'Application: 'Author: [D²O]Slayer 'WWW: www.deuteriumoxid.com 'Mail: d2o@deuteriumoxid.com 'Description: ' Strict AppTitle = "Typetest" '#Region 'BildschirmModus 'BildschirmModus auswahl, DirctX7 oder OpenGL '0 = DX Standart '1 = OpenGL Global Drivermod:String Const Modus:Byte = 1 Select Modus Case 0 SetGraphicsDriver D3D7Max2DDriver:TD3D7Max2DDriver() Drivermod:String ="DX7" Case 1 SetGraphicsDriver GLMax2DDriver:TGLMax2DDriver() Drivermod:String ="OpenGL" Default SetGraphicsDriver D3D7Max2DDriver:TD3D7Max2DDriver() Drivermod:String ="OpenGL" EndSelect 'Bildschirm Grundeinstellungen Global winx:Short = 800 Global winy:Short = 600 Global winmode:Short = 0 '0 = FensterModus 'ansonsten Farbtiefe für für den Vollbildmodus 'angeben, z.B. 16 oder 32 Global winframe:Int = -1 'Bildschirmwiederholung angeben '0 = Vsync von der Treibereinstellung übernommen '-1 Vsync Off '#EndRegion Graphics winx,winy,winmode,winframe 'neue Instancen von den Typen Tliftime und Tlooptime erstellen Global lifetime:tlifetime = New tlifetime Global getliftime:Int Global test:tlooptime = New tlooptime Global posx1:Int = 0 Global posx2:Int = 0 Global i:Int While Not KeyHit(KEY_ESCAPE) test.mlooptime If posx1 <= 0 Then lifetime.mlifetime posx1 = posx1 + posx2 If posx1 > 800 posx1 = 0 getliftime = lifetime.mlifetime(1) EndIf DrawOval posx1,300,5,5 'künstliche verzögerung For i = 0 To 35000 Next 'frame ausgabe DrawText f_myframe()+" Frames in der secunde",550,10 DrawText "Der Ball braucht "+getliftime+" Millisecunden",10,10 DrawText "Der Wert von Posx2 = "+posx2,10,20 Flip Cls posx2 = test.mlooptime(1,1) Wend End 'Funktion für die Frame ausgabe Function f_myframe:Int( l_in:Short = 1000) Global gfps:Int, gtempfps:Int ,gtime:Int If MilliSecs()- gtime>l_in gfps = gtempfps gtempfps = 0 gtime = MilliSecs() EndIf gtempfps:+1 Return gfps End Function 'Type um die Lebensdauer zu messen Type Tlifetime Field timestart:Float Field timeend:Float Method mlifetime:Float(l_in:Byte = 0) Local l_out:Float If l_in = 0 Then timestart = MilliSecs() If l_in <> 0 timeend = MilliSecs() l_out = timeend - timestart End If Return l_out End Method End Type 'Type für Frame unabhängiges Bewegen,Animieren ....usw. Type Tlooptime Field loopstart:Int Field loopend:Int 'l_mode 0/1 für start/ende 'l_move, für bewegung in pixel 'l_tune, bewegung habieren, 1 oder 2, einfach testen Method mlooptime:Int(l_mode:Byte = 0,l_move:Int = 1,l_tune:Int = 1) Local l_out:Int If l_mode = 0 Then loopstart = MilliSecs() 'Startzeit If l_mode <> 0 loopend = MilliSecs() 'Endzeit l_out = l_move * (loopend - loopstart) End If l_out = l_out/l_tune Return l_out End Method End Type |
||
Blitz+; Blitz3d; BlitzMax; GLBasic; Purebasic;
GameMaker Studio 1.4xx; AGK; |
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group