I'm coding a game - part 7

In this installment I used the transition function to have multiple levels in my game. That may not seem like a lot, but there was quite a bit of code involved. I also redesigned the layout of the level because I came up with a concept. So much to cover, let’s get started!
 
Redesigning the Layout:
 
First step was to change the layout of the stage. When I first thought of this game, I knew I wanted a side scroller type of game. The original dimensions of the game were 2048 x 1080:
Not too bad but then I thought to myself, “Go big, or go home!
 
So I doubled the width, yet again. This game is really starting to take on a life of it’s own.
The roof tops are swarmed with multiple AN3000 droids!! RUN FOR YOUR LIFE!!!
 
Then I duplicated the level so all the settings stayed the same. then altered the landscape, and POOF I have level 2! This is when a concept formed in my brain. Have the game take place on top of post apocalyptic sky scrappers! I know, I know, the genre is played out, but I don’t care! The brick texture I designed for the tiling now won’t seem out of place. After I finished the levels, it was on to code an object for transitions.
 
 
The Code for Transitions:
 
There was a lot of new code and concepts so I’ll try to keep it as concise as I possibly can. I created an object and named it, oTransistion. Next, I wrote some code in that object under the Create event:

The new concept or command I used was called the enum command. An enum is used to assign words to numbers. This can be very useful in programming. Instead of always using a ‘0’ to represent when I want something to be off, now I can just use OFF in the code. ENUMs are a better choice than variables if the program calls for a constant, not a variable. Next I wrote some code in the step event:

This bit of code features the switch command. The switch command is a useful command if the program has a routine that needs to switch from one variable to a different one. Now if you recall, I used the enum to define some constants so the switch will bounce from enum to enum. For instance, If the switch is set to INTRO and an event triggers the switch, then the mode will be switched to OFF. Depending on what the mode is set at, a certain routine will happen when the triggering event occurs.
 
Confused?

This was me staring at the code for a good hour.

It does make sense, try to think of it as a routine, broken down into subroutines. After my brain unlocked from thinking too hard it was time to add a script.

A script is code that exists outside of an object that can be called upon by any object. This script analyzes the mode, and when it is higher than ‘1’ sets the target variable to ‘1’. One last step and we’re done! Last I created an object that the main character had to touch to trigger all these lines of code!

I created a sprite and made it a blue box and wrote these lines under the collision event. When the main character collides with this object, these lines of code will process. I then placed the object onto the level. Eventually I’ll make the box clear so the player won’t see anything, but I need to see something as I’m creating the levels.
 
I discovered a neat little feature at this step. When an object is placed onto the scene it becomes an instance. That individual instance can then be assigned code specific only to that instance, not the object. So rather than creating an object for each new level, I created a generic object, then modified the instance when I used it.
 
I have to say, I really enjoy the way this thing is turning out. I can’t wait to complete the shell of the game, so I can start to modify it and make a ton of levels, power ups, and guns. This is so COOL! until next time!
 
Take it easy, but take it.
 
NickelNDime OUT!