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.

Starting 3D mode will result in the following changes. First of all hidden surface removal is<br />

switched on (using a 16-bit z-buffer). This means that for each pixel on the screen only the<br />

drawing <strong>with</strong> the smallest z-value (= depth value) is drawn. If instances have the same depth<br />

it is unclear what will happen and you can get ugly effects. Make sure instances that might<br />

overlap do not have the same depth value!<br />

Secondly, the normal orthographic projection is replaced by a perspective one. This means the<br />

following. Normally the size of instances on the screen is independent on its depth. With a<br />

perspective projection instances that have a greater depth will appear smaller. When the<br />

depth is 0 it is equal to the old size (unless you change the projection; see below). The<br />

viewpoint for the camera is placed at a distance above the room. (This distance is equal to the<br />

width of the room; that gives a reasonable default projection.) Only instances in front of the<br />

camera are drawn. So don't use instances <strong>with</strong> a depth smaller than 0 (or at least not smaller<br />

than -w where w is the width of the room or the view).<br />

Thirdly, the vertical y-coordinate is reversed. While normally the (0,0) position is at the top-<br />

left of the view, in 3D modo the (0,0) position is at the bottom-left position, as is normal for<br />

3-dimensional views.<br />

You can actually switch hidden surface remove and perspective projection on or off using the<br />

following functions.<br />

d3d_set_hidden(enable) Enables hidden surface removal (true) or<br />

disables it (false).<br />

d3d_set_perspective(enable) Enables the use of a perspective<br />

projection (true) or disables it (false).<br />

Easy drawing<br />

Once 3D mode has been switched on you can use <strong>Game</strong> <strong>Maker</strong> as you are used to it (except<br />

for the remarks made at the beginning). Only objects will appear in different sizes based on<br />

their depth setting. You can even use views. One additional function can be useful. If you draw<br />

a number of things in a piece of code you might want to change the depth value between the<br />

primitives you draw. For this you use:<br />

d3d_set_depth(depth) Sets the depth used for drawing.

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

Saved successfully!

Ooh no, something went wrong!