程序代写代做代考 ASSIGNMENT 2: Adventure Game and Drawing Application DEPARTMENT AND COURSE NUMBER: COMP 1010 COURSE TITLE: Introduction to Computer Science 1

ASSIGNMENT 2: Adventure Game and Drawing Application DEPARTMENT AND COURSE NUMBER: COMP 1010 COURSE TITLE: Introduction to Computer Science 1
TERM: Fall 2016
Assignment 2: Design an Adventure Game and a Simple Drawing Application
DUE DATE: OCTOBER 28, 2016 AT 11:59PM.
In this assignment you will design a basic adventure game and a drawing application. The description is broken into two parts: a preparation section that you can complete before programming, and the programming questions.
Preparation:
Q1: Decide on the story for your game. Design a world. (Some other type of location such as a room is fine.) In this world, there must be a goal object of some kind, such as a treasure to obtain, a bomb to deactivate, a person to rescue, or something similar. There must be a hero which can move around. There must be a barrier, such as a gate, a force field, or a locked door, that prevents the hero from reaching the goal. The hero will be moved using keys on the keyboard, but must not be able to get through the barrier, or leave the canvas. Make up your own story, and decide how the goal, hero, and barrier will be drawn. Be creative, but keep it simple. The hero could just be a circle, for example. There should be a key object which would allow the hero to get past the barrier somehow. The hero should be able to get to the key. The hero should be able to pick up the key by simply moving over it. If the hero is holding the key object, the barrier should be open or disabled. When the hero reaches the goal object (that is, the treasure, a bomb, person to rescue, etc.) carrying the key, the game will be over. The hero should have a limited amount of time to accomplish the goal. The remaining time should be displayed on the screen. If the time expires the hero should freeze in place and the game is lost.
Q2: Pick a minimum of three features that are commonly seen in a paint application (e.g., color, background, shape, stroke weight). Now display at least four options on the screen for each of these features (e.g., for color: red, green, blue, yellow; for stroke weight: 1, 2, 3, 4). Now, allow users to select options from the palette and allow them to draw with the corresponding options.
Notes:
 Name your sketches using your name, the assignment number, and the question number, exactly as in this example: SmithKateA2Q1.
 Your program must run upon download to receive any marks.
 Submit a PDE file for each question using UMLearn’s file submission tool (named dropbox), as demonstrated
in class.
 Assignments must follow the programming standards document published on UMLearn.
 After the due date and time, assignments may be submitted but will lose 2% of the marks per hour late.
 If you submit a question multiple times, only the most recent version will be marked.
 These assignments are your chance to learn the material for the exams. Code your assignments
independently. We use software to compare all submitted assignments to each other, and purse academic dishonestly vigorously.
1

ASSIGNMENT 2: Design an Adventure Game DEPARTMENT AND COURSE NUMBER: COMP 1010
Q1: Adventure game
Phase 1:
  





 
Implement the basic world for an adventure game, according to these criteria:
Use a canvas size of 800 by 600.
Specify a background colour.
As with Assignment 1, screenshots are given to
demonstrate the required elements of the
questions, but your program must be different than
the game shown in Figures 1 and 2.
Write a drawAndControlHero() function to place a
hero in the middle of the canvas. The hero can
consist of 1 to 5 shapes.
Note: in the example shown the hero is a single
ellipse. You may use a single ellipse in your own
game, or you may create a more detailed hero.
Add the necessary code to inside the function to
move the hero using the W, A, S, and D keys to move
the hero up, left, down, and right, respectively. You
will have to use the built-in variables key and
keyPressed. To get you started, here is a code snippet that should help:
if(keyPressed){
if(key == ‘w’)
heroY -= speed; //Move the hero UP
…etc…
Create a barrier somewhere in the world. Your hero should not be able to move through the barrier. In the example shown, the hero cannot move to the left of the arc (representing a force field). No part of the hero should be able to go past the barrier, or intersect with it. Keep the shapes simple to avoid complicated calculations.
 You should design a barrier that does NOT look exactly like the one shown in the figure. You might use lines or rectangles; you might run the gate along the top, bottom or diagonal of the screen; you might use a corner of the screen, or a circular area.
 Use a drawBarrier() function to draw the barrier.
Draw a goal object that the hero cannot reach because of the barrier.
 You can use from 1 to 5 shapes or lines to draw the goal object. (The bomb shown uses an ellipse, a rectangle, and an arc.)
 Use a drawGoal() function to draw the goal object.
Ensure the hero always stays in the canvas. No part of the hero should be able to move beyond the barrier. You may choose to limit the movement of the hero in additional ways, but this is not required. (For example, you could add obstacles or walls.)
Create a new function, drawKey(), to place a key object in the canvas, not too close to the goal or the hero. In the example shown the object is a single triangle. Use 1 to 5 shapes for this object.
The draw() function should contain calls to background, drawAndControlHero(),drawBarrier(), drawGoal(), and drawKey() functions.
Figure 1: A World showing a hero, a barrier, a goal object and a key object.
2

ASSIGNMENT 2: Design an Adventure Game DEPARTMENT AND COURSE NUMBER: COMP 1010
Phase 2: Finish your game by allowing the hero to pick up the key, carry it, and access the goal object to win the game. Here are the details and criteria:
 The hero has a limited time (for example, 15 seconds which is equivalent to 900 frames) to achieve the goal. You can adjust this amount to be suitable for your game. This time value should be initialized in the setup() function. Decrease the time value in each frame inside the draw()
function and display the remaining time in seconds at the top of the screen. When the timer expires, set a boolean variable to indicate that the game is over.
 See the instructions at the bottom of this assignment for drawing text in the canvas.
 When the game is over, the hero should no longer be able to move. A suitable message should be displayed. (In the sample game, perhaps “Boom!!” would be used.)
 Display some text in the canvas, giving the person playing the game a hint how to control the hero such as “Use the WASD keys to explore.”, or some other relevant message.
 When the hero moves over the key object, the object should automatically be picked up, and should move with the hero, as though the hero is carrying the object.
 Use a boolean variable to keep track of whether or not the hero has picked up the key.
 If the hero has the key, you may either draw the hero and the key at the same location, moving together, or
change the appearance of the hero in some way that makes it clear that the key is now being carried. The key
by itself should no longer appear in its original location.
 When the hero picks up the key, the text on the screen should change to instruct the hero to try to return with
it to the goal object as shown in the Figure 2. The barrier should now be gone or open. (The hero doesn’t have
to do anything with the key to remove the barrier – it will simply be gone or deactivated.)
 When the hero moves over the goal object within the given time, display a suitable message such as “You
win!”, or “We’re saved!”, and stop the game.
Figure 2: Since the hero has the key object, the barrier is gone. The text message now says “The force field is down! Destroy the bomb!”.
3

ASSIGNMENT 2: Adventure Game and Drawing Application DEPARTMENT AND COURSE NUMBER: COMP 1010 COURSE TITLE: Introduction to Computer Science 1
TERM: Fall 2016
Q2: Let’s Make a Paint Application
Implement a simple drawing application with the following criteria.
 Use a canvas size of 800 by 600.
 Pick at least three simple features from a
drawing application (e.g., color, background, shape, stroke weight). Add the features’ names in the canvas with text command.
 Now pick at least four options for each of these features (e.g., for color: red, green, blue, yellow; for stroke weight: 1, 2, 3, 4) and represent them in the canvas (e.g., In Figure 3, stroke colors are shown in rectangles, thickness are shown with lines).
 Add a large sub-canvas (i.e., rectangle) inside the main canvas. Restrict the drawing to this sub- canvas.
 Add functionalities for the feature options in
such a way that if user clicks on an option, s/he
can draw lines or shapes in the sub-canvas with
the selected options (e.g., if a user clicks on a red
stroke color, s/he will be able draw lines or shapes with red ink).
 This seems complex, but the amount of code will not be too large, and if you implement it using many small functions, one at a time, it will be much easier. Here’s a suggested approach (you can do it differently if you prefer):
 Use a drawPalette() function to draw the palette of options. You may want to further divide this into three smaller functions, one for each option.
 Use a checkPaletteClick() function to act appropriately if the user clicks in the palette. Again, you might want to use three smaller functions, one for each of the three options.
 Just as you write the usual setup() and draw() functions, you can write a mouseClicked() function, which contains code that you want to run when a mouse click is detected.
 Use a drawInCanvas() function when the mouse is in the drawing area. Drawing text in the canvas
It is easy to draw text in the canvas, using the following commands:
 text(“some text”,x,y) will draw the given text with its lower left corner at (x,y)
 textSize(n) will make the text n pixels tall
 fill(colour) will draw the text using that colour.
Figure 3: A sample canvas showing stroke color, background color and thickness features and their options. A user can select options and draw inside the right sub- canvas accordingly.
4

ASSIGNMENT 2: Design an Adventure Game DEPARTMENT AND COURSE NUMBER: COMP 1010
Assignment 2 Grading Guide
Q1: Adventure Game (10)
 The canvas shows a world with goal, barrier, key, and hero (1)
 Hero moves using WASD keys (1)
 Hero stays on canvas, but cannot get through the barrier (1)
 Hero can pick up the key and carries it (1)
 Text changes when hero picks up the key (1)
 Barrier is deactivated when hero picks up the key (1)
 Game is won if the hero reaches the goal with the key (1)
 Hero gets limited time to navigate between the partitioned spaces (1)
 Programming standards are followed (2)
Q3: Paint Application (10)
 At least three features with at least four options each (1)
 Drawing happens in the sub-canvas only (1)
 2 marks for each of the three features (6 total)
o Does the option work, and control the size/shape/colour/etc. in the drawing?  Sketch uses comments and standards as specified in the programming guidelines (2)
Grade: /20
5