Creating Video Game

Index

Attached Files

The following files have been attached to this tutorial:

.capx

defend-earth.capx

Download now 4.63 MB

Stats

2,654 visits, 5,545 views

Translations

This tutorial hasn't been translated.

Tools

Now add behaviour to spaceship 8 directions and flash. Looks like below

Now we said we want to move our spaceship only left and right. Therefore in behaviour set the property as below:

Here you must remember to set angle = no if you don’t then when you try to move left your Spaceship will be upside down. Another thing you can use Boundtolayout behaviour but, I will show you another way. Also set default control to NO too.

Open your Event Editor and add these lines.

Now add this line too.

Now let me explain here that we are using keyboard for input. Therefore if you press right arrow spaceship move right and left will move it to left. Now we must check for our spaceship not to go out of our boundary. So we check left side X and right side X. We do not need to check Y because our spaceship will always on Y alignment. So what we are saying if x left side is 48 then x=48 and if right side X = 592 then X=592. Here Construct 2 keeping tracks of X if it is 48 then stays at 48 or if 592 then stay at 592.

Now we need Bullets to fire at Alien Spaceship. So create sprite and call it playerbullet. Add behaviour as below too. Remember to set Angle of bullet behaviour to no.

Here in these lines we are telling Construct 2 to auto shoot bullets at 0.1 seconds. If you don’t set this you will have continues bullets being fired. It will not look good. Also we want to fire bullets upward so the angle settings works like below:

Right = 0

Left = 180

Up = 270

Down = 90

Therefore I have set angle of motion of our bullets to 270 upward. Run it and see if your spaceship shoots bullets upward. That is our player done.

Now let’s create Aliens ships objects but, first we need to create sprite to spawn random Aliens. So create 16 x 16 square sprite. Any colour you like and call it Spawn also set to invisible. Place these Spawn sprites like below and also create Alien sprite too.

Remember we have Timer set to zero. We have to tell Construct 2 add Timer value. So in our every tick we have to add value dt (Delta Time). It will look like below: what we are telling Construct 2 add Delta Time to our Timer. So when you RUN you will see your Timer will start and also you will see update in textbox.

  • 0 Comments

  • Order by
Want to leave a comment? Login or Register an account!