Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

COMP 1010 -A01

Introduction to Computer Science 1

Summer 2022

Assignment 3: Text, IF conditionals, and loops

Q1:  Creating and moving a character

In this assignment, Q1 and Q2 will produce a character that will move through the scenes with the user interaction.

For Q1 write a program, which will draw a character from

the story “Alice in Wonderland” on the canvas that will

move if the user uses the arrow keys on the computer

keyboard. It is made up of four keys: the left arrow (back

arrow), up arrow, down arrow, and the right arrow (forward

arrow). The character should move in all directions

accordingly with the corresponding keys. You can choose

one of the characters from Alice in Wonderland such as

Alice, Caterpillar, Cheshire Cat, Jabberwock, Mad Hatter,

Queen of Hearts, White Rabbit, Dinah (Alice’s cat), or

anything else that you like from this story. You can find the

characters’ descriptions at this link:https://www.alice-in-

wonderland.net/resources/analysis/character-descriptions/.

You also need to draw a rabbit hole for the character, that will be used on the Q2. In the sample solution, my character is Alice. Be creative and create your own.    The rules are:

•   It must be a character from Alice in Wonderland fairy tale story.

•   The character must contain 4 to 15 shapes (lines, ellipses, rectangles, or other shapes).

•   It should contain several different colours.

•   The character must move in all directions. The user should only use the keyboard arrows to move the character.

•   The rabbit hole will disappear when the character falls through the hole and it will reappear if the user clicks the mouse on the canvas.

•   The rabbit hole should appear in a different location each time that your character falls in the hole.

•    Make sure that the sizes of your character change appropriately if the canvas size is changed.

Save a copy of your Question 1 program and name it as “A3Q1” following the instructions provided at the beginning of this document.

Q2:  Creating scenes

This question requires material from week 6 and week 7.

Make the following changes and additions to your Q1 program.

In this question, you will alter your program so that the scenery along the character changes each time your character falls into the rabbit hole - so that the next time the character appears on the canvas, the scenery is different, and the rabbit hole will be positioned in a different place. The rabbit hole and the moving character remain the same as in Q1. Choose 5 or more themes for your scenery they can be anything you like. For example, the sample program shows the five scenes. Each of the 5 scenes must have different colors, shapes, and at least one of the 5 scenes must have

some sort of animation.  Be creative!

The rules for creating scenes are:

•   First scenario: create a pattern with a theme associated with it. Use ONE shape of your choice or more to create the pattern.

•   Second scenario: create a pattern with a theme associated with it. Use at least TWO shapes of your choice or more to create the pattern.

•   Third scenario: create a pattern with a theme associated with it. Use at least THREE shapes of your choice or more to create the pattern.

•   Fourth scenario: create any pattern with some sort of animation.  Use one or more shapes of your choice to create the pattern and animation. The animation should be added to the pattern.

•   Fifth scenario: create your own scenario. Use one or more shapes or more to create the pattern. 

 

General rules:

•   Scenes in the scenarios must be one different from another in terms of shapes, colours, and animation.

•   A pattern must contain 1 to 10 shapes (lines, ellipses, rectangles, or other shapes).

•   It should contain several different colours.

•   At least one scene should display an animation.

•   Scenes should display full shapes in all canvas sizes.

•   A scene should alternate between the 5 scenes.

•   Resizing the elements of the scenario is not required for Q2, but it is a nice feature to add.

This assignment is about loops. You must use loops to draw your scenes. Each scene must implement at least one loop. You may have to implement two or more loops to draw your scenes. Use a loop  (while, for, do while) to create repetitions and animation.

Your program must present scenes displaying full shapes in all canvas sizes. It also means that your animations cannot draw objects or anything that are totally or partially obscured in the canvas.

The speed that your character moves is up to you. The object moves with the keys from the computer keyboard. In the sample, the character moves 2 pixels per second.

 

If you’ve written your program well, everything should work. Now change the size of the canvas to 700 by 700 pixels, or to any other size and it should work. Save a copy of your Question 2 program and name it as A3Q2” following the instructions provided at the beginning of this document.

Q3: Label Maker

Write a program that will allow you to type a message at

the bottom of the canvas, in a very awkward way. There

will be a ring of characters (letters, blanks, punctuation

marks, etc.) that rotates continuously. The top of the ring

should be marked somehow (in the example, there is a

small vertical line). Whenever the user clicks the mouse

on the canvas (anywhere), whichever character is closest

to the top of the ring should be added to the message at

the bottom of the canvas (in the example, it would be

‘F’). If the user pressed any key, the message will be

erased.

Here are the specifications which you must follow:

•   Use a  String constant  (right at the top of your

program)  to  control  the  characters  which  will

appear around the ring. You (or the marker) should

be able to change this String, and it should still work. Include letters, a blank, and some punctuation marks. You could add digits if you like.

•   There should be a rectangle of a contrasting colour at the bottom of the canvas, in which the message will appear, as shown. The ring of characters should be centred in the upper part of the canvas.

•   The characters should be drawn, one at a time, in a ring, as shown. The ring should rotate at a constant speed. It could rotate in either direction, but clockwise is probably easier to program.

•   Draw some sort of mark to indicate the top of the ring. It could be a simple line, or a hollow box, or a V shape, or whatever you like.

•   Write a mouseClicked() function. This is a special function that will automatically be called by Processing whenever the user  clicks the mouse  in the  canvas. Another  character (whichever one is closest to the top) should be added to the message at the bottom of the canvas whenever this happens. The message should be empty when the program starts.

•   The message should be erased in the text box if the user presses any key on the keyboard.

•   Use appropriate constants, state variables, and functions to write your code.

Save a copy of your Question 3 program and name it as “A3Q3” following the instructions provided at the beginning of this document.