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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

}<br />

ttt = background_get_texture(back);<br />

d3d_primitive_begin_texture(pr_trianglefan,ttt);<br />

d3d_vertex_texture(0,480,0,0,0);<br />

d3d_vertex_texture(640,480,0,1,0);<br />

d3d_vertex_texture(640,480,1000,1,1);<br />

d3d_vertex_texture(0,480,1000,0,1);<br />

d3d_primitive_end();<br />

A triangle has a front and a back side. The front side is defined to be the side where the<br />

vertices are defined in counter-clockwise order. Normally both sides are drawn. But if you<br />

make a closed shape this is a waste because the back side of the triangle can never be seen.<br />

In this case you can switch on backface culling. This saves about half the amount of drawing<br />

time but it leaves you <strong>with</strong> the task of defining your polygons in the right way. The following<br />

function exists:<br />

d3d_set_culling(cull) Indicates to start backface culling (true) or stop<br />

backface culling (false).<br />

Drawing basic shapes<br />

A number of functions exist for drawing basic shapes, like blocks and walls. Note that these<br />

shapes also work correctly <strong>with</strong> backface culling on.<br />

d3d_draw_block(x1,y1,z1,x2,y2,z2,texid,hrepeat,vrepeat)<br />

Draws a block in the current color <strong>with</strong> the indicated opposite corners using<br />

the indicated texture. Use -1 to not use a texture. hrepeat indicates how<br />

often the texture must be repeated along the horizontal edge of each face.<br />

vrepeat does the same for the vertical edge.<br />

d3d_draw_cylinder(x1,y1,z1,x2,y2,z2,texid,hrepeat,vrepeat,c<br />

losed,steps) Draws a vertical cylinder in the current color in the indicated<br />

bounding box using the indicated texture. Use -1 to not use a texture.<br />

hrepeat indicates how often the texture must be repeated along the<br />

horizontal edge of each face. vrepeat does the same for the vertical edge.<br />

closed indicates whether to close the top and bottom of the cylinder. steps<br />

indicates how many rotational steps must be taken. A typical value is 24.

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

Saved successfully!

Ooh no, something went wrong!