Towers
Assignment 3
CSSE1001/7030
Semester 1, 2018
Version 1.1.1
20 marks
Due Friday 1st June, 2018, 18:00
1. Introduction
This assignment provides you the opportunity to apply concepts taught throughout the
course to extend the functionality of a basic tower defence game.
The assignment will focus on the concept of Graphical User Interfaces (GUIs) and objectoriented
programming. You will be required to extend the functionality of the base game to
achieve marks.
Students are encouraged to review some tower defence games, to better understand how
this type of game is played and for inspiration on advanced features.
Because this assignment deals with multiple files, while not required, you may wish to
investigate a more sophisticated IDE. One option is PyCharm, which is free for students.
1.1. Game Play
A video overview of the assignment can be found here:
https://www.youtube.com/embed/roE4p1frvwA
2. Overview
2.1. Getting Started
The archive contains all the necessary files to start this assignment. A
significant amount of support code has been supplied to make it possible to begin with a
simple application that is almost working.
The main assignment file is , which contains an incomplete implementation of
, the top-level GUI application class. The other files are support code which
must not be edited. Initially, you do not need to understand much of this code, but as you
progress through the tasks, you will need to understand more of this code . You should add
a3_files.zip
a3.py
TowerGameApp
code to and modify to implement the necessary functionality.
You are permitted to create additional files to simplify the separation of tasks (i.e. task1.py,
task2.py, etc.), although this is not required. If you do this, must be the entry point to
your application. One way to achieve this is to move to a separate file, such
as . Regardless of how you structure your files, the code must all be able to
be demonstrated by running .
3. Assignment Tasks
3.1. Task Overview
This assignment is broken down into three main tasks:
1. The first task involves adding lines of code to clearly marked sections within the main
assignment file
2. The second task involves extending the design to add more interesting functionality to
the game
3. And the third task involves adding sophisticated functionality to further improve the
gameplay experience
For post-graduate students only, there is an extra task that involves doing independent
research.
In general, as the tasks progress, they are less clearly prescribed and increase in difficulty.
3.2. Task Breakdown
CSSE1001 students will be marked out of 20 & CSSE7030 students will be marked out of
26 based on the following breakdown. Tasks may be attempted in any order, but it is
recommended to follow this breakdown, top-down, completing as much as possible of each
task before moving on to the next.
Sub–Task Marks
Task 1
Basic Features
9 marks
App Class 1 marks
Tower Placement 3 marks
StatusBar Class 2 marks
a3.py TowerGameApp
a3.py
TowerGameApp
base.py
a3.py
File Menu & Dialogs 1 marks
Play Controls 2 marks
Task 2
Intermediate Features
7 marks
Buy & Sell Towers 1 mark
Custom Tower & Enemy 2 marks
Shop 3 marks
High Scores 1 marks
Task 3
Advanced Features
4 marks
Advanced Tower 1.25 marks
Advanced Enemy 1.25 marks
Upgrade Tower 1.5 marks
Post-Graduate Task
Independent Research
6 marks
Selection of Library or Technique 2 marks
Application of Library or Technique 2 marks
Integration into Existing Game 2 marks
Sub–Task Marks
3.3. Mark Breakdown
For each task, marks will scaled according to the following breakdown.
Description Marks
Code Quality
Code is readable. Appropriate and meaningful identifier names
have been used. Simple and clear code structure. Repeated code
has been avoided.
15%
Code has been simplified where appropriate and is not overly
convoluted.
10%
Documented clearly and concisely, without excessive or
extraneous comments.
15%
Functionality
Components are functional, without major bugs or unhandled
exceptions.
Assessed through user testing/playing, not automated testing.
60%
Description Marks
4. Task 1 – Basic GUI
Basic GUI Example
There are a significant number of comments in intended to help you complete this
task.
4.1. App Class
Write a function that launches the GUI. Call this function inside
an block.
Modify so that the title of the window is set to something appropriate (i.e.
Towers).
4.2. Tower Placement
Allow the user to place a tower by clicking a grid cell with the mouse. While their mouse is
being moved over the , show a preview of the tower and its range in the current
cell as well as the new path the enemies would take if a tower were placed there. When the
mouse leaves the , hide the preview.
If placing a tower in the current grid cell would make it impossible for the enemies to move
through the grid, or there is already a tower there, the preview should indicate that this
would not be a legal placement by showing an X shape instead of the tower.
Note: For this task, you do not need to ensure that the user can afford the tower.
S e e , , ,
4.3. StatusBar Class
Define a class named , which inherits from . This class is used to
display information to the user about their status in the game. The ' s widgets
must:
1. be updated whenever necessary (i.e. after an enemy dies, etc. - see
comments)
2. be laid out approximately according toBasic GUI Example
3. contain the following widgets:
Wave (first row; centre) A label to display the current wave
Score (second row; centre)A label to display the player's score
Gold (third row; left) A label to display the amount of coins the player has in their
wallet, with an image of gold coins to the right
Lives Remaining (third row; left) A label to display the number of lives the user
has remaining, with an image of a heart to the right
a3.py
main TowerGameApp main
if __name__ == ...
TowerGameApp
GameView
GameView
GameView.draw_preview GameView.draw_path GameView.draw_towers
TowerGame.place
StatusBar tk.Frame
StatusBar
Task 1.3
(Status Bar): Update ...
Note: For convenience, you should have a setter method for each of the relevant widgets.
i.e. , etc.
The class should be added to the application in a frame to the right of the
. Other widgets will be added to this frame in subsequent tasks.
4.4. File Menu & Dialogs
Implement a menu bar, with a menu. The File menu should have the following entries:
: Restarts the game
: Exits the application
When the user attempts to exit the application, either by the file menu or otherwise, they
should first be prompted with a dialog to confirm that they indeed want to quit the
application. Further, when the game is over, the user should be shown a dialog informing
them of the outcome (either win or loss).
Note: On Mac OS X, the file menu should appear in the global menu bar (top of the screen).
4.5. Play Controls
Add a frame to the right of the , below the . Then, add a button to the
frame to send another wave of enemies against the player. Lastly, add a second button to
the frame to pause/resume the current wave. Both buttons should be disabled when the
game is over and (re)enabled when a new game is started.
5. Task 2 – Intermediate Features
5.1. Buy & Sell Towers
Further to 4.2. Tower Placement, if the player cannot afford the currently selected tower, do
not allow them to place it. Otherwise, after placing a tower successfully, deduct the value of
the tower from the player's wallet.
Add a feature that allows the player to sell a tower by right clicking on it. The tower should
be removed from the grid and 80% of its value should be put back into the player's wallet.
See
5.2. Custom Tower & Enemy
Implement a subclass of that is immune to &
damage. Next, implement a subclass of that deals damage (for
use against your custom enemy).
set_score(score)
StatusBar
GameView
File
New Game
Exit
GameView StatusBar
TowerGame.remove
AbstractEnemy projectile explosive
AbstractTower energy
5.3. Shop
The shop allows the user to select other types of towers to use against the enemies.
As shown above, the shop must:
be displayed to the right of the , below the & above the play
controls
display each of the available towers, along with their name & coin cost. The coin cost
should be displayed in red if the user is unable to afford the tower (this should be
updated whenever the user gains or spends coins)
have at least three towers available (i.e. , , & your custom
tower from 5.2. Custom Tower & Enemy)
This task involves implementing the GUI class required to display an
individual tower in the shop.
The class must inherit from and have at least the following
methods:
Shop
GameView StatusBar
SimpleTower MissileTower
ShopTowerView
ShopTowerView tk.Frame
__init__: Must have at least the followingparameters:
master: The parent widget
tower: The tower to display (an instance of )
click_command: A callback function to be called when the tower is clicked
*args & **kwargs: Positional & keyword arguments to be passed to the
constructor
set_available(available: bool): Updates the widget to show whether the tower is
available (white text) or not (red text)
The following code snippets will be useful in completing this task (can also be found in
):
Creating the Shop (used in
)
Drawing a Tower (used in
)
5.4. High Scores
Add an item to the file menu calledHighScores. When clicked, this should display a new
window which displays the names and scores of the top ten scoring players. When the user
runs out of lives, they should be prompted for their name if their score is enough to get in
the high scores list.
Note: The class will be useful for managing high scores.
6. Task 3 – Advanced Features
6.1. Advanced Tower
Create a more sophisticated tower and add it to the shop. This tower must make the game
substantially more interesting by offering functionality that differs from the provided towers.
Possible options for a new tower could be a flame throwing tower, boost tower, slow tower,
...
A key determination in marking this advanced feature is that the new tower requires nontrivial
algorithmic logic to implement its functionality.
6.2. Advanced Enemy
Tkinter
AbstractTower
tk.Frame
a3_files/snippets.txt
TowerGameApp.__init__
ShopTowerView.__init__
HighScoreManager
Create a more sophisticated enemy and add it to the game. This enemy must make the
game substantially more interesting by offering functionality that differs from the provided
enemies. Possible options for a new enemy could be one that shoots at towers, dealing
damage to them, or an enemy that spawns new enemies, ...
A key determination in marking this advanced feature is that the new enemy requires nontrivial
algorithmic logic to implement its functionality.
6.3. Upgrade Tower
Allow players to upgrade a tower. If a player left-clicks on a tower in the grid allow them to
select an upgrade option for the tower. This will activate a set of checkbox options in a
control underneath the play controls. Each option will have an associated cost. Selecting an
option will deduct the cost from the player's wallet and add that feature to the tower.
7. CSSE7030 Task – Independent Research
7.1. Advanced Feature
Research a library or design technique that has not been covered in CSSE7030. Use this to
implement a significant new feature in the game. For example: you could add sound effects
to the game; you could create multiple levels of game play, with additional challenge on
each level; You could use a design pattern to facilitate new functionality within the game
(e.g. towers aging and losing effectiveness).
8. Assignment Submission
Note: There will not be a practical interview for the third assignment.
Your assignment must be submitted via the assignment three submission link on
Blackboard. You must submit a zip file, , containing and all the files required
to run your application (including images). You may omit the support code — if you do so,
the most recent version will be used.
Late submission of the assignment will not be accepted. Do not wait until the last minute to
submit your assignment, as the time to upload it may make it late. Multiple submissions are
allowed, so ensure that you have submitted an almost complete version of the assignment
well before the submission deadline of 6pm. Your latest, on time, submission will be marked.
Ensure that you submit the correct version of your assignment. In the event of exceptional
circumstances, you may submit a request for an extension. See the course profile for details
of how to apply for an extension.
Requests for extensions must be made no later than 48 hours prior to the submission
deadline. The expectation is that with less than 48 hours before an assignment is due it
a3.zip a3.py
should be substantially completed and submittable. Applications for extension, and any
supporting documentation (e.g. medical certificate), must be submitted via my.UQ. You must
retain the original documentation for a minimum period of six months to provide as
verification should you be requested to do so.
Change Log
Version 1.1.1 - May 18
Clarified 5.1. Buy & Sell Towers
Moved to
Version 1.1.0 - May 17
It is recommended that you immediately update your support code. However, if you began
working on the assignment in version 1.0.0, you may submit it with version 1.0.0 of the
support code.
Assignment Sheet
Fixed typographical errors
Restructured 5.3. Shop & added helpful snippets
Extended 5.1. Buy & Sell Towers to cover paying for towers
Support Files
Added missing docstrings to
Added attribute to & its subclasses
Implemented & added
Restructured & subclasses to accept most configurables as default parameters
to
Merged into
Refactored to accept as parameter to support arbitrary unit
queries (i.e. collision detection, multiple targets, etc.)
Fixed bugs:
did not reset path or clear enemies
Preview flickered while game was playing
Placing tower over enemies crashed game; now enemies are moved to an
adjacent cell, preferring their previous cell
Enemies oscillated around centre of path-corner cell if they couldn't reach centre
(i.e. their speed was not a divisor of )
SimpleTower._get_target AbstractTower
a3.py
name Unit
PulseTower Pulse
Unit
__init__
AbstractTower.attack .step
Unit.step GameData
TowerGame.reset
cell_size
Combined into & simplified
Abstracted view logic for enemies & obstacles to
Refactored 's dependency on to default parameters
Removed method in favour of
Moved type hint definitions to
Converted to function and moved to
tower/range_view.py advanced_view.py
advanced_view.py
GameView Tower/RangeView
AbstractEnemy.get_real_position
AbstractEnemy.position
utilities.py
View.calculate_bounds utilities.py
版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。