Very Simple Game with Construct 2

2

Index

Attached Files

The following files have been attached to this tutorial:

.capx

collect-stars.capx

Download now 207.46 KB

Stats

8,410 visits, 17,381 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 11 Feb, 2016. Last updated 19 Feb, 2019

Now we want to add enemy, make enemy appear randomly on screen. As you already know the layout size is 854, 480. So what we have to do is spawn enemy random X and Random Y. Also keep in mind that enemy must be on screen and not spawn outside of layout. If sprites (Enemies) spawn outside layout waste of computing powers. Ok so what we do is:

System creates Enemy @ random seconds between (0.6 to 2) seconds: on player layout set Enemy.X to (40, 800) Enemy.Y to (40,400) keep in mind that our enemy is 40 x 40.

Do the same for Enemy 2 and enemy 3 and also for create Random Collectable_Star too.

Code looks something like below:

This code is not finished version because we need to add more to it. Test nit and you will notice layout is cram with enemy and stars. Also you see collecting stars is not much fun.

As you notice there are more Collectable are spawned so we need to change that code too. Also enemy are spawned but nothing happens.

Let’s add enemy death time say about 7 seconds. So every 7 seconds enemy will be destroyed and new one be created. Also clone Particle and name it Enemy_particle. Create Enemy family, name it Enemy.

Now another interesting thing is Collectable_Star, stays on forever, we don’t want that do we? No, so let’s make that interesting too. Say every 6 seconds that destroy too.

Run the project and see the result;

Not much I would say but we are getting some results as we wanted.

One problem here is that object like enemy and stars are created on top of each other, that’s not game is it? Let’s do something about that create Family and add the entire object but, do not add player and call the family all Family_All.

  • 0 Comments

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