How do I display a random text at the end of the game?

Get help using Construct 2

Post » Sun May 08, 2016 11:19 pm

I am a newbie, in fact this is my first day in gaming development so I need your help guys. I want to know how to add a list of phrases for example:

"great job"
"you are awesome"
"no doubt you are the best"

and display one randomized phrase in the Game Over screen. For example each time the gamer finish the game the gamer will see a different phrase in the gameover screen.


I have in mind a large list.


Please remember that I am a new corner.


Thanks for your help and also for this great opportunity to become a game developer.
B
4
S
1
Posts: 8
Reputation: 304

Post » Mon May 09, 2016 12:29 am

Make a new number variable, we'll call it randomText. Then on gameover we set the value of it to floor(random(10)) - that will allow us to put in 10 random phrases, just change that number if you want more or less.

Then:

if randomText = 0: set text to "great job"
if randomText = 1: set text to "you are awesome"
if randomText = 2: set text to "no doubt you are the best"

etc.

Just bear in mind that with floor(random(10)), your ten possibilities are stored in 0-9, value 10 will never come up, because the floor() function is rounding numbers for you :)
Image



Coming soon on Steam!
B
16
S
9
G
3
Posts: 202
Reputation: 3,462

Post » Mon May 09, 2016 1:12 am

Thanks but how can I do it? I mean I dont know how to create the Number Variable in "Contructs 2" .

mikehive wrote:Make a new number variable, we'll call it randomText. Then on gameover we set the value of it to floor(random(10)) - that will allow us to put in 10 random phrases, just change that number if you want more or less.

Then:

if randomText = 0: set text to "great job"
if randomText = 1: set text to "you are awesome"
if randomText = 2: set text to "no doubt you are the best"

etc.

Just bear in mind that with floor(random(10)), your ten possibilities are stored in 0-9, value 10 will never come up, because the floor() function is rounding numbers for you :)
B
4
S
1
Posts: 8
Reputation: 304

Post » Mon May 09, 2016 2:00 am

@romanos8
You should take a look into the tutorial section
https://www.scirra.com/tutorials

But the easiest way is "choose"
choose("Hello", "Hi", "Great", "Goodbye")
https://www.scirra.com/manual/126/system-expressions

  • System > On start of layout | system > load game from slot "brain"
  • System > On load failed | system > scroll to obj_Forum
B
17
S
8
G
5
Posts: 340
Reputation: 4,707

Post » Tue May 10, 2016 1:43 pm

Dont forget to add in trigger once when using choose or random....Ive experience melt down of contruct two when i forgot that and cause liek 20 event plus the random number to try to run at the same time lol
B
51
S
24
G
6
Posts: 391
Reputation: 7,820


Return to How do I....?

Who is online

Users browsing this forum: Darth Crusher, David181, vaticant and 1 guest