# Making game harder as score increases

Attention Topic was automatically imported from the old Question2Answer platform.

Im making an endless runner game and I want the player’s speed to increase every time his score increases by 10. How can I do this?

1. Introduce some difficulty scaling variable in scope high enough
2. Raise this variable every 10 points of score using the same method that shows score in UI
3. Apply this variable to whatever aspect of the game You need, like mobs speed = speed * this variable, or for x in range(this variable) spawn mobs every minute and so on

Thanks, but how can I check whenever the score is increased by 10? I was thinking something like this:

``````*everytime score is increased by 10:*
playerSpeed += 1
``````

How would I change this into actual code?

LyguN | 2021-12-24 14:29

You were making endless runner, so surely You were following tutorial from documentation. There is a method that counts the score, isn’t there ? I thought there was setget function described ? I mean a place in your code when new points are added to old points ? In this same place You can check current score and apply calculations to it, for example :

``````on mob_killed():
score += 10
difficulty =ceil(score/10)
``````

This calculation will result in ceiled integer of division score by 10, in other words, it will be 1 higher every 10 score. You can also make some maxscore variable, check if score is higher than maxscore, and if it is - raise the difficulty level by one and raise maxscore by chosen amount.
And in your movement code, calculate speed with difficulty however You like:

``````speed += difficulty
speed *= (1 + difficulty)/100
speed = speed.pow(difficulty)
``````

Inces | 2021-12-24 15:33

Ok so I got it working now. I wasn’t initially using setget but after you mentioned it I looked it up and decided to use it. Thank you!

LyguN | 2021-12-24 17:27