2
\$\begingroup\$
    me = self;
    view_yview[0] += ( me.y-(view_hview[0]/2) - view_yview[0]) * 0.1;
    view_xview[0] += ( me.x-(view_wview[0]/2) - view_xview[0]) * 0.3;

This is the code I use to smooth camera movement in game maker. But it's going beyond the room dimensions; showing stuff that shouldn't be shown, as the camera should stop following the player at a point.

How do I achieve this?

\$\endgroup\$
1
  • \$\begingroup\$ I suggest that you give far more details than that so people familiar with game-maker can jump in with a proper answer. Per your code snippet, it is a 2D game. But is the camera isometric-positioned? Does the player move in 360 degrees, or 8 directions or 4 directions? Is it grid based? What is the code that is moving the camera? The camera should stop when the player is out of the room? \$\endgroup\$
    – MAnd
    Commented Nov 13, 2015 at 19:12

1 Answer 1

1
\$\begingroup\$

Try adding:

view_xview[0] = round(median(0, room_width - view_wview[0] - 1, view_xview[0]));
view_yview[0] = round(median(0, room_height - view_hview[0] - 1, view_yview[0]));

and you need not use me and self:

view_xview[0] += (x - view_wview[0] / 2 - view_xview[0]) * 0.3;
view_yview[0] += (y - view_hview[0] / 2 - view_yview[0]) * 0.1;
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .