Frame Unabhängig?

Übersicht BlitzBasic Allgemein

Neue Antwort erstellen

 

Jey

Betreff: Frame Unabhängig?

BeitragMo, Okt 31, 2005 19:29
Antworten mit Zitat
Benutzer-Profile anzeigen
Hallo, ich versuche gerade, die Bewegungsgeschwindigkeit meines Charakters konstant zu halten, egal welchen frameanzahl ich habe.
Dazu benutze ich folgenden Code aus dem Forum
Code: [AUSKLAPPEN]

RT#=(MilliSecs()-timer)/1000 : timer#=MilliSecs()


meine bewegung schaut dann so etwa aus:
Code: [AUSKLAPPEN]

px#=px#+speed*RT#


Nur leider ruckelt das ziemlich, also die bewegung ist gerade nicht konstant. Vieleicht hab ich da irgend ein Fehler gemacht jedoch arbeite ich an einem Multiplayergame, wo schließlich alle Spieler gleich schnell sein sollten Wink Danke schonmal

D2006

Administrator

BeitragMo, Okt 31, 2005 20:19
Antworten mit Zitat
Benutzer-Profile anzeigen
Hi,

probier mal:
Code: [AUSKLAPPEN]
RT#=(MilliSecs()-timer)/1000.0 : timer#=MilliSecs()


Liegt wohl an der Integer Division.

MfG
D2006
Intel Core i5 2500 | 16 GB DDR3 RAM dualchannel | ATI Radeon HD6870 (1024 MB RAM) | Windows 7 Home Premium
Intel Core 2 Duo 2.4 GHz | 2 GB DDR3 RAM dualchannel | Nvidia GeForce 9400M (256 MB shared RAM) | Mac OS X Snow Leopard
Intel Pentium Dual-Core 2.4 GHz | 3 GB DDR2 RAM dualchannel | ATI Radeon HD3850 (1024 MB RAM) | Windows 7 Home Premium
Chaos Interactive :: GoBang :: BB-Poker :: ChaosBreaker :: Hexagon :: ChaosRacer 2

Dante

BeitragMo, Okt 31, 2005 22:25
Antworten mit Zitat
Benutzer-Profile anzeigen
vieleicht hilft das.
bei mir rucklt da dann nix^^

Edit: voher aber ne Sek warten bis der das berechnet hat, sonst springt der zu weit.

Code: [AUSKLAPPEN]
Graphics 800,600, 0, 2
SetBuffer BackBuffer()

Global frames# = 0.0, fpstime# = 0.0, fps# = 0.0
Global speed# = 150.0, tempo# = 0, x# = 0.0, y# = 0.0

Repeat
Cls
getFPS()

timer# = (1.0 / fps#)
tempo# = speed# * timer#

If KeyDown(205)
x# = x# + tempo#
EndIf
If KeyDown(203)
x# = x# - tempo#
EndIf
If KeyDown(200)
y# = y# - tempo#
EndIf
If KeyDown(208)
y# = y# + tempo#
EndIf

Rect x#, y#, 32, 32, 0
Text 0, 0, "Speed:" + tempo#
Text 730, 0, "FPS:" + Int(fps#)

Flip
Until KeyDown(1)

Function getFPS()
frames# = frames# + 1

If fpstime# + 1001.0 < MilliSecs()
fps# = frames#
frames# = 0.0
fpstime# = MilliSecs()
EndIf

End Function
  • Zuletzt bearbeitet von Dante am Di, Nov 01, 2005 12:22, insgesamt 2-mal bearbeitet
 

Jey

BeitragDi, Nov 01, 2005 0:54
Antworten mit Zitat
Benutzer-Profile anzeigen
Danke für die Antwort, bei mir muss es sich nur um einen Rundungsfehler gehandelt haben Wink

Neue Antwort erstellen


Übersicht BlitzBasic Allgemein

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group