Noughts & Crosses tutorial

Index

Attached Files

The following files have been attached to this tutorial:

.capx

nought-crosses.capx

Download now 277.81 KB

Stats

1,651 visits, 4,027 views

Translations

This tutorial hasn't been translated.

Tools

Set animation speed to zero (0) also add Instance Variable also with CTRL drag instance and place another next to first 1

xPostion = 0

yPostion = 0

PlayerNumer = 0

Look like below:

Lock the Square Grid layer and unlock HUD, here we will add some TEXT BOXES for score and player score, game over, play again etc

Create Text and name it as follows, place it on your HUD layer as you like or see below:

1. txtTurn

2. txtDraw

3. txtScore2

4. txtScore1

5. txtAgain

That’s it our screen design is done all is left now is to add code; Please make sure you enter code carefully or you will blame me and say hey Lord Shiva this won’t work. I have tested also test by my friend Brain Woodland and my god daughter Helen.

Open your Main Event Editor and add these lines of code below:

Lines of Code

Close Main Event Sheet, open Game Event Sheet and add these lines below;

Setting our game up at Start of Layout, by doing this every time game starts this code will be implemented or simply saying put into operation, put into practice.

1. Set game_over to 0 our Variable is set to zero

2. Set PlayerNumber 0

3. Must clear ARRAY

4. Set Animation frame to Player_Turn

5. Set Player_Turn VISIBLE

6. Set txtDraw to INVISIBLE

7. Set txtTurn VISIBLE

I think by now you would know what I am chattering about. Next enter below code, here with this code checking for player playing game on Mobile Device or PC. Once Construct 2 knows what device below code will be executed?

Next we have to check our ARRAY and player behaviours, add some function to check Arrays vertically and horizontally. And once we found match then act on it or do something else. We will be using loop for this, loop in construct 2 is no different but, you already know that. I am not here to teach you how to use loop.

Now rest is easy, when winner is found we display winner and if it’s Draw then we do that too. Also if player wish to carry on playing then we also show player what to do?

I hope you like this tutorial and learn from it. Only this I ask is please give out some kind of comment. We write this tutorial to benefit you and in return us not asking much just your comments.

God bless you all!

HAPPY DIWALI TO EACH AND EVERYONE ON SCIRRA & CO.

Lord Shiva

.CAPX

nought-crosses.capx

Download now 277.81 KB
  • 0 Comments

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