ID:775186
 
(See the best response by Kaiochao.)
Code:
turf
MouseEntered()
//MouseEntered() is used to give mouse scrolling.
set background = 1
var/mob/M = usr
if(M.camera_lock)
return()
if(M.no_scroll)
return()
M.mouse_loc = src //Mouse location stored, then checked after a delay to make sure the usr is still edging the cursor.
sleep(2)
if(M.mouse_loc != src)
return()
var/atom/eye_loc = M.client.eye

//The operation below finds an ellipse where P is the turf the cursor is over.
var/eye_x = eye_loc.x
var/eye_y = eye_loc.y

var/delta_x = eye_x - src.x
var/delta_y = eye_y - src.y

delta_x = delta_x**2
delta_y = delta_y**2

delta_x /= 289 //View (width/2) - 1, squared.
delta_y /= 64 //View (height/2)- 1, squared.

var/R = delta_x + delta_y

//Then, it compares the ellipse with the expected ellipse, given the view size.
if(R >= 1)
var/dir = get_dir(M.client.eye, src)
var/new_loc = get_step(M.client.eye, dir)
M.client.eye = new_loc


Problem description:

Alright. Here's my work-in-progress code for edge scrolling. I'm worried about two things:

A) The mass Mouse_Entered() callings. I tried to design in quick breaks if the scroll is turned off by the player, but I'm assuming most will use it.

B) Simply setting the eye to the new loc. Is there a better way to do this, rather than just teleport it one step? This makes it very jumpy.

C) Also, this assumes my default view size. I'm planning on generalizing this later.

Actually, is there a better way to do this overall?
client
lazy_eye = 5

Would be my suggestion.
Sorry, maybe I didn't explain the purpose of this very well.

This allows the player to hold their cursor at the edge of the screen and have the screen scroll in that direction. The mob doesn't move. The eye isn't connected to a mob at that point, so lazy_eye wouldn't do much.
Best response
A good method to use is to attach the eye to an invisible object that you can then move around. Smoothly.
When The Player Moves the Mouse North South etc u want the screen to move that way ? leaving the Person where they are ?
Kaiochao: I'm going to experiment with that tonight. I'll vote if it works out.

Edit: That made a huge difference, and was ridiculously easy to switch over to. Thanks.

The Motto: Yep. But only if the mouse is at the edge of the visible map. It's similar to the method found in most strategy games to move the screen.

Unfortunately, it would make more sense to scroll when the cursor bumps the edge of the view (including bottom-screen UI elements), but I haven't found a way to do this.

On second thought, I may just make the player's mob the invisible object controlling everything, and the "main" character a secondary mob controlled as normal.

BACK TO THE DRAWING BOARDS.