Welcome Guest [Log In] [Register]
Announcement
We are joining a member drive with other forums. Please view this announcement thread for details. Thanks!
Add Reply
Pls Help: Game Maker Script; Menus and Character Selection
Topic Started: September 22, 2008, 6:32 pm (83 Views)
phoenixmuse


I need help with two major aspects of the game I'd like to create. Menu making and selecting an object.

I'd like to be able to make multiple "units" or "characters" that can be controlled using the key pad, but only one should move at a time, which means that one object (one unit or one character) needs to be selected when I click on it, so that only that object moves when I press an arrow key.

The other important thing I need to know is how to click on menu items and make them do what they should when clicked on. I followed a tutorial that explained how to make a menu that is text-based, and I copied it exactly, but the tutorial was designed for using the arrow keys and the enter keys which conflicted with moving the character around. Again, I came across the problem of having on thing selected at a time. I'd like to just be able to click on a menu item and then have it do what it ought to do, but when my entire menu is one object, how can I tell it to determine that I've clicked on a particular part of the menu?

I'd also like to know if I can make a turn-based game.

I'd also like to know about giving a character multiple stats, like attack and defense and intelligence, and giving these stats to not just one character, but a few characters... But my first two questions are my main concern at the moment.
Offline Profile Quote Post Goto Top
 
SoulRed12
Member Avatar
Da Admin

I've moved this to the party room. Only because I was expecting questions about a soulscroll article. No worries though, I'll still try my best to help you out.

Okay, well first off. In the first question, you have to keep a separate invisible object that has a global variable storing the id number of the currently active unit. In the unit object just check if the unit's id number matches that global variable before moving.

For your second question, you could always put invisible objects with a rectangle sprite, where the text will be. Then when you click on a menu option, check which one was clicked on and move to another menu screen appropriately.

You are talking about a main menu type thing, correct?
Offline Profile Quote Post Goto Top
 
phoenixmuse


SoulRed12
September 22, 2008, 8:47 pm
In the first question, you have to keep a separate invisible object that has a global variable storing the id number of the currently active unit. In the unit object just check if the unit's id number matches that global variable before moving.
How do I set the global variable?

(I probably come off as if I know more about game-making than I do. I've only been trying to use Game Maker for two days now, so I'm really very clueless. I do have experience however with game design in general and I have worked as a web-designer before so I'm quite good with html. So that might make it more clear why I know stuff and don't know anything at the same time, lol.)

What is a global variable used for?

(I actually read this one in the manual and their explanation didn't do much for me.)

Hm. So if I give each object I want to be able to be selected the event "left click press" what do I put in the second space? Some code telling it that it's now the active unit? And then I have some other object programmed to know the ID number of that object via. global variable? Am I correct concept-wise?

If so, or even if not... What code do I need to input?

(I'm sorry if these questions seem silly, but I've been looking for this all over the forums and have not even seen it mentioned.. Btw, I think I'll do just as you suggested for the menu.)
Offline Profile Quote Post Goto Top
 
SoulRed12
Member Avatar
Da Admin

no probs. Well first let me ask, what exactly is this menu going to be used for?
Offline Profile Quote Post Goto Top
 
phoenixmuse


That is an excellent question. Instructions, save game, load game, exit game need to be on it. Below the menu I want the inventory to reside. I swiped a really awesome inventory from moo-moo the cow dude on the yoyo forums: http://gmc.yoyogames.com/index.php?showtopic=361884 But I really have no idea how to edit it. I figure using this example however will teach me a lot more about scripts as I learn to edit it. However, I was thinking that if I made invisible buttons over the text menu items, then I might as well just make buttons for them.
Offline Profile Quote Post Goto Top
 
SoulRed12
Member Avatar
Da Admin

Yeah, you could do that. Then just change the buttons' sprites when you click them.

It's probably a good idea to learn GML itself before trying to edit code made by others. After working out this menu stuff, maybe think about checking out some of the general tutorials on yoyo or the first few pages of the GML section of the GM manual. Or you could use the "SoulHow to code with GML" article on my blog.

If you wanted to keep the text, basically you're going to have to check whether the mouse clicked inside a rectangle that is centered around the text. That's why I suggested to use separate objects. If you only want to use the one menu object, you're going to have to check for this with code. I.e.:

"if (mouse_x>25 && mouse_x<75 && mouse_y>70 && mouse_y<100) ..."

If that doesn't make sense to you, you should probably look up the basics of code and then come back to this. :)
Offline Profile Quote Post Goto Top
 
phoenixmuse


Sounds like I need to do more reading about gml. *sigh*
Offline Profile Quote Post Goto Top
 
SoulRed12
Member Avatar
Da Admin

phoenixmuse
September 25, 2008, 11:58 am
Sounds like I need to do more reading about gml. *sigh*
Don't worry, it's easier than it looks. Feel free to ask another question when you're ready. :)
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Party Room · Next Topic »
Add Reply

Affiliates
RadioArcade