• 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!

Legacy GM Pause menu on an extra large room.

J

JonSnowShoveler

Guest
I’m trying to create a pause menu to choose between ship colors in a long hallway type room in my ship shooter. Room size 1280 X 10,000


I’m following what the tutorial on making a Breakout game said about creating a sprite from the application layer and then drawing it to my screen along with my pause menu sprite. The problem is that I’m using views to make the game look like it’s only 1280 x 720.

My ship can be anywhere along this hallway at any point that I pause the game and I don’t want it to create or draw the entire room. Maybe this huge sprite would work for showing the game frozen in time, but how do I even show my pause menu correctly in the view?

If my ship were somehow static in the middle of the screen at all times it’s possible there is some math to be done to determine the x,y of where I’d need to create and draw, but since the ship is always anywhere in the room I can’t use it as an anchor. There must be a way to use the current view to do this.

Any help would be appreciated.

BTW I did find this information on making the room persistent and then changing rooms to a pause room, but it doesn't really seem to help with figuring out the sprite creation dimensions and placement.

https://forum.yoyogames.com/index.p...-the-pause-function-in-my-game.784/#post-7307

I also don't understand how to accomplish the final post's solution of creating fake objects with sprites. Seems even more complicated.
 
Last edited by a moderator:
P

ParodyKnaveBob

Guest
Howdy, Jon, and welcome to GM and the GMC. $:^ ]

You didn't post what you've tried so far. Have you tried? $:^ } The thing is, the application surface should only be showing what's in your view anyway, thus your gigantic room shouldn't have any bearing on it, and you should still be able to make an expected-size pause screen from it.

I hope this helps,
Bob
 
J

JonSnowShoveler

Guest
Howdy, Jon, and welcome to GM and the GMC. $:^ ]

You didn't post what you've tried so far. Have you tried? $:^ } The thing is, the application surface should only be showing what's in your view anyway, thus your gigantic room shouldn't have any bearing on it, and you should still be able to make an expected-size pause screen from it.

I hope this helps,
Bob
Oh, I'm so sorry. I've been learning new things all day now and I'm pretty tired, but from reading the help documentation I couldn't find a solid answer on where the values were creating from exactly. The help files for both the create function and the application surface didn't specify that it was only the currently view-able area. THANKS!

I didn't attempt to do it because it seemed daunting to try and math it out based on the info I had.

EDIT:
Oh, I see where I messed up. The tutorial has you create the height of the application_surface sprite as room_height and that's where I got confused and assumed it would copy the whole thing.

I think instead I might need to just put in the view height of 720 pixels for the h value?
 
Last edited by a moderator:
J

JonSnowShoveler

Guest
Ok, well. You are right that it creates from the application_surface only what is on my screen, but I can't seem to get it to draw only to where my screen is. The game draws everything from the top of the room instead. Here is an example of what is shown when my ship is near the top end of the room, but not quite.




Here is my code. I need a better way to draw these items to the screen in a dynamic position beyond using basic x,y values and room_height. The room_width works out fine though because it's the same as the view width.




Of course, my pause menu for ship choice is going to end up halfway down the room (due to me drawing it as room_height / 2), so I understand why I'm not seeing that drawn. It comes back down to how do I tell it where to draw based on where my view currently is?

EDIT:
I looked more into how to DRAW TO a surface since the application surface is my current view only and I wanted to use that. I found this in the draw surface help index.

draw_surface(surf, view_xview[0], view_yview[0]); //Note that I am stealing only the view coordinates and not actually using the draw surface part.

This is working for drawing the application surface sprite I've created and placing it perfectly into my view, but my pause menu sprite is way off in the top left corner of my screen. I'll have to try to figure out the way to get that moved to the middle. The white rectangle overlay isn't even showing up at all now so I must be jacking that up pretty bad.


Also, I hope nobody is upset by me working things out on here hoping for help as I help myself. Writing it all out and knowing this is being viewed by others helps me scrutinize what I'm doing better and forcing me to try harder to figure it out. So I apologize if this thread offends anybody.

EDIT 2:
Ok, I've tried to fix the pause menu sprite draw by setting it's origin to 0, 0 but that just put it in the top left corner, whereas I want it to be in the middle and the sprite isn't the same size as the room itself, so I changed it to be -640 x -360 which isn't ending up in the middle, but at least it's progress. It just seems awkward to set the sprite's origin so far to the side so I'll probably need to edit the draw values better.


EDIT 3:
Herpa derpa. Seems all I had to do was set the pause menu sprite back to center origin and then offset the view coordinates in the draw function with + 1/2 of the screen width and height, which is 640, 360. So I got that worked out :)



Also managed to fix the white overlay being drawn using the same logic. Wow, this view_*view[0] variable is amazing! I'm so glad it exists and it opens up my options so much more! Now the only thing left to do is get the create from surface function to NOT create the ship's sprite, it looks off having 3 ships on the screen when paused like that.

I also gotta say that it's super satisfying to have such a struggle and then to come up with a solution. I felt elated when it finally worked the way I wanted it to. If this is the pay off that hard programming work gives then I look forward to future challenges. I hope that one day I become proficient but I can't forget the moment because these are precious times as well. You are only a noob once.
 
Last edited by a moderator:
P

ParodyKnaveBob

Guest
Also, I hope nobody is upset by me working things out on here hoping for help as I help myself. Writing it all out and knowing this is being viewed by others helps me scrutinize what I'm doing better and forcing me to try harder to figure it out. So I apologize if this thread offends anybody.
I'll be offended if anyone's offended by you working out your own problems and logging the progress for future readers to see. $E^ ]

Fyi, thank you for giving an exact copy of your Execute Code actions, but for the most part you can just select all the text in such an action (Ctrl+A), copy it (Ctrl+C), then come here and Insert...->Code and paste it (Ctrl+V) ... or, if you prefer, type [code], paste it, then type [/code]. (That's what I do.) This gives you something like the following:

Code:
/// My Awesome Code Block
variable = "set!";
function("get!");
repeat (9001) {
  other_great_things_naturally("!");
}
$:^ P

That said, I believe you'll find a lot of your headache above comes from the arguments you're supplying the sprite_create_from_surface() function.

Straight from the manual:
Syntax:
sprite_create_from_surface(index, x, y, w, h, removeback, smooth, xorig, yorig);

Argument Description
index | The index of the surface to create from.
x | The x position to copy from.
y | The y position to copy from.
w | The width of the area to be copied (from the x position).
h | The height of the area to be copied (from the y position).
removeback | Indicates whether to make all pixels with the background colour (left-bottom pixel) transparent.
smooth | Indicates whether to smooth the edges.
xorig | Indicates the x position of the origin in the sprite.
yorig | Indicates the y position of the origin in the sprite.
Straight from your code:
Code:
sprite_create_from_surface(application_surface, 0, 0, room_width, room_height, false, false, 0, 0);
Lemme break this down with comments:

Code:
sprite_create_from_surface( // Yay, gonna create a sprite...
        application_surface, // ...using the application_surface. But how much do we want to copy?
        0, // Start at application_surface's leftmost...
        0, // ...and topmost pixel. That's 0, 0.
        room_width, // Go rightward to meet the same width as the room (1,280 pixels) and copy that from the surface.
        room_height, // Go downward to meet the same height as the room (10,000 pixels) and copy that from the surface.
        false, // Don't bother changing any pixels to be transparent.
        false, // Don't bother changing any edge pixels, either.
        0, // Make the sprite's origin the leftmost...
        0 // ...and topmost pixel. That's 0, 0.
); // Close function. $:^ }
Did you notice the problem? In case no, I'll write it out explicitly: GM auto-sets the application_surface to be only as wide and tall as essentially the screen output -- in your case, the view's width and height -- but you're setting the sprite to be as wide and tall as the room -- same width, about fourteen times the height. Perhaps you should supply a different height (and width just for good code semantics) to the function, eh? $;^ J

I hope this helps,
Bob $:^ ]
 
J

JonSnowShoveler

Guest
Thanks for the info. When I tried to insert code it asked me what type and I thought since it said HTML it was for executing formatting in the post itself. Plus I like taking screenshots with ShareX so I just screenshotted my code instead. I'll use the code brackets next time though, as it takes less room and effort.

As far as the create sprite from application surface, I did eventually change the parameters to use my view width and height instead, now that I learned more about the view variables.
 
Last edited by a moderator:
Top