Rock, Paper and Scissors !…

January 12, 2019
I'm a former teacher (and headmaster) in french primary schools. Now I work as a freelance on the net as a webmaster. I used to work with Flash for many years, but now I'm starting to discover Captivate and find it amazing !...
Master 5 posts
Followers: 4 people
1

Rock, Paper and Scissors !…

I'm a former teacher (and headmaster) in french primary schools. Now I work as a freelance on the net as a webmaster. I used to work with Flash for many years, but now I'm starting to discover Captivate and find it amazing !...
Master 5 posts
Followers: 4 people
January 12, 2019

Hello Captivaters !…

After a year of “serious” work (see my previous message here), I wanted to take a funny short break…

And what’s better than a game to do it ?…

I had the idea of making a “Rock-Paper-Scissors” game while ago, so here was the time to make it !…

Nothing really complicated with advanced action…

First of all I created 3 variables :

– v_MyScore (For my score)

– v_YourScore (For the player score)

– v_MyChoice (For choosing randomly my action)

1./ On the first slide of the game (“PLAY”) :

I have 3 images/button for the player’s choice, each one leading to another slide, respectively leading to “ROCK”, “PAPER” and “SCISSORS” slides.

I also made a While action to display my randomly choice, using a multi-state object.

2./ On the 3 player’s choice slides (“ROCK”, “PAPER”, and “SCISSORS”) :

I have an image of the player’s choice,¬† a multi-state object to display my randomly choice (My_Hand), and another multi-state object to display the result (Win, Loose or Equal).

So I put an “on enter action” with :

– a Javascript action to choose randomly my action (1, 2 or 3) :

window.cpAPIInterface.setVariableValue(“v_MyChoice”, Math.floor(Math.random()*3+1));

– 3 conditional actions (one for each randomly choice) :

# If v_MyChoice is equal to 1

=> Modify the state of “My_Hand” to Rock

(Than apply the results => Win, Loose or Equal, using again a multi-state object with my “Dirlo character”, and increment by 1 v_MyScore or v_YourScore, or doing nothing, depending of the result…)

# If v_MyChoice is equal to 2

=> Modify the state of “My_Hand” to Paper

(Than apply the results => Win, Loose or Equal, using again a multi-state object with my “Dirlo character”, and increment by 1 v_MyScore or v_YourScore, or doing nothing, depending of the result…)

# If v_MyChoice is equal to 3

=> Modify the state of “My_Hand” to Scissors

(Than apply the results => Win, Loose or Equal, using again a multi-state object with my “Dirlo character”,, and increment by 1 v_MyScore or v_YourScore, or doing nothing, depending of the result…)

3./ I fixed the end of the game when a player arrived to 10 points, using 2 new slides (one for “Win”, and one for “Loose”)

For this I put 3 conditional actions on my “Continue button” :

# If v_MyScore is equal to 10

=> Go to “WIN” slide

# If v_YourScore is equal to 10

=> Go to “LOOSE” slide

# If v_MyScore is less than 10 AND v_YourScore is less than 10

=> Go to “PLAY” Slide

And that’s it !… I hope everything is clear as the game is in french !…

So can you beat me ???

Play

As usual great thanks again to Lilybiri !… (See : https://blog.lilybiri.com/playing-a-dice-game-using-while-loop ; http://blog.lilybiri.com/playing-with-numbers-part-1)

Have fun with Captivate !…

Comments (1)
2019-01-14 11:54:02
2019-01-14 11:54:02

It is fun to develop simple games with Captivate. In most cases you need indeed a random number. For those interested in the way that number is generated  with the JS math functions, have a look at the detailed explanation in:

http://blog.lilybiri.com/playing-with-numbers-part-1

Like
Add your comment