top of page

After creating the Pong O Pong, now I have created a Shoot em' Up game. This game is much tougher to make compared to the previous one. However, I still managed to insert some interesting features into the game.

 

       These are the interesting features.

 

1. Optimized Player Movement

In the previous game, the codes are everywhere, unoptimized and it only supports 4-way movements. However, in this optimized player movement, the codes are made in a single behaviour, optimized and supports 8-way movement. Let's get to it then,

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

                                                          The codes highlighted with a red box are the player movement codes.

 

This time I are required make attribute to hold values, controls etc. As you can see such attribute are the Left, Right, Up, Down, Horizontal and Vertical. Player X and Player Y are global attributes ( purple-coloured ) which can be used throughtout the game. This time the logic is quite tricky. You need knowledge of vector and binary codes to understand the logic easier.

 

I use this piece of codes for explaination.

 

 

 

Computers work in binary code systems.

So, if Right key is pressed , the logic will become 1. If it is not pressed , the logic will become 0.

Therefore, if Right key is pressed, the mathematics is 1-0=1. If it is not pressed, it will be 0-0=0.

However, if Left key is pressed, the mathematics is 0-1= -1. If it is not pressed, it will be 0 too.

The result is pressing Right key will produce a positive value, pressing Left key will produce a negative value

 

In Stencyl,

-Moving right needs positive x-coordinate values.

-Moving left needs negative x-coordinate values.

-Moving up needs negative y-coordinate values.

-Moving down needs positive y-coordinate values.

 

COINCIDENCE? Haha

Now all that's left to do is to multiply the result with a Speed value to get the desired movement.

An important note is if the Right and Left order is reversed, pressing Right will move the object to left instead.

 

Reminder

The order must be Right - Left and Down - Up.

 

2. Tracking

This mechanic is used to dynamically track an object. If you want to make a homing missile, this is what you need.

 

 

 

 

 

 

 

                                                                        The picture above shows the codes for an object tracking player.

 

The mathematics is:

 (atan2 (y: (y-coordinate of target) - (y-coordinate of self)  x: (x-coordinate of target) - (x-coordinate of self)))    

   degrees

 

3. Dynamic Bullet Spawning

This is the trickiest mechanic among the others. A lot of trail and error is needed to get the desired bullet spawn pattern.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

                                                      The picture above shows bullet spawn increases as the Burst value increase.

 

The Burst is my power level, it increases overtime.

 

The logic is: If a condition is true, repeat the process by N times.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

                                                                The picture above shows the movement of the bullet spawned.

 

After spawning the bullets, the bullets need movement.

Loop Count is created to hold the number of repeated times to spawn bullets.

 

The logic is: Move the bullets towards ( [wanted direction] + {LoopCount] x {Offset value} ) degrees

                       with Speed value

 

Offset value is used to prevent the bullet moving on the same coordinates repeatedly.

For example, if I spawn bullets 3 times, facing upward (90 degrees) and offset value is 6: 

 

                       The LoopCount is equal to 3.

                     In the first loop, degrees        = 90 + ( 1 x 6 ) = 96 degrees.

                     In the second loop, degrees = 90 + ( 2 x 6 ) = 102 degrees.

                     In the third loop, degrees      = 90 + ( 3 x 6 ) = 108 degrees.

                 Difference between each consecutive value is 6 degrees. 

 

   As conclusion, everytime a spawn happens the object will spawn 6 degrees away from the previous object. This has succesfully create a spawn pattern.

 

In my game, I rely heavily on my Burst value because I spawn bullets based on my Burst value. You guys do not need to use Burst to spawn bullet but make up your own conditions for the bullet spawns.

That's all I am going to present for this game. I will continue to more exciting games. Stay tuned and have a great day.

PROJECT GUARDIAN OF UNIVERSE

bottom of page