Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Screen Speed
#4
exact position calculation:

take the average of all (players that are alive)'s x coordinates (on the same computer), store it in avgX

next variable, start with 0, and add 1 for every player facing right, and subtract 1 for every player facing left, store this in facing

let xLimit be where we want the camera to move to, screenW be 792 (lf2 window width), and halfW= 792/2 = 396.

also, let numPlayers be the number of alive players on the current computer

the calculation for xLimit is:
xLimit=
(facing × screenW) / (numPlayers × 6) - (halfW + avgX)

if xLimit < 0, then xLimit = 0
if xLimit > background's width - screenW then xLimit = background's width - screenW


kayz so that's where the camera will scroll to assuming the characters don't move from their current positions. but since we want to implement a smooth scroll (the dvx: of the camera), instead of making the camera's x position = xLimit, we would do:

x = currentX + (xLimit - currentX position) / 8

---

I'm 80% sure that that's the exact algorithm that lf2 uses (i know xLimit is exactly the same as lf2's, but not sure about the x scrolling speed. if any of you still have the java HQ running, then you could check by running them side by side



Azriel~
Reply
Thanks given by: Magnamancy


Messages In This Thread
Screen Speed - by Magnamancy - 03-14-2010, 09:26 AM
RE: Screen Speed - by prince_freeza - 03-14-2010, 09:33 AM
RE: Screen Speed - by Silverthorn - 03-14-2010, 10:39 AM
RE: Screen Speed - by Azriel - 03-15-2010, 06:42 AM



Users browsing this thread: 1 Guest(s)