Hey look it’s a code post for our video game! ..Wait please come back, don’t go back to Facebook! I’ll explain it thoroughly.
Say you’re making a top-down game or a three-quarter view game and you have a masked object like this:
(Pictured: MS Paint)
Set up with some other basic movement code, other objects in the game won’t be able to go through the mask. Thing is we want our units to be able to go behind and in front of the Cloudmobile. Having a static depth doesn’t do that for us.
(Even the clouds have eyes..)
The solution? Give objects this snipet of code: depth – = y Using this code in a dynamic object’s step event (every frame of the game) or in the creation event of a static object, we can change the depth of an object based on its y coordinates.
(Couldn’t think of anything funny.)
There you have it! Objects behind stay at a larger depth than those in front. Further posts will refer to the game as Project 9-bit. We plan on having 3/4 view as well as sidescroller and possibly other styles. Hope you enjoyed this simple tutorial.
Thanks to Game Sprite Archives for continually supplying win and Nintendo for making a 5 star game.