This is my first StackExchange post, so forgive me if I make a silly mistake.

Getting to the point, I've made a simple Mario-esque platformer where whenever you die, game over text is printed to the middle of wherever you are on the screen. Dying is an Instance Destroy event triggered by various objects, while the Draw GUI event is triggered by a separate object placed in each room.

The third and final "level" room is where text doesn't appear no matter where you die. I've made multiple attempts to fix this, but nothing appears. I believe part of it involves the room's layout; the other levels were simple "go to the right" styled rooms. The third room goes vertically and is much taller.

The issue also likely involves the camera. I'm using viewport[0]. Room properties are as follows:

  • Room settings - Width: 3000, Height: 3000

  • Clear Viewport Background: ON

  • Camera - X Pos: 0, Y Pos: 2250, Width: 1080, Height: 768

  • Viewport - X Pos: 0, Y Pos: 0, Width: 1080, Height: 768

  • Following object: obj_playercube (player object) (Hor. border: 400, Vert. border: 400, Hor. speed: 200, Vert. speed: 200)

This is the code for obj_gameover's Draw GUI event:


// (x, y) coordinates of the center of the view

var center_x = view_xview[0] + view_wview[0]/2;

var center_y = view_yview[0] + view_hview[0]/2;

if (!instance_exists(obj_playercube))


    draw_text(center_x, center_y, "Game Over\n Press Enter to restart from current room.");
    show_debug_message("Game over has printed");


I'm sure it's a matter of adding more variables to account for the room's differing properties compared to the others. I'll try to figure it out myself in the meantime.

  • 1
    \$\begingroup\$ Assume any links you include will rot one day, and ensure all information needed to understand and answer your question is included in the post itself. That includes the relevatn code. If your full code is too large to include, then you'll need to do some work to simplify it to the smallest snippet that demonstrates the issue - what we call a Minimal Complete Verifiable Example (MCVE). \$\endgroup\$
    – DMGregory
    Jun 16, 2018 at 15:41
  • \$\begingroup\$ OK, you have a point. I'll edit the question to include the code without the link. \$\endgroup\$ Jun 16, 2018 at 17:04

1 Answer 1


Hi and welcome to Gamedev Stack Exchange!

Both of your variables center_x and othercenter_x are always equal so there is no reason to have two of them. The formula looks correct to me and should be working fine in any given scenario.

Debugging is an iterative process. Let's assume that, since we believe the formula is correct, something else is failing which prevents us from seeing the message. You'll have to go through each step to find out which exact one is misbehaving.

Since the third room is the only one where it doesn't work, maybe the object isn't placed there? Try printing your debugging message to make sure that the player's death does in fact trigger the event and the debug message appears. Maybe the positioning is wrong? Print all the variables involved (or better yet, use the debugger and access them directly) and see if their values are what you expect.

If the bug persists, please post your findings here so we can help. At this point there simply isn't enough information to make an accurate guess of what goes wrong here.

  • \$\begingroup\$ Based on what I did find, the variables I have should work even for the third room. I'll go through the game and try what you suggested. Thanks. \$\endgroup\$ Jun 15, 2018 at 21:08
  • \$\begingroup\$ I put a breakpoint when the event is supposed to draw. The values of the variables are always the same: center_x = 540 and center_y = 2634. Since center_y is dividing the viewport's height, shouldn't it be 384 instead? That's what my math tells me. \$\endgroup\$ Jun 16, 2018 at 17:36
  • \$\begingroup\$ The values should be correct. Remember that you add the camera's position to it after dividing height/width by 2. So if the camera's Y position is 2250, then we'll get 2634 in the end. What confuses me is that the values are always the same. Try testing it by dying in different locations to get the camera move there. \$\endgroup\$
    – altskop
    Jun 16, 2018 at 18:13
  • \$\begingroup\$ Oh doi. I didn't realize that the variables referred to the camera(I thought they were the view). That makes more sense; I'm still new to GameMaker. So I did die in different locations, and the values for center_x and y were always the same. I tested this in the previous rooms, and they also keep the same values throughout, yet the Game Over text still appears. I noticed the difference between them was the camera; 1 & 2 are both X & Y =0. Room 3 obviously has Y = 2250. \$\endgroup\$ Jun 16, 2018 at 20:21
  • \$\begingroup\$ The camera's height in each room (except 3) is also set to the room's height. In room 1, it's 800, in 2 it's 900. For 3, I couldn't make it 3000 because it wouldn't display what I wanted, which was the bottom left corner of the screen. I'm going to play around with the view and camera settings and see if that does anything. \$\endgroup\$ Jun 16, 2018 at 20:27

You must log in to answer this question.

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