N
netscaped
Guest
Hey all, I'm very, very new to gml, but what I tried to do here was to slowly move my camera to the desired coordinates (It's a very uh, pixelated game, so 1px per loop wouldn't be too slow), but it doesn't seem to do anything except freezing the game up. I've tinkered with it for a while now, but I just can't seem to understand what's wrong, I would hugely appreciate any help.
GML:
//the x y i want my camera to move to
goal_x = 180;
goal_y = 25;
//record x y before moving, so i can pan back later
before_view_x = camera_get_view_x(view_camera[0]);
before_view_y = camera_get_view_y(view_camera[0]);
//set the recorded coordinates as variables for current x y
view_now_x = before_view_x;
view_now_y = before_view_y;
//calculates how much the camera is off before loop
x_to_go = view_now_y - goal_x;
y_to_go = view_now_y - goal_y;
//loop for moving the camera
while x_to_go != 0 or y_to_go != 0
{
//horizontal
if x_to_go > 0
{
camera_set_view_pos(view_camera[0], view_now_x-1, view_now_y);
}
if x_to_go < 0
{
camera_set_view_pos(view_camera[0], view_now_x+1, view_now_y);
}
x_to_go = view_now_x - goal_x;
view_now_x = camera_get_view_x(view_camera[0]);
//vertical
if y_to_go > 0
{
camera_set_view_pos(view_camera[0], view_now_x, view_now_y-1);
}
if y_to_go < 0
{
camera_set_view_pos(view_camera[0], view_now_x, view_now_y+1);
}
y_to_go = view_now_y - goal_y;
view_now_y = camera_get_view_y(view_camera[0]);
}