how do i calculate the numbers based on the target

0 favourites
  • 10 posts
From the Asset Store
Hand-animated Sprite Base for isometric game/animation development
  • hi all,

         I am about to develop a game where there a certain numbers with random numbers in it.

         My actual question is how do i calculate the sum of numbers based on the click on one particular element(numbers).

        EX: There would be Target of sum 15

           

         And the numbers would be like this

         

          1 5 6 7 8 8 9 9 4

          3 4 5 9 0 3 6 7 9

          6 8 6 9 4 4 3 2 1

          1 2 7 5 3 7 8 0 4

    And if i click the above numbers like 7+5+3 it should be 15

    How do i calculate the sum of numbers based on the target(15) which i click on this numbers it should tally the target.

    Could anyone please help me in solving my problem.And If you guys did not get my point please refer to the below link which is similar to it.

    ludei.com/sumon

    Thanks in advance!!

  • So for each number that's been clicked on, you can set it's state to 'selected' whether by a boolean, or by numbers.

    +on number clicked    >set number.selected to true.. (or set number.selected to 1)

    then to total all the numbers selected :

    +for each number

    +number is selected (or number.selected = 1)

            >add number.value to TotalSum (a global or local variable)

    where number.value, of course, is an instance variable containing the actual number visible on the block/cell

  • keepee

    I would like to add a question here.

    If the numbers are a family. How should I do that?

    I tried this but it's not working

    +on number family clicked/ pick instance with UID family.UID

    +for eache number is selected

          >add number.value to TotalSum (a global or local variable)

  • Peret

    try setting all the instance variables to family variables, so you don't have to pick by uid

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you guys it's working well.

            But i have one problem in it.How to set the numbers based on the target it should take the numbers from the display to set the target as like

    Ex: if have some numbers in display like

    5 5 4 5 4

    4 2 3 6 9

    7 8 8 5 4

    And the target is 15.

    I have given like if the target is matched it would be invisible and that's working fine.But coming to last of it the target and the display of numbers are not matching.

    Ex: Target=9

    8 5

    4 2

    but it is not matching the display and the target.

    It should match the target what it is displaying on the screen. How should i make it to match it. Could you guys help me in this.

    Thanks in advance

  • I just upgraded the capx I gave you in the topic you opened as

    I don't know why you have two usernames on this forum, but it gets confusing. If you would just want me to make the game for you , you could just ask me. If you want to learn something, try to understand what I did.

    Demo-number-improved-again

  • hi littlestain

           

            Narasimha is my friend who actually working on other part the game and i am doing some other part of it.

               The one which you have send is perfect with it.

    But it should tally the numbers based on the target

    Ex : If i have a target=10

    The numbers in display is

    8 3

    4 6

    but it does not match the target.How can we click on it to set the target

    My question is how to set target based on the display of numbers.

  • I don't understand what you mean by the target.

    The capx I posted above makes it so that when the total of numbers on screen goes below a certain value the target is adjusted to comply with the numbers on screen. I guessed that was what you wanted.

  • Ok, I understand what you mean. That will be kind of hard to do. You would have to check if the combination of numbers that are on the screen can add up to the target-number.

    I'm not a math-wizard, so I can't really help I think.

    Maybe you could turn it around. pick three instances at random and add up their animationframes and set that number as target. Than you could keep the rest of the events as is..

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