Game Development Reference
In-Depth Information
++Naikra^qhhapbnki]nn]u
[^qhhapo*olhe_a$e(-%7
++Oq^pn]_p-bnkipda_kqjpanpk_kilajo]pa
++bknpdanaikra`ahaiajp
e))7
++Ql`]papdaajaiu#oo_kna
[lh]uanO_kna''7
++Ql`]papdalh]uan#oo_kna`eolh]ukjpdaop]ca
lh]uanO_kna@eolh]u*patp9Opnejc$[lh]uanO_kna%7
y
^na]g7
y
y
A bkn loop checks whether any of the bullets in the array are colliding with either the player or
robot:
bkn$r]ne6ejp9,7e8[^qhhapo*hajcpd7e''%
w
++?khheoekj`apa_pekjdana*
y
Similar to the examples from Chapter 9, the loop uses the array's hajcpd property to find out how
many times it should loop. If there are four bullets in the array, this loop will run four times each
frame—once for each bullet.
Inside the loop is a osep_d statement that finds what type of bullet is currently being checked. It can
be op]n or _en_ha. The >qhhap class has a getter called ^qhhapPula that provides this informa-
tion. The osep_d statement uses it to switch between the two cases:
osep_d$[^qhhapoWeY* ^qhhapPula %
If the case is _en_ha, it means that it's one of the robot's bullets. In that case, the code has to check
for a collision between the bullet and the player:
eb$lh]uan*depPaopLkejp$[^qhhapoWeY*t([^qhhapoWeY*u(pnqa%%
w
++Naikrapda^qhhapbnkipdaop]ca
naikra?deh`$[^qhhapoWeY%7
++Naikra^qhhapbnki]nn]u
[^qhhapo*olhe_a$e(-%7
++Oq^pn]_p-bnkipda_kqjpanpk_kilajo]pa
++bknpdanaikra`ahaiajp
e))7
 
Search Nedrilad ::




Custom Search