user4228573
user4228573

Reputation:

Game Maker framerate and other timing related things

What's the framerate in GM games and how often is the game code executed per frame? I can't find the answer anywhere explained so that I would understand it. Are there ways to change these? I'm used to solid 60 fps and game code executed once per frame. This is important since I'm used to programming in frame timing, meaning that a one frame is the smallest unit of time that can be used, and counters are incremented (or decremented) once per frame. This also means that drops in framerate will create slowdown instead of frames begin skipped. The game code in the game I've been programming on another program basically runs the game code once an then waits for a VBlank to happen before running the game code again.

Upvotes: 1

Views: 6706

Answers (3)

PGmath
PGmath

Reputation: 450

You can change the room speed in the room settings, this is the number of steps per second. This property can also be accessed and changed mid-game with the room_speed global.

You can also access the actual screen update speed with the fps read-only global. Note: screen fps is totally independent from the draw event, which happens at the end of each step.

Upvotes: 0

null
null

Reputation: 566

Let me explain how GM works. It's complicated.

When the game starts, the game start event from every object is called. I believe this happens AFTER the create event.

Once per (virtual) frame, the step event is called. You see, GM doesn't lock itself down to whatever the room_speed is, it will run as fast as it can. (If not compiled.) fps_real shows you how many frames per second the engine is ACTUALLY pumping though in any given second.

So every second, assuming the processor and GPU can keep up with the room_speed, room_speed amount of step events occur. Take this situation for example:

  • room_speed is 60
  • fps is 60
  • fps_real is 758
  • Let's assume there is an ObjPlayer with a step event.

In this situation, ObjPlayer's step event will be run 60 times in that second.

This is a problem, however. Let's say, if the keyboard space button is held down, the player moves 3 pixels to the left. So assuming the game is running at full speed (room_speed), the player will move 3 * 60, or in this case, 180 pixels in any given second.

However, let's say that the CPU and/or GPU can't keep up with 60 FPS. Let's say it's holding steady at 30. That would mean that the player will move a mere 3 * 30, or 90 pixels a second, making the game look much slower than it should. But if you have played a AAA game like Hitman Absolution, you will notice that the game looks just as fast at 30 FPS as it does at 120 FPS. How? Delta time.

Using delta time, you set the room_speed at max, (9999) and every time you call upon a pixels-per-frame speed, multiply it by a delta time that has been worked over to work with 60 FPS. I am explaining it terribly, and it's a lot easier than I make it out to be. Check out this guide on the GMC to see how to do it.

When you have delta time, you don't need to worry (as much) about the FPS -- it looks the same in terms of speed no matter what.

But as for refresh rate, I am not 100% sure, but I believe that GM games are 60hz, I could be wrong, but that's what I've heard. All GM games are also 32 bit.

Upvotes: 2

Timtech
Timtech

Reputation: 1274

The variables room_speed and fps may be what you are looking for. There is no point in increasing fps to anything higher than room_speed, which can be modified during program execution or statically through the room editor and is 30 by default.

Upvotes: 0

Related Questions