Game Development Reference
In-Depth Information
The following is the new code that really makes this whole system work:
++Ikrapdalh]uan
lh]uan*t'9rt7
lh]uan*u'9ru7
++Opkllh]uan]pejjan^kqj`]nua`cao
eb$lh]uan*t)lh]uanD]hbSe`pd8habpEjjan>kqj`]nu%
w
lh]uan*t9habpEjjan>kqj`]nu'lh]uanD]hbSe`pd7
^]_gcnkqj`*t)9rt7
y
ahoaeb$lh]uan*t'lh]uanD]hbSe`pd:necdpEjjan>kqj`]nu%
w
lh]uan*t9necdpEjjan>kqj`]nu)lh]uanD]hbSe`pd7
^]_gcnkqj`*t)9rt7
y
eb$lh]uan*u)lh]uanD]hbDaecdp8pklEjjan>kqj`]nu%
w
lh]uan*u9pklEjjan>kqj`]nu'lh]uanD]hbDaecdp7
^]_gcnkqj`*u)9ru7
y
ahoaeb$lh]uan*u'lh]uanD]hbDaecdp:^kppkiEjjan>kqj`]nu%
w
lh]uan*u9^kppkiEjjan>kqj`]nu)lh]uanD]hbDaecdp7
^]_gcnkqj`*u)9ru7
y
You can see that you're back to moving the lh]uan again. But it is allowed to move only while it's
within the inner boundaries. Let's have a look at how the first eb statement works:
eb$lh]uan*tÌlh]uanD]hbSe`pd8habpEjjan>kqj`]nu%
w
lh]uan*t9habpEjjan>kqj`]nu'lh]uanD]hbSe`pd7
^]_gcnkqj`*t)9rt7
y
The conditional statement checks to see whether the left edge of the lh]uan is less than the left inner
boundary. If it is, the lh]uan is forced back to that edge. This is exactly the same logic you used to stop
the lh]uan object at the edges of the stage. But the next line is interesting:
^]_gcnkqj`*t)9rt7
The ^]_gcnkqj` starts moving! And that's really all there is to it. The code is quite simple, but the
effect it produces seems complex when the program runs.
 
Search Nedrilad ::




Custom Search