Maths game, some work, some don't

Hi there, first time poster, long time MakeCoder.

I am building an example game for my year 9/10 Game Design Class and am stuck on something.

Basically, the game wants you to make a total of ten by shooting numbers that add up to ten.

Seems basic right, I agree.

I have done something wrong and am confused why when I shoot some numbers, they add to the total, but others just get destroyed and dont add to the total.

I have tried laying it out in three different ways but i get the exact same result each time.

Any ideas people?

5 Likes

Each time you spawn a new numeral, you lose track of the previous one of that value.

For example, let’s say you’ve created a “2.” When you make another “2,” the 2 variable only points to the most recent one and loses track of the first one. So, when you do your comparison in on destroyed, only the most recent “2” would get caught by the if statement.

You’ll want to use the sprite-data extension. Assign a value to the sprite’s data and then use that information when checking the destroyed sprite.

Gimme a few minutes and I’ll create a demo project for you.

See if this gets you there. Holler if you have any questions.

P.S. Always great to hear from educators outside of the U.S.!

4 Likes

There’s another way to do this that doesn’t use the sprite-util extension, and that’s to use the sprite’s image in a conditional; i.e., check if the image is a “1,” a “2,”, etc.

Here’s the same project as above, but without the sprite-util extension. This one is closer to the spirit of what you had attempted originally.

1 Like

Uh huh, i suspected something along those lines but was stuck on how to move on from there.

Also, many thanks for the detailed and down to earth explanation.

I also appreciate the example you popped in there.

I appreciate it.

Just noticed your PS, thanks.

Yeah, from Bendigo, Victoria in Australia.

2 Likes