Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // oliver @pixelchipcode
- //create
- // Default frame rate settings
- default_fps = 60;
- target_fps = default_fps;
- change_speed = 1; // Speed of transition (higher = faster change)
- current_fps = default_fps;
- // Set the initial game speed
- game_set_speed(default_fps, gamespeed_fps);
- //step
- if (mouse_check_button(mb_left)) {
- // Set the slow-motion target frame rate on mouse press
- target_fps = 10; // Example: Slow motion at 30 FPS
- } else {
- // Reset to the normal frame rate on release
- target_fps = default_fps;
- }
- // Smoothly interpolate the current FPS towards the target FPS
- if (abs(current_fps - target_fps) > 0.1) { // Only adjust if there's a noticeable difference
- current_fps = lerp(current_fps, target_fps, change_speed * delta_time / 100000);
- // Clamp and round the FPS to ensure valid values
- current_fps = clamp(round(current_fps), 1, 1000); // FPS range: 1 to 1000
- // Set the game speed
- game_set_speed(current_fps, gamespeed_fps);
- }
Advertisement
Add Comment
Please, Sign In to add comment