Game Development Reference
In-Depth Information
w
++Lnarajpbkn_aobnki^aejc]llhea`ebpdak^fa_peo
++ikrejckqpkb]_khheoekj
^kqj_aT9,7
^kqj_aU9,7
bne_pekjT9,7
bne_pekjU9,7
y
When the bounce and friction forces are calculated, they can be applied to the lh]uan object:
++=llhulh]pbknibne_pekj
lh]uan*rt'9kt)bne_pekjT7
lh]uan*ru'9ku)bne_pekjU7
++Ikrapdalh]uankqpkbpda_khheoekj
lh]uan*t'9kt7
lh]uan*u'9ku7
++>kqj_apdalh]uankbbpdalh]pbkni
lh]uan*^kqj_aT9^kqj_aT7
lh]uan*^kqj_aU9^kqj_aU7
Remember that kt and ku are the amount by which the player overlaps the platform when the colli-
sion occurs. The player is separated from the platform by that amount.
Detecting the top of the platform
There's one other detail I need to point out. The Lh]uan[Lh]pbkni class needs to know when the
lh]uan is on the ground so that it can be permitted to jump. It contains a private Boolean variable
called [eoKjCnkqj` that's accessed by a getter and setter called eoKjCnkqj`. When the lh]uan is on
the bottom of the stage, [eoKjCnkqj` is set to pnqa, and the player can jump.
The lh]uan needs to be able to jump not only when it's on the bottom of the stage but also when it's
on top of a platform. Fortunately, the collision code is able to tell you which side of the platform the
lh]uan is colliding with. All you need to do is set eoKjCnkqj` to pnqa when the code detects a hit with
the top side of a platform:
eb$`u8,%
w
++?khheoekjkjPkl
kt9,7
ku&9)-7
`t9,7
`u9)-7
++oappdalh]uan#oeoKjCnkqj`lnklanpupk
++pnqapkaj]^hafqilejc
lh]uan*eoKjCnkqj`9pnqa7
y
 
Search Nedrilad ::




Custom Search