• Hey! Guest! The 40th (!!!) GMC Jam will take place between February 25th, 12:00 UTC to March 1st 12:00 UTC. Why not join in this very special anniversary jam! Click here to find out more!

GMS 2.3+ Little math problem

Hello everyone,

I have a temperature which can have take a minimum value at -25°C and a maximum at 50°C.
I want to convert my temperature value in a percentage in order to my -25°C is 0% and my 50 °C is 100%.

The aim for me is to use : merge_colour(col1, col2, amount); to represent the temperatures variation in a map.

Can you help me?


Your original range is -25 to 50.

Adding 25 gives a new range of 0 to 75.

Dividing by 75 gives the final desired range of 0 to 1.

I strongly suggest that you get your math in line and familiarize yourself with linear interpolation. For people who attempt game development without linear interpolation, their stuff tends to look like crap because of a lack of smooth transitions, and they waste hours on routine problems that people who do know it finish in seconds.


Firehammer Games
I would make a function out of it, which would be handy for other situations that need it. See this post for it(created by FrostyCat FYI).

You are basically mapping a range to another range, sort of a reverse LERP of sorts. So halfway between the first two values would map to halfway between the second two values. You can then use that mapping to do a LERP between your color choices.