How do I click on numbers?

Get help using Construct 2

Post » Thu May 05, 2016 5:08 pm

Hi,

I am having trouble figuring out the right construct 2 code for the following psuedocode:

1.) Generate a random set of numbers so: Generate between 4 and 10 different random numbers.

2.) The tricky part I am struggling with: If user clicks on these numbers in order of sequence then start the sequence from beginning, if one of them is not clicked on in the right order then start the sequence from the beginning but the use gets no point.


Also how do I generate the numbers as negatives additionally?
B
9
S
3
Posts: 103
Reputation: 1,043

Post » Fri May 06, 2016 11:17 pm

Bump.
B
9
S
3
Posts: 103
Reputation: 1,043

Post » Sat May 07, 2016 1:24 am

1. Generate a random set of numbers using the random() expression. To determine the number of random numbers generated, you can use a loop - repeat random(4,10) times. Create text, set text to random(x,y). Random() can be set to a negative number

2. One way to sort your randomly generated numbers in order, probably in an array. There are multitudes of ways to do this. Ref: https://en.wikipedia.org/wiki/Insertion_sort Edit: Just use the sort action!

A simple way I can think of to simulate the effect you are looking for, is to compare the selected number with ALL the other numbers. If ANY other number is less than the selected number, then fail and start over, set points, ect. Else if no numbers are less than the selected number, then delete that number and move on.

This will only work for numbers, and in order from smallest to greatest or vice versa.
Last edited by oosyrag on Mon May 09, 2016 6:47 pm, edited 1 time in total.
Mistakes were made.
B
48
S
23
G
107
Posts: 1,576
Reputation: 60,168

Post » Sat May 07, 2016 11:54 am

I choosed for lazy coding ( = no calculating positions, no arrays, and a lazy flow)
Most of this code is making sure that they spawn on random positions, but not on the same place
+ making sure each number is unique. Take that out, and its gets really simple.
The number shown is not the actual number, wat it shows is just a little trick to include negative numbers without much hassle. (= lazy coding too)

But, you know, be able to code in the most possible lazy way, that is the strenght of c2.

https://drive.google.com/open?id=0B1SSu ... 3VNV1ZUOTg

Be free to ask.
B
33
S
18
G
27
Posts: 2,431
Reputation: 20,326

Post » Mon May 09, 2016 4:13 pm

Um 99Instances2Go your code is good, but surely there is a shorter and simpler way of doing it as oosyrag mentioned but I have no idea how to implement, still better than what I can do. I find your code hard to understand.
B
9
S
3
Posts: 103
Reputation: 1,043

Post » Mon May 09, 2016 6:36 pm

Just found out the array object had a sort action that I never even realized was there, sorry if I made it sound more complicated than it was. The sort action makes it much simpler!

Here are two examples, one using an array and one without using arrays.

https://www.dropbox.com/s/bve7b9dnxsh7o ... .capx?dl=0
https://www.dropbox.com/s/69rfiiabmfv9t ... .capx?dl=0

I didn't add the actions for what happens on success or failure besides destroying the text on success to show it works, try to give your best shot at implementing a scoring system on your own.
Mistakes were made.
B
48
S
23
G
107
Posts: 1,576
Reputation: 60,168

Post » Tue May 10, 2016 1:21 pm

Thanks overall
B
9
S
3
Posts: 103
Reputation: 1,043


Return to How do I....?

Who is online

Users browsing this forum: timoteomorelli and 1 guest