GameMaker is very flexible when it comes to drawing. There are several built-in functions for drawing basic and advanced geometric shapes. Drawing is done by positioning sprites or vertices within the room. In GameMaker, x relates to how many pixels across the screen and y for how many down. The position at the top left is 0,0. This chapter will introduce you to the basics of drawing.
Drawing the border of a room.
Making popup text boxes.
Creating effects when changing rooms.
Making various graphical effects.
Drawing grids, for example for inventory.
There are several built-in color constants that can be used, see Figure 1-9 back in Chapter 1.
which would draw the outline of a circle in the defined color. Setting the value true to false would draw a solid circle.
You can set up global values at game start, so your defined colors are accessible by all objects in your game. Very useful if you will be using a lot of custom color in your game. For example: global.colour_mix_1=make_colour_rgb(80,90,60);
There are many other drawing shapes and functions. Look up the manual for functions starting with draw_ and have a play-around using them.
When in the code window, you can click on a function with the middle mouse button to quickly look up its entry in the manual.
Basic Projects
- A)
Draw a chessboard in black and white, using appropriate drawing functions.
- B)
Use draw functions to draw a floor plan of the room you are in. Use different colors for chairs, tables, lockers, etc.
Advance Project
- C)
Using drawing functions to draw a representation of the Mona Lisa, limit yourself to 30 minutes.
will draw a shape on screen.
A primitive is a collection of points that are connected to each other by lines. This has the advantage over the basic draw_line function as you only need to reference the next point to draw to (as opposed to stating the start and end point).
Useful Functions
Sometimes you may wish to set the alpha of something you are drawing. Setting an alpha changes its transparency (from 0 which is fully transparent to 1 which if fully opaque). This can apply to text, shapes, primitives and sprites, etc.
Which would draw a red rectangle with rounded corners at 50% transparancy.
Summary
You should now be comfortable in setting colors, drawing various geometric shapes, and have better understanding of room co-ordinates.