M
MANGOSENTINEL
Guest
Hi GMC, I've been working on a reverse tower defense game (you play the attacking force, I like to think of it as a strategy puzzle game almost) for awhile and I'm finally starting to see the light at the end of the tunnel where I worry about making my game look better as opposed to just, functioning. Which brings me to a concern my artist has been having: The camera for our game is..."jerky".
It's only jerky on some occasions, mostly the diagonals and I'm at a loss to what to do about it. Here's some background information if anyone can lend a hand:
Since I wanted to cage the mouse to the game window without doing a DLL, I developed a system with the help of a few friends that locks the mouse into the middle of the game window and feeds the mouse inputs into a "false" cursor, obj_cursor. I then use obj_cursor for all the purposes of a mouse, such as interacting with with menus or units on the field. In designing a camera for the game, my theory was to have a camera object that followed the cursor object at a set distance, and only moved the screen when the cursor got near the edge of the view. To that end, I've created a camera with this code:
Addittionally, I have the view set to follow my camera object with the following values:
Hborder = 800
Vborder = 450
Hspd = -1
Vspd = -1
I chose 800 and 450 since my port on screen for my game is 1600 x 900, despite my games view in room being 1920 x 1080. Not sure if that would cause issues or not.
While this is close to achieving the effect I want for a camera, I was wondering if anyone had advice or a better method for this, since I can't quite tweak the numbers to make them the way I want to.
Thanks in advance!!
It's only jerky on some occasions, mostly the diagonals and I'm at a loss to what to do about it. Here's some background information if anyone can lend a hand:
Since I wanted to cage the mouse to the game window without doing a DLL, I developed a system with the help of a few friends that locks the mouse into the middle of the game window and feeds the mouse inputs into a "false" cursor, obj_cursor. I then use obj_cursor for all the purposes of a mouse, such as interacting with with menus or units on the field. In designing a camera for the game, my theory was to have a camera object that followed the cursor object at a set distance, and only moved the screen when the cursor got near the edge of the view. To that end, I've created a camera with this code:
Code:
STEP EVENT:
//CAMERA CONTROLS
if distance_to_point(obj_cursor.x,obj_cursor.y) >= 400
{
var xTo, yTo;
move_towards_point(obj_cursor.x,obj_cursor.y,0)
xTo = obj_cursor.x + lengthdir_x(min(800,distance_to_point(obj_cursor.x,obj_cursor.y)),direction)
yTo = obj_cursor.y + lengthdir_y(min(450,distance_to_point(obj_cursor.x,obj_cursor.y)),direction)
x += (xTo - x)/25
y += (yTo - y)/25
}
//TWEEENING ??
view_xview[0]+=((x-(view_wview[0]/2))-view_xview[0])*.5
view_yview[0]+=((y-(view_hview[0]/2))-view_yview[0])*.5
//////CLAMP THE VIEW
view_xview[0]=clamp(view_xview[0],0,room_width - view_wview[0])
view_yview[0]=clamp(view_yview[0],0,room_height - view_hview[0])
Addittionally, I have the view set to follow my camera object with the following values:
Hborder = 800
Vborder = 450
Hspd = -1
Vspd = -1
I chose 800 and 450 since my port on screen for my game is 1600 x 900, despite my games view in room being 1920 x 1080. Not sure if that would cause issues or not.
While this is close to achieving the effect I want for a camera, I was wondering if anyone had advice or a better method for this, since I can't quite tweak the numbers to make them the way I want to.
Thanks in advance!!