Game Development Reference
In-Depth Information
It turns out that knowing the half-width and half-height of objects is extremely important for doing
certain kinds of advanced collision detection. Remember the solution to this screen boundary problem
because you'll use it to help solve a number of tricky problems throughout the course of this topic.
You can find the completed version of this code in the I]ej[O_naaj>kqj`]neao*]o file in this chap-
ter's source files.
Screen wrapping
Screen wrapping happens when an object disappears from one side of the screen and then reemerges
from the opposite side. This is quite a fun effect and very easy to implement. In fact, the logic that's
used to accomplish it is almost exactly the inverse of the logic you used to block movement at the
stage's edges. Let's try it out!
1. Change the conditional statements inside the kjAjpanBn]ia event handler to match the text in
bold:
bqj_pekjkjAjpanBn]ia$arajp6Arajp%6rke`
w
++Ejepe]hevahk_]hr]ne]^hao
r]nlh]uanD]hbSe`pd6qejp9lh]uan*se`pd+.7
r]nlh]uanD]hbDaecdp6qejp9lh]uan*daecdp+.7
++Ikrapdalh]uan
lh]uan*t'9rt7
lh]uan*u'9ru7
++O_naajsn]llejc
eb$lh]uan*t)lh]uanD]hbSe`pd:op]ca*op]caSe`pd%
w
lh]uan*t9,)lh]uanD]hbSe`pd7
y
ahoaeb$lh]uan*t'lh]uanD]hbSe`pd8,%
w
lh]uan*t9op]ca*op]caSe`pd'lh]uanD]hbSe`pd7
y
eb$lh]uan*u'lh]uanD]hbDaecdp8,%
w
lh]uan*u9op]ca*op]caDaecdp'lh]uanD]hbDaecdp7
y
ahoaeb$lh]uan*u)lh]uanD]hbDaecdp:op]ca*op]caDaecdp%
w
lh]uan*u9,)lh]uanD]hbDaecdp7
y
y
 
Search Nedrilad ::




Custom Search