0 Favourites

Question about equation's game

  • In a game about equations, I intend to create multiple objects with random numbers from 1 to 9, which must be clicked together to equate to a value. Initially I think working with a single object with nine frames and 32 will be created from it. I thought first randomly generate this amount, but will always remain balls because you may not have numbers together to reach this value. The right would generate a value according to the spheres that have on the screen, but how can I do to know how much each is worth, whether they are copies of the same object? Does anyone have another idea or suggestion?

  • Uh, I think I understand...

    You can use "count" to know how many instances of an object there are.

    I would create a random number between 1 and the sprite.count, for the first number, the second would be a number from 1 to the sprite.count minus the first number, then split it again, or use the remainder as the last number.

  • A little complicated for me. I think that I don't understand how to use "count". I'll know the value for each instance too? Something like "count.object.AnimationFrame" (I know this is wrong and maybe not exist - is only a guess). If is possible, maybe I could generate a total value based on the sum of the value of the remaining instances, according to a minimum of instances (eg 03).

    Could you explain with details this solution that you suggested?

    PS.I forgot to mention that there is an object on top of the spheres and the goal is to avoid it touch the floor.

  • RenatoB

    The count expression is accessed by sprite.count

  • I need to know if "count" will count the instances and values ??of each. If this is possible, I want to count how many instances there are currently screen, then randomly select two or three and add their values ??to associate it to the total.

    Could a good soul give me a small example? No need to create a CAPX.

    Thanks

  • RenatoB

    You could do something like this.

    For each object

    is object on screen

         use the array push action to add the object's UID

    Select a random value with round(random(array.length))

    Pick object by UID

        

    To pick more than one, use the pop action to remove the one already selected and then select another random value from the array.

  • Thanks aerirprown, but my game is almost ready and I did't use "array". And about "count"? Could I use it to solve my problem? Thanks

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • There may be some other method that would involve count. I did not see a need for it to simply pick instances on screen.

  • aerirprown

    I don't know how to use array. I would like a simple solution (without array) and I thought that "count" would be a good the solution.

  • Any help?

  • I used this solution:

    Pick object random instance: add object.AnimationFrame+1 to total

    object is on screen

          >> Repeat (random(2,5) times

                 >>             : set text to total

    But not work. How could I change this script to run like I want?

    Thanks

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