Post by dwmitch on Sept 1, 2004 2:50:14 GMT -5
I notice in games such as the Final Fantasy series the character has to be directly in the center of the screen for the view to follow them. I have figured out to an extent how to achieve this using the following:
The problem is, if I have a room with a width of 640 it will put the rightmost boundary in the center of the view before it stops.
Setting the draw event for the player to draw view_left[0] + view_width[0] shows that at the start, with a 640 x 480 viewport, the rightmost boundary is already at the room width in a 640 by x room, meaning it shouldn't move.
However, when the player walks to the right (direction 0) once he gets to the x center of the view it will keep going until the rightmost boundary is at 960, which is well beyond the boundary defined in the room settings (as confirmed by having the player object draw the room width).
I suspect that the problem lies with the first if statement, but I don't know how to fix it. I've tried just using view_width[0] alone with the same results. I've tinkered with the statement that keeps the view centered on the player (to keep from interrupting the scrolling when the player hits an object and doubles back), but that allowed the view to move infinitely.
If anyone wants to try out this code, it is a script run in the step event of the player character, with vel being declared in the create event of said character.
Problem fixed. Source code removed due to newly realized security issues.
The problem is, if I have a room with a width of 640 it will put the rightmost boundary in the center of the view before it stops.
Setting the draw event for the player to draw view_left[0] + view_width[0] shows that at the start, with a 640 x 480 viewport, the rightmost boundary is already at the room width in a 640 by x room, meaning it shouldn't move.
However, when the player walks to the right (direction 0) once he gets to the x center of the view it will keep going until the rightmost boundary is at 960, which is well beyond the boundary defined in the room settings (as confirmed by having the player object draw the room width).
I suspect that the problem lies with the first if statement, but I don't know how to fix it. I've tried just using view_width[0] alone with the same results. I've tinkered with the statement that keeps the view centered on the player (to keep from interrupting the scrolling when the player hits an object and doubles back), but that allowed the view to move infinitely.
If anyone wants to try out this code, it is a script run in the step event of the player character, with vel being declared in the create event of said character.