Skip to content

Commit

Permalink
Fixes to state interpolation and to sfml.
Browse files Browse the repository at this point in the history
  • Loading branch information
Orpheon committed Sep 9, 2014
1 parent efccc2f commit 78a3cf8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion client/handler.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import sfml
import sfml.graphics
import json
import os.path

Expand Down
4 changes: 4 additions & 0 deletions client/rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ def render(self, client, game, frametime):
# Take the oldest one and move it back in time
self.interpolated_state = states[0].copy()
self.interpolated_state.update_all_objects(game, target_time - self.interpolated_state.time)
elif states[-1].time < target_time:
# Even our most current state isn't "up-to-date" enough
# We can't do better than use it
self.interpolated_state = states[-1].copy()
else:
# Now we need to find the two states that bracket target_time
# Easier to do this by looping over index
Expand Down
2 changes: 1 addition & 1 deletion engine/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self):
self.vertical = 0

def update(self, networker, frametime):
if abs(self.rendering_time - self.current_state.time) > 2:
if abs(self.rendering_time - self.current_state.time) > 0.5:
self.rendering_time = self.current_state.time - constants.PHYSICS_TIMESTEP
self.rendering_time += frametime + frametime*(self.current_state.time+self.accumulator - self.rendering_time)*constants.INTERP_SLIDING_WINDOW
self.accumulator += frametime
Expand Down
2 changes: 1 addition & 1 deletion function.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def load_texture(filename):
return textures[filename]

# Attempt to load the texture from files
texture = sfml.Texture.from_file(filename)
texture = sfml.graphics.Texture.from_file(filename)
textures[filename] = texture

return texture
Expand Down

0 comments on commit 78a3cf8

Please sign in to comment.