I've made a script for calculating speed with desired freq.
An example:You create an object called objPlayer. On the left key event you use this code:if(place_free(x-4, y)) { x-=4; }And the user will move 4 pixels to the left.However, if you set the roomspeed to the users screen hz. (ex. 60hz) the user will move 8 pixels to the left.But if you use my script like this:if(place_free(x-4, y)) { x-=freq_pixels(4); }It will move 4 pixels to the left. And if the users screen hz was 100hz. It will still move 4 pixels to the left!The script can be copied from below:——–var sp, freq, calc;sp = argument0;freq = display_get_frequency();calc = (sp / freq) * 30;return calc;——–
Cool
may i change the code?
Instead of 30, use room_speed…var sp, freq, calc;sp = argument0;freq = display_get_frequency();calc = (sp / freq) * room_speed;return calc;That won't work. Then it will return same value as input.
Try it yourself in gm.This code makes the player to move 4 pixels as if the room speed was 30, ALLWAYS
EDIT: it DOES work, but your description wasn't really clear.
Well done, you've rediscovered delta time, only you've mutated it into some anal-raped abomination. Using the screen frequency only works if you're using synchronisation. Here, this is how it should be done:
return argument0 / fps * room_speed;Also, you need to be using that function for the collision checking as well or else you may end up checking 4 pixels ahead and actually jumping forward 6, leading to embarassing sticking problems. Which I'm sure you and your sock are accustomed to.Sorry for my fail at the description. I'm not that good on english.