• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Windows PERFORMANCE: Keyboard/Mouse-Events VS. Input-Checks in STEP.

R

Ratatosque

Guest
So recently i tried to implement alternative input devices besides my usual keyboard/mouse controls.
One of the issues was a huge fps-drop (1200 fps to 18 fps) due to a bug or peculiarity with the joystick functions. I talked with some people in another thread about this.

Now another thing that occurred is the following.
Since i used the events for mouse and keyboard for the input before, i now had to check for the input in the step event, as there is no seperate event for gamepad input in gamemakers UI.
For example:

Now instead of the mouse-enter event to make my buttons glow i have to use this in the step event of the parent for all buttons:
( they all glow when hovered over )
Code:
if position_meeting(mouse_x,mouse_y,id)
        {
      
        glow=true;
        image_index=1;
  
        }else
            {
            glow=false;
            image_index=0;
            }

For the click to for example start the game i check in the step event like this:
This is in the start button, which is a child of the obj_parent_Button
Code:
event_inherited()


    if position_meeting(mouse_x,mouse_y,id) && mouse_check_button_pressed(mb_left)
        {
    
        scr_button_start_game()

        }

the issue is, it seems that with this method i still get an fps drop from around 1200 fps to around 120 fps. Is this normal? May there be another reason for this issue other than the input check? Is there a more effective way to implement multiple input devices and to check them without loosing huge chunks of performance?

Much thanks in advance!
 

TheouAegis

Member
First off, make sure short-circuit evaluations are enabled in the game settings, then move mouse_check_button_pressed(mb_left) so it's the first condition checked. But how many buttons are in the room? You shouldn't get that significant of an fps drop normally even with that code.

You started off talking about the gamepad, then your code is using the mouse. Are you checking for all three inputs at the same time and just showing the mouse code here? If you have code checking the gamepad too, you should disable that code if no gamepad is detected.
 
R

Ratatosque

Guest
First off, make sure short-circuit evaluations are enabled in the game settings, then move mouse_check_button_pressed(mb_left) so it's the first condition checked. But how many buttons are in the room? You shouldn't get that significant of an fps drop normally even with that code.

You started off talking about the gamepad, then your code is using the mouse. Are you checking for all three inputs at the same time and just showing the mouse code here? If you have code checking the gamepad too, you should disable that code if no gamepad is detected.
the gamepad funcions come below the mouse-code. the first condition is "if obj_cursor exists" which is a replacement for the mouse cursor controlled by the gamepad, then the same code followes with fire_0 (a button for shooting pressed) instead of mouse_check_button_pressed(mb_left). thanks for the suggestions i will try them and see how it changes the performance.

edit: hm at first it seemed to work putting the mouse_check first. i had 1000 fps again when starting the game. but starting several times over and observing the fps-rate i noticed huge variatons. in the end i was at 90 fps starting the game. this gives me some worries. either its because of windows doing something in the back or me having some memory-leak in my game. damn it.
 
Last edited by a moderator:
Top