• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

(Solved) Display Manager & Start Screen

chefdez

Member
Hey all,

I'm having some difficulties with meshing the Start Screen & Display Manager codes that Spalding has in his tutorials. Everything is working properly EXCEPT for the fact that I am unable to draw text onto my start screen despite the 1 dimensional array being functional (ie starting the game and scrolling down to exit the game as the last option but not being able to see the text or the sprite).

I am very positive it is the display manager because this is the only object that runs before the start screen in my rooms.

Display Manager Create Event:
Code:
/// Display Properties
ideal_width = 0 ;
ideal_height = 135;
zoom = 1 ;
maxzoom = 1 ;

aspect_ratio = display_get_width()/display_get_height();

ideal_width = round(ideal_height*aspect_ratio);
ideal_height = round(ideal_width / aspect_ratio);

if(display_get_width() mod ideal_width != 0)
{
    var d = round(display_get_width()/ideal_width);
    ideal_width = display_get_width()/d;  
}

if (display_get_height() mod ideal_height != 0)
{
    var d = round(display_get_height()/ideal_height);
    ideal_height = display_get_height()/d;
}

// Check for odd number
if (ideal_width & 1)
    ideal_width++;
if (ideal_height & 1)
    ideal_height++;
  
// Calculate max zoom
// Always floor the calculation so that the window does not get bigger than the full screen size.
maxzoom = floor(display_get_width()/ideal_width);
  
// Set up view for every room so views tab will never need to be used.
// Every "room" in the tree is simply a number.
for (var i = 1; i <= room_last; i++)
{
 if (room_exists(i))
 {
    room_set_view(i, 0, true, 0, 0, ideal_width, ideal_height, 0, 0, ideal_width, ideal_height, 0, 0, 0, 0, -1);
    room_set_view_enabled(i, true);
    //room_goto(room_next(room));
   // if room_next(room) != -1 {room_goto(room_next(room));}
 }  
}

surface_resize(application_surface, ideal_width, ideal_height);
display_set_gui_size(ideal_width,ideal_height);
window_set_size(ideal_width, ideal_height);

if room_next(room) != -1 {room_goto(room_next(room));}
My array for the start menu drawing text:
Code:
draw_set_halign(fa_left);
draw_set_valign(fa_middle);
draw_set_font(fnt_options);
draw_set_color(c_black);

var m;
for (m = 0; m < array_length_1d(menu); m+= 1)
{
    draw_text_ext(x + space, y + (m * space), string(menu[m]), 1, 0)  
}

draw_sprite(sprite_index, 0, x + 16, y + mpos * space);
I'm not sure why text isn't being drawn. When I press enter it successfully starts the game and text can be drawn in game but specifically on this start screen it cannot.

I would appreciate any suggestions!!!
 

rIKmAN

Member
Pretty sure this code is originally by PixelatedPope from his YT tutorial, not Shaun.

For your issue, is your start screen room 0 / the first room in the list in the IDE?
If so, look at the for loop that sets each rooms properties - it starts from 1 as room 0 is the init room that is only visited once and used to setup all the other rooms in Popes tutorial.

If Shaun doesn't also do this in his tutorial then that could be the issue as it isn't getting setup the same way as all the other rooms.
 

chefdez

Member
Pretty sure this code is originally by PixelatedPope from his YT tutorial, not Shaun.

For your issue, is your start screen room 0 / the first room in the list in the IDE?
If so, look at the for loop that sets each rooms properties - it starts from 1 as room 0 is the init room that is only visited once and used to setup all the other rooms in Popes tutorial.

If Shaun doesn't also do this in his tutorial then that could be the issue as it isn't getting setup the same way as all the other rooms.
You're right, this may be a P Pope tutorial, honestly it slipped my mind but I'm not sure.

This is my current IDE set up (attached), with my menu given a blue background.

At the moment the code works, it moves on from display manager and right into the menu room 0 as a resized Blue room. However, no text is being drawn even though the code is working (ie press Enter and start game or press down 4 times and Enter to quit.).
 

Attachments

chefdez

Member
This is what happens when I change the IDE and have the menu run before the display manager.

No changes in code, the text draws without a problem! Thank you for helping!!
 

Attachments

chefdez

Member
The strange thing is when I play the actual game, text doesn't have a problem being drawn. It is only specifically on this menu screen D:
 

Attachments

rIKmAN

Member
Does a simple draw_text(20, 20, "Test") work?

The width argument is also set to 0 in the draw_text_ext() function which may be causing an issue.
 

chefdez

Member
Does a simple draw_text(20, 20, "Test") work?

The width argument is also set to 0 in the draw_text_ext() function which may be causing an issue.
I changed the draw text ext to a regular draw text function, no changes, the words still do not display

The draw text test works tho!

This is the create event for the menu if it helps
Code:
menu[0] = "Start"
menu[1] = "Continue"
menu[2] = "Level Select"
menu[3] = "Options"
menu[4] = "Quit"

space = 64;
mpos = 0;
 

Attachments

chefdez

Member
I played around with the values some more, it seems with the resolution I used it was displaying the text far off screen.

I changed the space value to 16, and used 20, 20 as the x and y values and got this!

Now I have to figure out where the pointer is haha
 

Attachments

chefdez

Member
yes ! sometimes I just gotta be talked thru it lmao. I should have paid more attention when Spalding said the values were arbitrary . Many thanks to you
@rIKmAN
 

Attachments

rIKmAN

Member
Print the values of the variables used in the for loop and see if they are what they should be, they seem to be the issue either being different than what you think they are or not drawing where you expect (ie. off screen).

Edit:
You posted while I was typing haha, glad you found the issue.
 

chefdez

Member
Print the values of the variables used in the for loop and see if they are what they should be, they seem to be the issue either being different than what you think they are or not drawing where you expect (ie. off screen).

Edit:
You posted while I was typin haha, glad you found the issue.
You're awesome thanks again!!
 
Top