4
\$\begingroup\$

I'm making a game which the user can use the arrow keys to scroll left and right to view the map. I had an issue with the health bars of my enemies being drawn way off even though I set them to be drawn at the x and y position of the enemy.

I tried to debug using the following line to draw something at mouse_x and mouse_y:

draw_text(mouse_x, mouse_y, "X");

The X on screen would be at the correct position (the mouse position) when the mouse was at 0, 0, BUT as the mouse was moved farther right or down, the respective x or y offset became bigger and bigger, almost like I said to draw the X at mouse_x * 1.5, mouse_y * 1.5.

I'm using a view (view[0]) to allow the user to scroll through the map, and I thought this might be the source of the issue. This is the code I used to allow the user to scroll left and right:

if (view_xview[0] < room_width - view_wview[0]){
    view_xview += clamp(room_width - view_xview[0], 0, 10);
}else{
    view_xview[0] = room_width - view_wview[0];
}

The same code was used for moving left, but reversed.

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Make sure that you haven't accidentally chosen "Draw GUI" rather than "Draw" to put this code in. These are two very different things in Game Maker. Draw uses the absolute x and y coordinates, whereas Draw GUI uses the position relative to the window.

\$\endgroup\$

You must log in to answer this question.

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