03-15-2010, 06:42 AM
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~
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~

Chat
![[Image: ZucdcMY.png]](https://i.imgur.com/ZucdcMY.png)