Assignment 8

Due Date : 11/18 @ 11:59pm

Instructions

Each of you should have a repository in GitHub with the name assignment8-githubHandle. Use this repository and add all your work there. In order to clone the repositories from GitHub to your machine (or watch this video video instructions):

  1. Sign in to GitHub.

  2. On your GitHub home page your Github Handle should appear on the left as a button/drop down menu. Click that button and from the drop down menu select cs2500f14. The GitHub page will then navigate to the class' web page and to the contents that is available to you.

  3. On the right you should be able to see all repositories to which you have been given access. Find the repository whose name matches the pattern assignment8-githubHandle, where githubHandle is your GitHub account name, e.g,assignment8-john123, and click on it.

  4. On the repositories home page look at the bottom right hand corner for a button with the text Clone in Desktop. By clicking on this button your browser will launch the GitHub client that we installed in class and ask for a location on your drive to store the repository.

    If you are not using the GitHub client the clone URL is located above the Clone in Desktop button. Copy the URL and issue the following command on your shell git clone URL.

  5. Create a file and save it under the folder on your drive that you selected in the preceding step.

Remember to push your changes to the GitHub repository often.

Missile Defence

We are going to develop a version of the game called "Missile Defence". Visually the game consists of

The game starts with a random number of missiles falling from the top of our scene in a straight line downwards the bottom at a steady speed. The missiles appear at random locations and at random times. At the bottom of the scene in the center location we starts our defender. We keep track of the defender's health. A defender starts the game with health equal to 5.

The game proceeds with missiles falling down from the top of the scene to the bottom of the scene at a steady speed and in a straight line. The defender moves constantly at a steady speed. The defender starts the game moving to the left. The defender can move from left to right or from right to left only. The user can change the defender's direction by

The defender can move all the way to the edge of the scene. Once the defender reaches the edge of the scene it stays at the edge of the scene unless it's direction is altered. For example if the defender is moving to the right and it reaches the right edge it should remain at the edge until its direction is changed to go left.

Also the user can press the space bar in order to fire a bullet. Bullets are created from the location of the defender at the time when the user pressed the space bar. Bullets travel from the bottom of the scene towards the top of the scene at a steady speed and in a straight line. Once a bullet hits a missile both the bullet and the missile are no longer visible. Here is a screen shot of the game

If a missile manages to reach the bottom of our scene then the defender loses 1 point of health. The game ends when the defender has 0 or less health points. The defender and the missile are not affected when they collide. When a missile hits the defender, nothing happens, the missile continues in its path and the defender continues in its path.

Recommendations

We are providing you with some recommendations for the game. You are free to alter or not use them at all, if you do be prepared to defend your decision and also to spend more time developing a solution


;;;; DATA DEFINITIONS 
;; A World is (make-world [Lof Posn] [Lof Posn] Defender)
;; interpretation: represents a world where 
;; bullets is the list of defender bullets in flight 
;; missiles is the list of missiles in flight
;; defender represents the defender   
(define-struct world (bullets missiles defender))  

;; A Defender is (make-defender Posn Direction Number)
;; interpretation: represents the defender with a location 
;; its direction and its current health
(define-struct defender (location direction health))

;; A Direction is one of 
;; - 'left
;; - 'right    


;;;; CONSTANTS 
(define WIDTH 600)
(define HEIGHT 600)
(define BACKGROUND (empty-scene WIDTH HEIGHT))

(define MISSILE-RADIUS 10)
(define MISSILE-DIAMETER (* 2 MISSILE-RADIUS))
(define MISSILE-SPEED 5)

(define BULLET-RADIUS 3)
(define BULLET-SPEED 5)

(define HEALTH-INIT 5)

(define DEFENDER-WIDTH 40)
(define DEFENDER-HEIGHT 10)
(define DEFENDER-SPEED 10)

(define DEFENDER-IMAGE 
  (rectangle DEFENDER-WIDTH DEFENDER-HEIGHT 'solid 'black))
(define DEFENDER-BULLET-IMAGE 
  (circle BULLET-RADIUS 'solid 'black))
(define MISSILE-IMAGE
  (circle MISSILE-RADIUS 'solid 'red))


;;;; Initial World 
(define DEFENDER-INIT 
  (make-defender (make-posn (floor (/ WIDTH 2))
                            (- HEIGHT DEFENDER-HEIGHT))
                 'left
                 HEALTH-INIT))

(define WORLD-INIT (make-world empty empty DEFENDER-INIT))

You might also want to use some of the following functions

Important features of the game

These are some of the features that we will be looking for in your games and you will be taken into consideration for grading