A little curious

I have been trying to make a clicker game.

I am stuck at thinking how to make a sprite change once its reaches a certain number and if the number goes down the sprite goes back to normal

example:

You reach 300 points and the sprite gets bigger, then you spend those points and are left with 100 and the sprite goes back to what it was

I probably dont make sense with what im saying

Any help would be good for me TwT

5 Likes

If I’m understanding correctly your asking for help with the logic of changing weight states based on points. One way you could execute this is with a function that takes the current score and returns the weight state the character should be at. Within it, you could set up threshold checks of if-elseif-else statements that check if score is >= to target score for the next weight stage, arranged from highest to lowest order.
This method gives flexibility on if your weight stages have different values that scale radically different from one another, but otherwise a more efficient version would be to create a formula where you plug in X (score) and get Y (weight state) relative to some function of scaling. I suggest looking at graphical representations of some formulas to visually see how fast (or slow) state change can be relative to the score. I hope some of this helps ;3

2 Likes

The way I set it up is two arrays (you could use a ds grid as well, this is just how I’ve done it), one with the weight thresholds and one with the sprites you’re using. Then set up a small for loop that checks if the current score is greater than the threshold at each position like Kanto said and change your sprite variable to whatever is in the same position in the sprites array.

3 Likes

Thanks, It helped a lot to make the code work

2 Likes