-
Notifications
You must be signed in to change notification settings - Fork 0
/
GAME
146 lines (130 loc) · 8.45 KB
/
GAME
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
I added to the original game a quest system and some new characters and features.
QUEST 1:
- Speak with the warrior
- Find him a new sword
- speak with the beekeper
- bring back his bees
- kick the bees to get them follow you
- run near the beekeper
- you only need to bring back the 3 bees near the lake
- speak again with the beekeper
- take the sword from inside the crate
QUEST 2:
- Free the wizard
- use the warrior to kill the bees
- speak with the wizard
- Get a spell from the chemist
- speak to the chemist controlling the wizard
QUEST 3:
- Reach the shrine in the center of the map
- Use the wizard's spell to burn the trees
- When you arrive near the shrine activate it
You must do those stuff in the right sequence and with the right character (eg. speaking with the chemist
with the boy won't get you the spell and you can't kick the bees before talking with the warrior and the
beekeper)
-----------------------------------------------------------------------------------------------------------
### AGENTS ###
I added two new playable characters: the warrior and the wizard. At the beginning you can control only the
boy and the girl but during the quests you'll get the control of the other two.
- Warrior
For the warrior I created with GIMP two sets of images. At the beginning he's without sword and after
completing the first quest he gets a sword and a shield. To do this there are different images for
running and standing with or without weapons. Attacking is possible only after getting the sword so
for that action there is only one set of images.
- Bees
There are two groups of images, differentiated by their ID.
The first three are near the beekeper and can be kicked: this action'll make them following you. If
they arrive too near to you they'll attack and you'll loose some health. Every time in the
onInstanceActionFinished handler they check if they are near the beekeper: in this case they stop
following the hero and start moving randomly near the beeboxes.
The other four can be attacked by the warrior: after being hit they will fall and lie on the ground.
All the bees moves randomly inside a small area near their initial position or near the beeboxes.
When they moves randomly they're very slow but their speed increases when kicked.
- Wizard
I renamed the hippie_priest as wizard. It's now a playable character and when he cast a spell he
creates a fireball which is useful to burn the trees.
- Fireball
For the fireball I created with GIMP the 8 images (for each orientation) for when it's flying and for
the explosion. Stand's images are empty so when the fireball is not being used it's invisible.
This agent has three action, which are stand, fly and explosion. There are 4 fireballs in the map, so
it's possible to cast another spell when the first one is not yet finished.
Sometimes the fly action fails because there are no free path from the current position to the target;
to fix this problem immediately before the explosion the agent position is set to the target location.
In this way you can't see the fireball flying there but you'll only see the explosion.
- Crate
This crate is near the beekeper. At the beginning it's closed and you can only inspect it. When all
the bees are back near the beeboxes it'll be possible to open it and get the sword and the shield
inside.
-----------------------------------------------------------------------------------------------------------
### CODE ###
I created some new classes to write a more modular code. I tryed to separate the code related to the
agents, the game status and the dialogs.
- Game
The main purpose of this class is keep the game status. Inside there's a state machine which decide
accordingly to the current status which are the available actions.
In this class there are the methods to save and load the game status: all the useful parameters are
written in a file called conf (which contains a copy of the last saved state) and in files inside
the saves folder.
I tryed to make all classes as much separated as possible: the (almost) only function of Game which is
called from the other classes is 'event()', so it's possible to change the internal structure of Game
without having to change other parts of the code.
In this class there are also most of the UI callbacks.
- AgentManager
This class initialize all agents and keep a reference to them. It contains a list of all the playable
characters so it's able to toggle the active agent.
It also contains methods to get all the agents and get the agent corresponding to a specific id.
There are two methods 'beesAtHome' and 'BeesDead' which check if all the bees are near the beeboxes
of if they're all dead.
- Agent
Every agent class inherits from this class. Here are set the properties and methods common to each
agent like 'say()' and 'health'. Two useful methods are 'getX()' and 'getY()' which returns the
agent's coordinates.
- Dialog
This class shows and hides the instancemenu and the status dialog. The instancemenu's buttons are
choosen by the Game class because they depend on the agent and the game's state.
-----------------------------------------------------------------------------------------------------------
### GAME ###
- Dialogs
At the beginning of each quest or when you click on the hint button a popup will appear with the
current quest's objectives and hints.
- Health bar
Immediately below the player image in the top-left corner of the screen you can see the health bar.
This bar changes color accordingly to the health percentage of the current character. The only way to
loose height is by being attacked by the bees.
- Status label
Below the player image there is a label PAUSE which appears when the game is paused, which usually
means that you are speacking with someone or you're reading the quest instructions. Until the end of
the dialog or the closure of the popup window you cannot move the characters: all your clicks
will be ignored.
- Save & Load
When the quit button is clicked or you press thw ESC key a menu will appear. It has 3 different
options: save, load and exit. With save it's possible to save the game state in a file: the same
parameters will be written also in the file conf so the next time that you launch the game you'll
start from that point.
If you choose the load option, a new menu will appear with the list af the last 5 saves plus the three
default saves that correspond to the beginning of each quest. When you choose one of this saves the
game'll be set to that particular state: all characters (including the bees) will be positioned in
their last position and they'll start acting as before.
With the exit button instead you'll exit the game without saving.
-----------------------------------------------------------------------------------------------------------
### ADDITIONS ###
- Tests
I also added some unit tests to the game. They're not part of the game code or really useful but I
added them to learn how to write tests in python and how to use the MagicMock library.
To run them it's enough executing "python test_main.py" from the demos/softdev folder. The real
implementation is in a file called test_game.py inside the code folder.
- Git
To keep track of all versions of my game and sometimes to rollback when I made some mistakes I used
git. In the submitted archive there is also the .git folder, so it's possible to see the versions
history.
The remote repository is hosted on bitbucket and will be made public since the 1st of February, 2014
with the following url: https://bitbucket.org/drolando/softdev
-----------------------------------------------------------------------------------------------------------
### PROBLEMS ###
- Deletion problem
Sometimes when you destroy the trees the agents are not able to cross the cell previously occupied by
the tree. If you get this error save the game, close it and launch it again.
I tryed to fix this bug but it seems to be a bug of FIFE ENGINE. I'm using their function
'layer.deleteInstance()', moving the trees in the right position only after initializing the agents
and I also modified the shrine.xml as written on their forum to use 'narrow cells' and static cells
but it's not enough.