Basic Functionality (12 Marks) 1. Your program begins with an intro screen showing your name and student number. When SW2 is pressed, the game begins. 2. When joystick centre is pressed once, the game...

Programming for a microcontroller. See document for details


Basic Functionality (12 Marks) 1. Your program begins with an intro screen showing your name and student number. When SW2 is pressed, the game begins. 2. When joystick centre is pressed once, the game pauses (all sprites stop moving and are unable to move by using the normal controls), the game screen is cleared, and game information is displayed. The game is resumed when joystick centre is pressed again. The game information displayed is: a. Lives remaining b. Current score c. Game time in mm:ss format 3. The player initially appears on a 'starting block' in the top row. The player’s sprite is at least 3 pixels high and 3 pixels wide. 4. All blocks are: a. At least 2 pixels high, b. At least 10 pixels wide and are clearly distinguished from each other (through spacing between sprites or other visual design), c. Always at least player sprite height + 2 pixels vertically separated from other blocks. d. There are at least 7 safe blocks on the screen at one time. e. There are at least 2 forbidden blocks on the screen at one time. f. Safe and forbidden blocks are easily distinguished from each other. 5. Blocks have no consistent observable pattern and each block: a. Appears in a randomly selected row, b. Appears in a randomly selected column, c. Does not overlap other blocks. 6. Pressing the joystick LEFT or RIGHT has the following effect: a. Pressing the joystick left or joystick right moves the character one step left or right, respectively, b. If the player is not supported by a block, it will move vertically toward the bottom of the screen. For Basic Functionality, realistic physics such as acceleration and horizontal momentum, are not required. c. The joystick has no effect on the player's motion when the player is not supported by a block. d. If the falling player collides with a safe block from above, then the player lands on the block. The player will then immediately stop moving. e. Under no circumstances may the visible pixels of the player sprite overlap with the visible pixels of a block. 7. There is a treasure sprite that: a. Is no larger than the player's sprite and has a clearly distinct image. b. Does not overlap any of the blocks. c. Spawns in the bottom half of the screen and moves back and forward, changing horizontal direction when it reaches the edges of the screen. d. Stops moving when SW3 (right button) is pressed and starts moving again if SW3 (right button) is pressed again. e. Disappears when the player collides with it and gives the player 2 more lives and returns the player to the 'starting block'. f. Does not reappear again unless the game is restarted. 8. The following game mechanics are present: a. The player starts with 10 lives. b. A point is scored every time the player lands on a safe block. c. The player dies if any part of the player sprite moves off the screen in any direction or manner, or if it collides with a forbidden block. d. On death, the player respawns on the 'starting block'. e. When the player loses all their lives, the game over screen is displayed which displays a game over message, total score, and game play time. f. The game over screen allows the player to restart by pressing SW3 (right button) and score, lives, time, and player position all reset or end the game by pressing SW2 (left button) which clears everything and just displays student number on the screen. Advanced Functionality (10 Marks) 9. In addition to the functionality of points 4 and 5 above, the blocks move. a. All blocks move at a constant horizontal speed. b. Each row of blocks must move in the opposite direction to the row above it. 10. The functionality defined in point 6 above is redefined as follows: a. Pressing the joystick either LEFT or RIGHT while the player is supported by a block sets the player in continuous horizontal motion at a constant speed (relative to the block) in the appropriate direction. When in horizontal motion, the players horizontal velocity must be greater than that of the block, so that it is possible for the player to make progress against the direction of the block. b. If the player is moving horizontally on a supporting block, and the joystick is pressed in the opposite direction, then the player stops moving relative to the supporting block, and is carried by the block. c. If the player is moving horizontally on a supporting block, and the joystick is pressed in the same direction as current movement, then the player continues to move at the same speed in the current direction. d. If the player is moving horizontally on a supporting block, and the joystick is not pressed, then the player continues to move at the same speed in the current direction. e. If the player is not supported by a block, then it will commence to accelerate downwards. If the player is moving horizontally before leaving the support of a block, then the player must continue to move horizontally at the same speed while accelerating downwards, so that a parabolic flight path will be observed. f.  If the player is moving without support of a block (ie, flying, jumping, or falling) and the player lands on a safe block, it will then immediately begin to move horizontally in the same speed and direction as the block, and all vertical motion will cease. That is, the player will ride along the block, and player movement block. g. If the player is moving without support of a block, and its Sprite collides with the end of a safe block (from the side), then its horizontal motion becomes zero, and it continues to accelerate downward. h. All other collisions between the player and safe blocks are treated in a manner consistent with the combined motion. i. Any collison with an unsafe block results in death.  11. Pressing the joystick UP while the player is supported by a block causes the player to jump. a. After UP is pressed, the player should commence to move upwards. Any horizontal motion should continue, and the acceleration provision of 10(e) will take effect. b. Once UP is pressed, the joystick has no effect until the player lands on a block or dies. c. Immediately upon landing on a block, the player's velocity changes to match that of the block so it is carried along. d. If the player jumps off screen, the player dies. e. The initial vertical velocity should be sufficient to allow the player to jump through gaps between blocks and land on blocks on the row above. 12. Player has an inventory which stores Food. Food occurs such that: a. At the start of the game, the player has five (5) Food in their inventory. b. The Food sprite's area (i.e. sprite width * height) is no larger than the player sprites's area. c. When the player is supported by a block and joystick DOWN is pressed, Food appears. The Food must be supported by the block, and overlap the player sprite. The number of Food in the inventory decreases by one. d. The total Food count (inventory + screen) must always equal 5. e. Food dropped on a block is carried by the block. f. Food may overlap. 13. Five (5) Zombies appear from the top of the screen, and fall straight down without overlapping each other, after the program has been running for approximately 3 seconds. The Zombies behave as follows: a. Zombies stop falling when they land on any block. b. If a Zombie falls all the way to the bottom of the screen, it passes from view and does not reappear immediately. The player doesn't get any points for this. c. After landing on a block, Zombies prowl left and right along the blocks at fixed constant speed relative to the blocks. Zombies can cross over narrow gaps (just how narrow depends on the span of the Zombies' "feet"). Whenever a Zombie reaches a gap that it cannot cross, it reverses and moves in the opposite direction. d. Zombies may overlap each other if they are moving in opposite directions on the same span of blocks. e. If a Zombie is on a block that leaves the screen, the Zombie is carried off the screen; it continues to move along the blocks as if nothing untoward had occurred. f. When a Zombie collides with Food: i. the Zombie disappears, ii. the player gains 10 points, iii. the Food disappears, and iv. the Food inventory increases by 1. g. If a Zombie collides simultaneously with multiple Food, then the Zombie consumes one Food, leaving the others unaffected. h. Zombies do not disappear when the player collides with them, but instead the player loses a life and respawns. i. Three seconds after the last of the five Zombies disappears, either by feeding or falling out of view, the full complement of five Zombies respawn in the manner noted above. 14. In addition to the items listed under point 2, the pause screen shows: a. Number of Zombies on screen. b. Number of Food in inventory. Specialised Teensy Functionality (18 Marks) 17. ADC (your program uses one potentiometer) to control the movement of blocks, such at: a. All rows of blocks move at the same speed which is proportional to the potentiometer value. b. Block movement speed should range from 0 to a speed where the blocks are still clearly visible. 18. All switches that are used in the program are debounced efficiently, using the algorithm developed in AMS Topic 9, Question 3. 19. Both LED0 and LED1 flash at approximately 4Hz (synchronously or asynchronously) before the zombies spawn and continue to flash until all the zombies have landed or fallen off screen. 20. Direct control of the LCD using lcd_write (without using show screen or any equivalent function) is used to animate a death animation when the player dies the final time (i.e. when lives reach 0). 21. Multiple timers and interrupts are used to implement elapsed game time and zombie spawning and animation. 22. Program (flash) memory is used in an appropriate manner (other than the ASCII font already supplied in the library code) to store large data objects which would normally occupy static memory. 23. PWM is used to control the backlight when the player loses a life (but not the last time, when lives reach 0) and respawns and contrast
Sep 27, 2020
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here