08.11.2012 Views

Designing Games with Game Maker - YoYo Games

Designing Games with Game Maker - YoYo Games

Designing Games with Game Maker - YoYo Games

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

You can also draw larger primitives. This works slightly different. You begin by specifying the<br />

primitive you want to draw. Next you specify the vertices for it, and finally you end the<br />

primitive, at which moment it is drawn. There are six types of primitives:<br />

pr_pointlist The vertices are a set of points.<br />

pr_linelist The vertices are a set of line segments. Each pair of vertices<br />

forms a line segment. So there must be an even set of vertices.<br />

pr_linestrip The vertices form a polyline <strong>with</strong> the first connected to the<br />

second, the second to the third, etc. The last one is not connected to the first<br />

one. You have to specify an extra copy of the first vertex for this.<br />

pr_trianglelist The vertices are a set of triangles. Each triple of vertices<br />

forms a triangle. So the number of vertices must be a multiple of 3.<br />

pr_trianglestrip The vertices again form triangles but this time it works<br />

slightly different. The first three form the first triangle. The last two of these<br />

vertices, together <strong>with</strong> the next vertex, form the second triangle, etc. So each<br />

new vertex specifies a new triangle, connected to the previous one.<br />

pr_trianglefan Similar to a triangle list but this time the first vertex is part<br />

of all the triangles. Again, each new vertex specifies a new triangle, connected<br />

to the previous vertex and the first vertex.<br />

The following functions exist for drawing primitives<br />

draw_primitive_begin(kind) Start a primitive of the indicated kind.<br />

draw_vertex(x,y) Add vertex (x,y) to the primitive, using the color and<br />

alpha value set before.<br />

draw_vertex_color(x,y,col,alpha) Add vertex (x,y) to the primitive,<br />

<strong>with</strong> its own color and alpha value. This allows you to create primitives <strong>with</strong><br />

smoothly changing color and alpha values.<br />

draw_primitive_end() End the description of the primitive. This function<br />

actually draws it.<br />

Finally, it is possible to draw primitives using sprites or backgrounds as textures. When using<br />

a texture the image is placed on the primitive, reshaping it to fit the primitive. Textures are<br />

used to add detail to primitives, e.g. a brick wall. To use textures you first must obtain the id<br />

of the texture you want to use. For this the following functions exist:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!