With a centered origin:
view_xview = floor(player.x - (player.sprite_width>>1)*sign(mouse_x - player.x | 1) + mouse_x - view_wview >> 1);
view_yview = floor(player.y - (player.sprite_height>>1)*sign(mouse_y - player.y | 1) + mouse_y - view_hview >> 1);
If the origin is not centered, it'll be trickier. If you have the origin centered horizontally but at the very bottom of the sprite, then change (player.sprite_height>>1) to just player_sprite_height.
Of course if you put all this code in the player object, you don't even need the
player. part of it.
Alternative code:
Code:
if abs((mouse_x - view_xview - view_wview/2)) < view_wview>>2 && abs((mouse_y - view_yview - view_hview/2)) < view_hview>>2
{
var lr = x - view_wview/2 - view_xview;
var ud = y - view_hview/2 - view_yview;
view_xview += lr>>2;
view_yview += ud>>2;
}
else
{
var lr = sign(mouse_x - x | 1);
var ud = sign(mouse_y - y | 1);
if abs(x - mouse_x>>5)
view_xview = x - (sprite_width>>1)*lr + mouse_x - view_wview >> 1;
if abs(y - mouse_y>>5)
view_yview = y - (sprite_height>>1)*ud + mouse_y - view_hview >> 1;
}