ID:2428953
 
(See the best response by Ter13.)
im trying to make a turn based sidescroller and i want the player to be able to move the camera around without moving the mob. any advice on how can i do this?
client/perspective = EYE_PERSPECTIVE


and then you would modify the location/offset of the mob's eye as needed.
how do i do that though? the only example i see is using
client/eye=locate(5,5,1) how do i move the eye left/right or up/down
In response to Surge mage
Surge mage wrote:
how do i do that though? the only example i see is using
client/eye=locate(5,5,1) how do i move the eye left/right or up/down

Use animate() on ,client pixel_x and pixel_y.


@Edited
Try:
mob/proc/MoveScreen(X,Y)
animate(src.client, pixel_x = X, pixel_y = Y, time = 5)

Code:
mob/proc/movescreen(X,Y)
animate(src,client.pixel_x=X, client.pixel_y=Y,time=5)
mob/verb/pancamleft()
movescreen(2,0)


Problem description:
ok thanks now it just says error index list out of bounds
Because i made mistake it is how should looks like
mob/proc/movescreen(X,Y)
animate(src.client,pixel_x=X, pixel_y=Y,time=5)
mob/verb/pancamleft()
movescreen(2,0)

Code:
mob
proc
movescreen(X,Y)
animate(src.client,pixel_x=pixel_x+X, pixel_y=pixel_y+Y,time=5)


Problem description:
cool is there a way to keep scrolling instead of stopping? i couldnt get it to happen ^
What do you mean? Could you give us more details about what do you want to do?
Maybe you want something like in MOBA or RTS games, so then i think the best way is build something like "camera control system" independent of players mob.

Check
http://www.byond.com/developer/forum_account/pixelmovement
sure cant get the demo to load though says: error unable to open <forum_account\keyboard>
think of like 2dtanks games i want to be able to scroll around the entire map basiclly
In response to Surge mage
Surge mage wrote:
sure cant get the demo to load though says: error unable to open <forum_account\keyboard>

Delete this lib and download it again. If you will still have a problem, try to stop your antivirus.

think of like 2dtanks games i want to be able to scroll around the entire map basiclly

If you mean somethink like "Worms" series, just make a obj, focus client.eye on it and just move itas you like.

Code:
mob
var
Controls/controls = new()

// implement the default key_up and key_down behavior
key_down(k, client/c)
#ifndef TWO_DIMENSIONAL
if(k == controls.jump)
if(can_jump())
jump()
#endif

key_up(k, client/c)


Problem description:/b>
well it didnt seem to work with the sidescroller library but with the pixel movement one im getting an error:key_down:undefined proc
Best response
If you want control of the camera to be separate from the position of the mob, the best way to do it is to set the client.eye to a different mob than the player mob.

The problem with just animating the client pixel_x/y, is that it just shifts the viewport. It doesn't actually change the location of the viewport, so the edges of the viewport are still not expanding when the pixel values are moved too far.

This will result in weirdness. It's better to use a different mob to control the camera.

Here's an example of the above in effect:



A very simple implementation of this could look something like this:

mob
appearance_flags = LONG_GLIDE
camera
invisibility = 101
density = 0
glide_size = TILE_WIDTH
var
client/viewer
proc
transition(atom/start,atom/end,duration)
var/sx = start.x + viewer.pixel_x/TILE_WIDTH, ox = end.x-sx, cx
var/sy = start.y + viewer.pixel_y/TILE_HEIGHT, oy = end.y-sy, cy
loc = locate(sx,sy,start.z)
var/st = world.time, et = st+duration, t, ct
while(viewer.eye==src)
if((t = world.time)<=et)
ct = (t-st) / duration
cx = sx + ox * ct
cy = sy + oy * ct
if(round(cx)!=x||round(cy)!=y)
loc = locate(cx,cy,z)
viewer.pixel_x = (cx-x)*TILE_WIDTH
viewer.pixel_y = (cy-y)*TILE_HEIGHT
sleep(world.tick_lag)
loc = null
simple to you lol
looks great but what do i put in the args i dont quite understand and can i just use 32 instead of tile_width/height
My implementation is tile-based, so it won't be exactly what you need, but the math will be largely the same for whatever you use. My implementation takes a starting turf or object, and an ending turf or object on the map, and a duration over which to perform the transition.