CS 117 Assignment: Automatically adjustable images


Many aspects of backgrounds and landscapes that you see in today's movies are computer enhanced. Perhaps the weather was wrong on the day the film was shot, or maybe the director had a change of mind involving the mood. For this assignment, you will create an image that can be changed and adjusted by the user.

Part 1: Draw a landscape and cloud

Create a directory named landscape1 to store your work, then copy into it the Canvas class that we used in the previous lab. Write Java code to make a canvas of size 500 pixels wide and 500 pixels high, then draw a simple landscape. Your landscape doesn't have to be particularly fancy, especially if your artistic skills are as bad as mine. Set the background to blue to represent a sky, then draw a couple of rough hills or buildings using ovals or rectangles.

Draw a small white cloud at the top left corner off your canvas. Your cloud can be as simple as a cloud-sized oval, but feel free to use multiple overlapping ovals or other techniques to make your cloud as attractive as you like.

Part 2: Make the position of your cloud adjustable

The goal of this part of the assignment is to place the cloud in different places in the sky, depending on where the user of your program wants it. Specifically, your program should ask your user for a wind speed (in miles per hour), and the number of hours that have passed since the cloud first appeared in the top left of the window. Your program should then draw the cloud in its correct location. Assume that the image is 20 miles across, and that the wind is blowing directly to the right. Here is a sample of what the interaction between your program and your user should look like. The user's responses are in red.


Automatic Landscape Builder

What is the windspeed in miles per hour? 3.5
How many hours have passed? 2.5

Here is your picture!

You will need to do some arithmetic to determine precisely where the cloud should go:

Finally, here are some things you can do to test your code:

When finished, use hsp to submit your landscape1 directory. Indicate in program comments the names of both authors (you and your partner), as well as roughly what fraction of the time each team member spent "driving" at the keyboard. You should be working to give all team members approximately the same amount of time driving.

Good luck, and have fun! Remember that lab assistants are available in the evenings in CMC 306 to help out if you need it.