//Update camera coordinates. if keyboard_check(ord('A')) x -= pan_speed; if keyboard_check(ord('D')) x += pan_speed; if keyboard_check(ord('W')) y -= pan_speed; if keyboard_check(ord('S')) y += pan_speed; //Update camera scale, correct out of bounds zoom scales, //and handle directional camera movement if mouse_wheel_down() or mouse_wheel_up() { if mouse_wheel_down() zoom_scale += zoom_tick; if mouse_wheel_up() zoom_scale -= zoom_tick; if zoom_scale > zoom_scale_max zoom_scale = zoom_scale_max; if zoom_scale < zoom_scale_min zoom_scale = zoom_scale_min; //Okay to us zoom_scale now. zoom_scale has been updated. //Ratio of mouse coordinates on window to dimensions of window. var x_ratio = window_mouse_get_x() / window_get_width(); var y_ratio = window_mouse_get_y() / window_get_height(); //Projected new view dimensions var new_width = room_width * zoom_scale; var new_height = room_height * zoom_scale; //Set coordinates x = mouse_x - (new_width * x_ratio) + (new_width / 2); y = mouse_y - (new_height * y_ratio) + (new_height / 2); } //finalize camera coordinates before here //Check out of bounds for camera object. if x > room_width x = room_width; else if x < 0 x = 0; if y > room_height y = room_height; else if y < 0 y = 0; //Update _wview and _hview to scale view_wview[0] = room_width * zoom_scale; view_hview[0] = room_height * zoom_scale; //finalize _wview and _hview before here //Update camera coordinates. view_xview[0] = x - view_wview[0] / 2; view_yview[0] = y - view_hview[0] / 2; if view_xview[0] < 0 view_xview[0] = 0; if view_xview[0] + view_wview[0] > room_width view_xview[0] = room_width - view_wview[0]; if view_yview[0] < 0 view_yview[0] = 0; if view_yview[0] + view_hview[0] > room_height view_yview[0] = room_height - view_hview[0];