Games Tutorials for Beginners

3

Attached Files

The following files have been attached to this tutorial:

.capx

building-game.capx

Download now 3.38 MB

Stats

3,725 visits, 5,934 views

Tools

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 12 Jul, 2014. Last updated 19 Feb, 2019

Every person buys Construct 2 wants’ to make games, or whatever they wish to make. Understanding the tool sometime it’s very daunting task for beginners. I am not saying it’s very hard but, you have to be very calm and understanding. If some code or code snippet not working do not give up. Get some rest, go out and take about half hour break. Better still forget it for today and start again next day but, do not give up. If you do then you the one who has lost not the software or computer or the person whom has written the tutorial.

Let us create simple game where, you as player collect some coins. We can use keyboard plus touch control.

1. Start by creating new project in Construct 2. Name the project as you wish

2. Set windows size to 800, 480

3. Add version, Descriptions, ID, Author, Email, and website if you have

ADD MOUSE, TOUCH CONTROL, AUDIO, KEYBOARD. To add this item all you do is double click on layer or right click mouse and insert.

Once this is done save your project. Remember to save your project very often and if you make mistake don’t worry I would advise you to keep backup copy of your project. Now let’s start

1. Layout size to 800, 480 and margin 800, 480

2. Name the layout Level 1

3. Name the Event sheet to Code

4. Double click on your layout or right click mouse and click on INSERT

5. Click on TiledBackground and import it.

6. Make TiledBackground little larger than your layout say about 900, 900

7. Now lock the layout.

Our TiledBackground is done.

Create new layer and call it GUI or whatever you wish. On this layer we will add coins, textbox, left, right, up, and down arrows for touch control.

Import coin sprite or whatever you think.

Also add textbox and name it txtScore Colour of your choice and font size

Now create for arrow sprite and place it as Picture I have provided and also lay your coins out as well.

These four arrows you must name it as Left, Right, Up, Down. So when we insert codes we will indentify by name. Lock the layer and create new layer call it Player, or Hero.

Note when you insert ARROWS SET OPACITY TO about 50; you will know when we start adding code we will update this. So person playing will notice what is happening with ARROWS

Add 8 Direction to player behaviour. Now you be wondering why we haven’t included bound to layout. Well reason is we will check in our code that hero is gone out or not.

Let’s start coding and see what we can accomplish with this tutorial. There is more we can add to improve our game. That will be depending on your imagination and no limit in your part. Hope you learn something. Good luck and God bless

Every time you create game you will need variables. With variables we can do many things. Sorry I am not here to teach about all inns and out of variables. Google it and you will learn more about it. For now we need 3 variables:

1. Score set to 0

2. Highscore set to 0

3. Level set to 1

So it would look like below

Now next thing is start of layout you need set txtScore and you’re Audio. Looks like this below

We can say system on start of lay out = txtScore set score&level&highscore like this

Set txtScore "Level: " & level & " High Score: " & highscore & " Score: " & score

Now we are ready to move our Player (Hero) with touch control first. Here we go

Touch is touching mouse up hero Simulate 8direction pressing up and set opacity to 100. So when person is pressing that ARROW it will high lights and once stop it goes back to 50 opacity.

Now we add keyboard movements

Not much in this keyboard movements

Here is most important thing is remember our Player (Hero) is not bound to layout. If you run it now, you will notice Player will go outside layout. We have to keep him in. So here is the code that will keep hero in check. We can do it this way like check X less then or X greater then and do same for Y coordinate too. Remember checking X greater then and Y greater then has coordinate is LayoutHeight and LayoutWidth. So our code will be like this below:

This is how we keep our hero inside layout. Try it should work.

Now we have to collect coins and update score and highscore level

You must be wondering we only have one textbox. How are we going to do that? Answer is simple this symbol (&). With this we can get around to it. Our code below

txtScore = "Level: " & level & " High Score: " & highscore & " Score: " & score

That is that. Now run your game and start collecting coins and sees how you’re score and other text works in textbox. Now I must remind you I have not added sound FX or anything in this code. It is up to you to read Nice Construct 2 Manual and work it out yourself.

Now I am setting you all beginners challenge. I want you to add Hero Energy Bar. Collecting coins is hard work therefore you need energy. Next I want you to add Guards like top, bottom, sides so they can shoot hero. This is where your hero loses his energy therefore you have to update Energy bar accordingly. Now add random things falling from above which also can reduce Hero energy. See how much you can improve the game.

One more thing try and speed up your game. Do not add more Layouts for new level but, use the same layout and see if you can use that same level to make Level 2, 3, 4, 5 and so. Idea is endless what you can do.

If you need help please ask but, do not ask me or anyone else in forum to finish your game. Good luck and God bless

.CAPX

building-game.capx

Download now 3.38 MB
  • 0 Comments

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