how do i calculate the numbers based on the target

Get help using Construct 2

Post » Wed Jul 24, 2013 2:34 pm

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.

http://ludei.com/sumon

Thanks in advance!!
B
3
Posts: 18
Reputation: 211

Post » Wed Jul 24, 2013 3:06 pm

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
B
28
S
8
G
1
Posts: 469
Reputation: 4,683

Post » Wed Jul 24, 2013 3:29 pm

@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)


Peret2013-07-24 15:42:34
B
14
S
4
G
1
Posts: 42
Reputation: 1,775

Post » Wed Jul 24, 2013 4:06 pm

@Peret

try setting all the instance variables to family variables, so you don't have to pick by uid
B
28
S
8
G
1
Posts: 469
Reputation: 4,683

Post » Wed Jul 24, 2013 5:02 pm

I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Jul 30, 2013 1:35 pm

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
B
3
Posts: 18
Reputation: 211

Post » Tue Jul 30, 2013 2:21 pm

I just upgraded the capx I gave you in the topic you opened as @narasimha.

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
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Jul 30, 2013 2:34 pm

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.
B
3
Posts: 18
Reputation: 211

Post » Tue Jul 30, 2013 2:45 pm

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.

I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Jul 30, 2013 2:57 pm

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..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Next

Return to How do I....?

Who is online

Users browsing this forum: ezgaming420, marcinkowski, plinkie and 11 guests