Game Development Reference
In-Depth Information
There are other specialized classes that are working simultaneously with @qjcakjKja[I]j]can:
Lh]uan: Contains the player's keyboard control system. It also keeps track of whether the key
has been picked up.
S]hh: Sends references of all the s]hh instances to the @qjcakjKja[I]j]can class to help with
collision detection between the walls and the player.
@kkn: Keeps track of whether the doors are open or closed. It also plays a sound when the door
is opened.
Sa]lkj: Lets the player fire bullets. It creates new instances of the >qhhap class and adds them
to the stage.
>qhhap: Controls the bullets' movement.
As long as all the classes are in the same project folder, they can communicate with each other.
Let's take a look at the @qjcakjKja[I]j]can class. It's a very long class, but don't let that scare you.
Most of the game logic is in the kjAjpanBn]ia event handler, and I numbered and highlighted each
important section with code comments. You'll see that you can break each of the major occurrences
in the game down into very manageable and almost mundane eb/ahoa statements.
A good way to read the code is while you're playing the game. When you complete a specific task in
the game, such as picking up the key, see if you can figure out how code actually makes it work. I used
numbered comments in the code to walk you through it. You'll recognize most of this code immedi-
ately from other chapters. I'll explain the all-new code, and how this code integrates with the other
classes, in the pages ahead.
DungeonOne_Manager class
l]_g]ca
w
eilknpbh]od*`eolh]u*Ikrea?hel7
eilknpbh]od*arajpo*Arajp7
lq^he__h]oo@qjcakjKja[I]j]canatpaj`oIkrea?hel
w
lq^he_bqj_pekj@qjcakjKja[I]j]can$%
w
++Ejepe]hevapda_h]oosdajpda
++`qjcakjk^fa_poeo`eolh]ua`kjpdaop]ca*
]``ArajpHeopajan$Arajp*=@@A@[PK[OP=CA(kj=``a`PkOp]ca%7
y
lner]pabqj_pekjkj=``a`PkOp]ca$arajp6Arajp%6rke`
w
++=``arajpheopajano
]``ArajpHeopajan$Arajp*AJPAN[BN=IA(kjAjpanBn]ia%7
]``ArajpHeopajan$Arajp*NAIKRA@[BNKI[OP=CA(kjNaikra`BnkiOp]ca%7
 
Search Nedrilad ::




Custom Search