Kren Devlog #1 – Upgrade System and Level Specific Items

Player now has data (like energy, starting_x and starting_y positions, starting direction and so on) and a nice inventory of permanent upgrades. I’ve called it inventory for the sake of it. It’s just an array (it really is) of stuff you can get through the whole game. Permanent stuff. Stuff you can get only once per whole game.

In every room (level) there are a number of different objects (like enemies and items). Most of these items will simply respawn once the Player gets back into the same room. Again and again.

This way it doesn’t matter how many times you killed the enemies in the room. As soon as you exit and re-enter the same room, all those enemies are just there. Again.

This is fine. Almost essential in some situation (believe me, there will be times when you’ll need more enemies to refill your energy or ammo levels).

The green stuff will not respawn once you pick it up. The enemy will, as soon as you re-enter the room.
The green stuff will not respawn once you pick it up. The enemy will, as soon as you re-enter the room.

So what’s with the level specific items? If you already acquired the high-jump ability, you won’t find it again in the level. This is where the inventory comes into play. And this is what I’ve coded today.

By the way I’m not using maps. I’m using simple arrays. I just defined a couple of macros so I can use my global array like it’s a key/value map. I get the added benefit of speed and code autocompletion in GameMaker. The only thing I made sure of, was to initialize the size of the whole array.

//Arrays
global.player[MAXARRAY]     = 0
global.inventory[MAXARRAY]  = 0

Obviously MAXARRAY is a macro (value is 255).

Then let’s say that I have another macro like PLAYER_DATA which is an expression referring to global.player. And I happen to have just the right macro for the 0th position of such array; ENERGY.

If I write PLAYER_DATA[ENERGY] = 99, it’d be like writing global.player[0] = 99. But now I have autocompletion in GameMaker and a list of defined, clear, meaningful, macros.

What are your thoughts on this?

This site uses Akismet to reduce spam. Learn how your comment data is processed.