Creating simple game

3

Index

Attached Files

The following files have been attached to this tutorial:

.capx

creating-simple-game.capx

Download now 203.99 KB

Stats

6,660 visits, 13,171 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.

Test screen when you run your Project

Not much of game but you do understand that what can be accomplishing with Construct 2 with little effort in your part.

I know we don’t like all cluttered up screen and our game is nothing like what you see in above picture that is only demonstration to show you power of Construct 2.

NOTE PLEASE DELETE ABOVE LINES AND ADD LINES BELOW:

Open Main Game Event and add this Global Variables

1. spawn_Time = 0.04 seconds

2. spawn_Endtime = 2 seconds

3. gemstone_Speed= 200

Some of you may be wondering why use Global variables when we can just enter the speed? Well answer to that is very simple let’s say we have 12 line of code that has speed and we need to change that. What would you do? Changing 12 lines take time but, if you have Global Variable Speed, all you need to do is change Speed Variable and that’s done simple!

Back to our Game Even sheet and enter lines below;

In line 3 we are using our Global variable to spawn Gem_Stones randomly also we are instructed Construct 2 to choose Gem_Stonespawn randomly, not the same one, using default image point. We need to change Gem_Stones random frames, also we need to change Speed and bullet angle to be 90 degree

In line 4 when player touch the Gem_Stones all we doing is destroy the Gem_Stones and adding 1 to our Score Variable. He you might be thinking why did I not set txtScore text? Simple Construct 2 knows it has to update score every tick so, why do we need to repeat it again?

In line 5 we are simply checking if Gem_Stones overlapping each other then destroy it, won’t look good and also it will double the score too.

Now our little simple game is working but has you notice anything wrong? Let me remind you our Gem_Stones are spawning perfectly and also moving down too, but the Gem_Stones are still going on and on? This will create problem to our game because if it carry on then waste of memory and game will become slow, slow, and might stop working.

Create sprites 2000, 12, any color you like also name it Destroy_Gemstone. Place this sprite under the screen position about 928, 1280. Like below;

With this line all we do is add line of code;

Gem_Stones on collision with Destroy_Gemstone ACTION Gem_Stones destroy. Very simple! Now any of you do not believe or accept as true then all we do to test that create TEXT and name it txtDewbug. Place it somewhere on screen and add line below:

Create Global Variable Gem_Destroyed = 0

Place it on top of your screen position at 0, 0 we will use this for advancing our game further. For now we use it to see the result of above:

  • 1 Comments

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