Jump to content
Lab #2: The Quest
2 replies to this topic
Posted 01 July 2014 - 06:41 AM
Hi to everyone!
I'm having trouble understanding the architecture of the Lab #2: The Quest project.
If the Game class keeps track of everything that is happening, and only that class is exposed to the form,
why do Enemy, Player and Mover classes have such a class reference in their constructor?
Thank you for helping
I'm reading the 3rd edition.
Posted 01 July 2014 - 04:52 PM
That's a great question -- it's really good that you're thinking about how the objects relate to each other, and about what information they have available to them.
The Enemy objects need to know where the player is because they move towards him, so their Move() methods need to know the player's location. They'll use the game.PlayerLocation property for that. When the player attacks, the Player object's Attack() method needs to know where the enemies are, so it will use the game.Enemies property to locate them.
I hope this helps!
Author, Head First C#
Building Better Software -- http://www.stellman-greene.com
Posted 03 July 2014 - 10:06 AM
This makes sense.
I'm just a little bit confused how this architecture works. There is a lot going on. Objects are constantly updated with new information.
I can't wait to use the debugger tool on the finnished project to see how these objects communicate with each other.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users