copying, or obtaining source code by any means other than through an act of original creation by yourself, is strictly prohibited.
Exceptions: you are strongly encouraged to call functions defined in the current version of the cab202_teensy library, as downloaded from CAB202 2019 Semester 1 Blackboard Learning Resources on or after 25 February 2019.
6. Abundant code samples, demonstrations, and exercises have been made available to support your effort toward this programming task. Written permission must be obtained from the Unit Coordinator if you want to use technology other than the ZDK to implement your game. Permission will only be granted if there are compelling special circumstances that make it impossible for you to use the ZDK. Without this permission, a game implemented with some other graphical framework will receive a score of 0. Direct use of the ncurses library to render graphics or text is expressly prohibited.
Breaching any of the foregoing conditions will result in an immediate and final score of 0 for the Assignment.
In this game you control a starfighter which must defend the Earth from a catastrophic asteroid swarm. Asteroids enter the playfield at the top of the LCD display, and travel generally downwards. The starfighter is equipped with a potent plasma cannon mounted in a turret in its nose. When fired, this emits a coherent packet of highly energetic plasma (a plasma bolt) which travels in straight line from the launch point. The plasma cannon covers a 120-degree forward arc (i.e. in front of the starfighter), with default firing direction straight ahead. You can fire plasma bolts by aiming the turret at any point within the forward arc. When a plasma bolt hits an asteroid, the asteroid splits to form two boulders. Boulders continue to move downwards, at a new (different) oblique angle. When a plasma bolt strikes a boulder, the boulder splits to form two fragments, which in turn continue to move downwards at new oblique angles. The starfighter is protected by a deflector shield which extends horizontally across the display just in front of it. When the deflector shield is touched by an object (asteroid, boulder, or fragment), the object is immediately destroyed but the shield takes damage. Eventually, cumulative damage weakens the shield and the starfighter is destroyed by intense ionising radiation released as the shield collapses.
Joystick left: move spaceship leftJoystick right: move spaceship rightJoystick up: fire plasma boltsJoystick down: send and display game statusJoystick centre: pause gameLeft button: start/restart gameRight button: quitLeft potentiometer: set the aim of the turretRight potentiometer: set the speed of the game
'a' – move spaceship left'd' – move spaceship right'w' – fire plasma bolts's' – send and display game status'r' – start/reset game'p' – pause game'q' – quit't' – set aim of the turret
'm' – set the speed of the game'l' – set the remaining useful life of the deflector shield'g' – set the score'?' – print controls to computer screen (Putty)'h' – move spaceship to coordinate'j' – place asteroid at coordinate'k' – place boulder at coordinate'l' – place fragment at coordinate
i. The Starfighter is at least 4 pixels and no more than 7 pixels in height.ii. The Starfighter is at least 5 pixels and no more than 15 pixels in width.iii. The Starfighter has a turret from which the linear wave-guide the Plasma Cannon extends. This will look like a short straight line. All further mentions of Starfighter include the turret.
iv. When the game starts or resets, the Starfighter is horizontally centred in the bottom 8 rows (i.e. rows 40 - 47) of the screen, or as close to the centre as possible given the geometry of your design.v. When the game game starts or resets, the Starfighter is stationary.vi. No part of the Starfighter may ever leave the screen or overlap the Deflector Shield.vii. The Starfighter may never move vertically.
i. Asteroids fall from the top of the screen, two seconds after the game is started or restarted, and pose a danger to the Starfighter.ii. Initially, three Asteroids spawn at random horizontal positions above the top of the screen, and move smoothly into view one row of pixels at a time (i.e: they do not simply appear).iii. Asteroids may not go outside the left, right and bottom edges of the screen (but may be seen to come in from the top of the screen).iv. Asteroids fall downwards only.v. If a falling object touches the Deflector Shield, the object disappears and the remaining useful life of the Deflector Shield decreases.vi. When hit by a Plasma Bolt (see below) Asteroids split to form two Boulders, and Boulders split to form two fragments. Fragments just disappear when hit by a Plasma Bolt.vii. When an object splits, each of the two resulting objects acquires a new random velocity within += 30 degrees of the heading of the object that has been destroyed.viii. When a falling object is hit by a Plasma Bolt, the player's score increases.ix. Falling object sizes are as follows:
Asteroid: are 7 by 7 pixels, shaped like diamonds, and give 1 point when shot.Boulder: are 5 by 5 pixels, shaped like diamonds, and give 2 points when shot.Fragment: are 3 by 3 pixels, shaped like plus symbols, and give 4 points when shot.
i. Game timeii. Remaining Useful Lifeiii. Score
i. Game timeii. Livesiii. Scoreiv. Number of asteroids on screenv. Number of boulders on screenvi. Number of fragments on screenvii. Plasma bolts on screenviii. Aim of turretix. Speed of game
i. At the beginning of the game, the Starfighter is randomly assigned a velocity, by default, that is speed 1 in either the left or right direction.ii. From a stationary position, pressing Joystick Left or 'a' causes the Starfighter's velocity to increase in the left direction.iii. From a stationary position, pressing Joystick Right or 'd' causes the Starfighter's velocity to increase in the right direction.iv. From a left velocity, pressing Joystick Left or 'a' again, results in no change.v. From a left velocity, pressing Joystick Right or 'd', causes the Starfighter's velocity to change to 0, stopping the Starfighter's movement.vi. From a right velocity, pressing Joystick Right or 'd' again, results in no change.vii. From a right velocity, pressing Joystick Left or 'a', causes the Starfighter's velocity to change to 0, stopping the Starfighter's movement.viii. When the Starfighter hits the side of the screen, it automatically bounces, reversing it's direction.
i. In the Plasma Cannon coordinate system, 0 degrees is taken to be straight up. The Plasma Cannon is restricted to aim between 60 degrees left of centre (-60) and 60 degrees right of centre (+60).ii. Setting the left potentiometer to its physical minimum position corresponds to -60. Setting it to its maximum position corresponds to +60.iii. The Plasma Cannon should visibly move to reflect the current angle as accurately as possible.
i. Plasma bolts are fired if either the Joystick Up is pressed or 'w' is received via USB serial, but only if at least 0.2 seconds has elapsed since the last Plasma Bolt was fired.ii. Plasma bolts travel in the direction at which the Plasma Cannon was aimed when they were launched, moving with constant velocity.iii. Plasma bolts disappear when they hit a falling object, or when they reach the edge of the screen.iv. The maximum number of plasma bolts on screen at any given time is 100.v. If Joystick Up or 'w' is pressed and there are already 100 plasma bolts on screen, nothing happens.
1. Student number2. Game title3. Some kind of animation4. Use of PWM to adjust the brightness of the back-light (either on or off is up to you).
i. The Starfighter and Deflector Shield are visible on screen.ii. The Remaining Useful Life of the Defelector Shield is 5.iii. The score is 0.iv. No Asteroids appear on screen.v. There are no Plasma Bolts on screen.vi. Game time is set to 00:00.vii. The game is paused.
13. Game time and Game start: the game time is derived from one of the Teensy's onboard timers and is incremented at approximately 1 second intervals. The game time starts when the player unpauses from game start. When the player unpauses the game status information is sent to the computer along with a "game started" message.
14. Game pause: the game is paused by pressing Joystick Center or 'p'. When the game is paused the game time stops incrementing. To resume, Joystick Center or 'p' is pressed again.
i. If there are more Asteroids on the left side of the screen, only the Left LED flashes.ii. If there are more Asteroids on the right side of the screen, only the Right LED flashes.iii. The side the Asteroid is determined to be on is based on the middle of the Astroid.
i. The current status is sent to the computer along with a "game over" message.ii. The backlight fades off using PWM.iii. The words game over are displayed on screen and both LEDs turn on for a duration of 2 seconds.
iv. The backlight fades back on using PWM, the LEDs turn off, and options to quit or restart are given.
17. Restart game: if restart is chosen, the game returns to it's Game start state.
18. Quit game: if quit is chosen, the Teensy screen goes into inverse mode and displays student number only.
19. Speed of the game:The Right Potentiometer or 'm' is used to set the speed of the game. The speed ranges from 0 (no movement) to a suitable speed that is still playable.
20. Direct screen write:additional marks will be awarded for drawing and updating the Starfighter using direct screen write. If direct screen write is used, only the minimum screen area necessary should be updated via this method with the rest of the screen being updated normally via the cab202_teensy screen buffer.
i. 'l' - set the livesii. 'g' - set the scoreiii. '?' - print controls to computer screen (Putty)iv. 'h' - move spaceship to coordinate within the bottom 8 rowsv. 'j' - place large asteriod at coordinatevi. 'k' - place medium asteriod at coordinatevii. 'l' - place small asteroid at coordinate
Program structure, implementation quality
Test Requirements
What item of functionality (from the numbered list above) the test exercises.What the expected outcome from running the test should be.What the behaviour observed in your program is.An executable command which includes the explicit input sequence required to run the test, and which executes the test automatically when the shell script runs.
Marking
The assignment is worth 40% of your total grade in this subject, and it is marked out of 30. A detailed marking rubric will be published in Blackboard Grade Centre at least 14 days before the submission deadline. The approximate breakdown of marks will be:
Functionality: 25 marks.
Testing: 10 marks.
Program structure, implementation quality: 5 marks.
The following points should be noted about marking:
1. If your code does not compile when submitted to AMS, the mark awarded will be 0. Give yourself plenty of time to get the basics right. Submit Early. Submit Often.
3. If the program locks up or produces other untoward brick-like behaviour, marks will be awarded for the features that were observed prior to the point at which the game ceased to operate.
No effort will be made to work around the crash, nor will we debug your code to make it compile or run.
“It runs fine on my computer!” may be true, but it is largely irrelevant if the program crashes when executed on another machine. Such an excuse will not be accepted.
4. It is your responsibility to implement each feature sufficiently well that it is readily detected through normal operation of the game. Any feature that is not apparent through normal play will be deemed to be unimplemented.
5. We require tutors to adhere to a strict time limit of 3 minutes run time when marking each submission. Any feature that cannot be assessed in that time will be deemed to be unimplemented. Therefore you must avoid defects in game dynamics such as extremely fast motion, extremely slow motion, inconsistent control settings, premature program termination, or other properties that render the game unfit for use.
6. It is better to implement some of the features extremely well than to try to do everything and deliver a substandard product.
7. Penalties will be applied if the code exhibits general defects or undesirable behaviour not otherwise covered in this document. This includes but is not limited to such things as: