make an ESP game using gamesalad part 2

Ok let's continue from the first part of the ESP game blog post.

We'll be creating a new actor. Let's call it "selectCard".

Let's change it's width to 37 and height 64. (note that this is actually half the size of the main card we first created).

Next create an INTEGER attribute inside this actor. Name this attribute as "ID".

We will use this attribute "ID" to identify which cards are on display. You'll understand after we add some rules inside this actor. Let's actor these rules to change the actor's image based on it's "ID".

These are similar rules we had first created in the "ZenerCard" actor in the first part of the tutorial blog post.
These rules will check for the "ID" value and then display the image.

If "self.ID" = 1
   Change image to "circle"

If "self.ID" = 2
   Change image to "cross"

If "self.ID" = 3
   Change image to "square"

If "self.ID" = 4
   Change image to "star"

If "self.ID" = 5
   Change image to "wave"

Alright! Now that we have done the change images rule we need to add a game attribute. We need to do this so that the game knows which card the player has selected.

Go back out of this actor and then click on the GAME tab and then click on the + sign at the bottom of the tab window. Let's call this new INTEGER attribute "selectedCardNum".

Once you got this, double click on the "selectCard" actor again and add a TOUCH rule.

Inside the TOUCH rule add the CHANGE ATTRIBUTE behavior and select game>>selectCardNum. Then on the next field click on the "e" sign button to open the "expression editor" where you will select the actor "selectCard" >> "ID".

Great job!

Next what happens when the player selects the card? Let's make the card pop up!

Add a new rule. Select ATTRIBUTE from the drop down menu. Select "game>>selectCardNum".

In the next empty field, click on the "e" sign button and then select "selectCard>>ID".

Next add 2 CHANGE ATTRIBUTE behavior in it. This time, we will change the size of the selected card to make it 30% bigger.

Choose selectCard>>Size>> Width. Then on the next field click on the "e" sign button to open the "expression editor" where you will key in: 37*1.3 (37 is the original width of the actor and 1.3 means 130%)
Do the same with selectCard>>Size>> Height but this time key in 64*1.3 into the expression editor.

Next we need to make the actor return to its normal size (37 width and 64 height when the player doesn't touch/press it. So In the same rule, at the bottom of it open the "otherwise/else" section and add a CHANGE ATTRIBUTE behavior to change the width and height back to its original setting.

Wonderful! We are now ready to add the cards into the scene! 
Go back to the scene and now from the Actor library, add one "selectCard" actor into the scene. Place it below the main Zener card.

Next double click on that actor that is on the scene. We're going to change its "ID" value to 1. This will be the "circle" card and it is our first card.

Add another 4 cards and do the same to change their ID values to 2,3,4,5 respectively.

Let's preview our game!

Now that we have all 5 cards for the player to select, we need to make the game check to see if the player has selected the same card as the computer!

So the logic is this:

If game.selectedCardNum = ZenerCard.count
   displayText >> You win!
   game.score += 1

If game.selectedCardNum != ZenerCard.count
   displayText >> You lose!

I will explain more on this in my next blog post. But you can try this out on your own right now!


Popular Posts