How do I click on numbers?

0 favourites
  • 7 posts
From the Asset Store
Game "Word Search" with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • 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?

  • Bump.

  • 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: 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.

  • 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. ... 3VNV1ZUOTg

    Be free to ask.

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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. ... .capx?dl=0 ... .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.

  • Thanks overall

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)