Legacy GM [SOLVED] Simple Inventory System?

M

MintyPretzel126

Guest
What I need is to have the game know when I collected a certain amount of keys, change the sprite of one instance of an empty key, (currently have 8 different empty keys,) and make the stage advance when I have 8 keys. I'll explain it a little clearer if needed. Thanks a bunch, even if you just read this.
 

YoSniper

Member
Are all of the keys the same kind of object? Or is each one unique (as in, for example, it opens a specific door that the other keys can't?)

If all of the keys work the same way, you could just have a global variable that tracks the number of keys collected (may need to get reset in each room.)

Otherwise, you could have a global array, like global.has_key[ii], where ii would be any integer from 0 to 7. This would operate in a similar fashion, except that you could check a specific slot if a condition required that a specific key was collected.

Hope this makes sense.
 

JackTurbo

Member
I'm pretty new to game maker, so maybe take my suggestion with a grain of salt (and my syntax might be a bit off) but my first thought is that if all the keys are the same you could just use a variable, like...

Give the player object a variable for number of keys.

Code:
keyNumber = 0;
Then on collision with a key run something along on the lines of

Code:
keyNumber = keyNumber + 1;
Then run something like the following in your room.

Code:
if (oPlayer.keyNumber >= 8){
        room_goto_next();
}
obviously, replace oPlayer with what ever your player object is called.

Like I said I am pretty new to Game Maker and GML though, so this could be catastrophically wrong for all I know haha
 
Last edited:
Top