Game Maker Programming/InputOutput

All of Game Maker's visible output is performed in the Draw event of an instance. By default, the object will be drawn at its specified coordinates, but this can be overridden by creating a draw event. Functions that deal with output have the prefix draw_, and these functions are not guaranteed to provide any visible output if used outside of a draw event.

To receive input, built-in variables are used. keyboard_string holds the last 1,024 characters typed while the window is in focus. mouse_x and mouse_y hold the x and y of the mouse relative to the top left hand corner of the window.

Together with output functions, you can create interactive games very easily based on user input. For example, in the Draw event of an instance:


would draw the last 1,024 characters the user typed, starting from 0,0 - or the upper left hand corner.

Drawing surfaces edit

Note: This is not available in the free version of Game Maker.

It is possible to draw images on a canvas instead of directly on the screen. To do this, you will need to use the functions starting with surface_ and draw_surface_.