CSE 113 - Spring 2011 - Banner
  • CSE 113 - Spring 2011
CSE 113 - Spring 2011 - Navigation

Lab 9
Last modified: April 08 2011 10:25:38 AM

CSE 113 - Spring 2011 - Lab 9

Fun with Images

We explored how to draw and create our own images in class, and now you will be able to do it on your own.

If you don't remember how to do any of the steps (like, copying, zipping, etc), please refer back to Lab 1.

First, you will need to copy over the scenario for this assignment. If you are working from home, you can download the scenario here. If you are in lab, the scenario is located in /eng/class/notes/cse113/Lab9.


Required Lab Tasks

Create a background

The background for the world at this point is pure white. You need to design a background for the world that is generated when world is created. Fill in the paintImage method in the ImageWorld class to create your background image. Create whatever image you'd like for the background, but make sure that at least one element of the background image is random. What is random is up to you, but you want to make something random to help you determine that the next step in the assignment is working.

In the image, you need to do more than simply fill the background with a color. There should be at least one shape (filled or outline) and at least two colors (one fill color and one color for shapes). However, you are free to have as many of these as you'd like.

Background Randomly Repaints

Fill in the act method of the ImageWorld so that at random times throughout the running of the scenario, the background repaints. The frequency of this is up to you, but the less often this happens, the less distracting it is to watch over long periods of time. However, when you first start, you may want to make it occur more frequently so that you can make sure it is working.

Growing Actor

Create an actor named Grower that when placed into the world, will start out at some size and grow to another size. When it reaches its maximum size, it should disappear. These sizes can be fixed or they can be random and set upon creation of the grower. The actor can be drawn (like a circle or square), or it can use an image file and scale it to be larger.

For now, manually add one or more to the world to test that they work correctly. They will actually be added to the world randomly in the finished program.

Shrinking Actor

Create an actor named Shrinker that when placed into the world, will start out at some size and shrink to another size. When it reaches its minimum size, it should disappear. These sizes can be fixed or they can be random and set upon creation of the shrinker. The actor can be drawn (like a circle or square), or it can use an image file and scale it to be smaller.

For now, manually add one or more to the world to test that they work correctly. They will actually be added to the world randomly in the finished program.

Growing and Shrinking Actor

Create an actor named GrowShrink that when placed into the world, will start out at some size and grow to another size. When it reaches its maximum size, it should begin to shrink to its minimum size. These sizes can be fixed or they can be random and set upon creation of the grower/shrinker. The actor can be drawn (like a circle or square), or it can use an image file and scale it to be smaller and larger. These actors will not leave the world.

Add Growing/Shrinking Actors to the World

Write code in the ImageWorld so that a random number of GrowShrink Actors appear in the world at random locations when the world is created.

Add Growing Actors to the World

Modify the GrowShrink actor so that it keeps track of how many times it has reached its maximum size. Every five times it reaches its maximum size, a random number of Grower actors (between 1 and 5) should appear in the world at random locations.

Add Shrinking Actors to the World

Modify the GrowShrink actor so that it keeps track of how many times it has reached its minimum size. Every ten times it reaches its minimum size, a random number of Shrinker actors (between 1 and 5) should appear in the world at random locations.

Fading Actor

Create an actor named Fader that when placed into the world, will start out fully visible and will eventually fade away (the transparency will become so high that you will be able to see right through it). Note the setTransparency method in the GreenfootImage class. Passing in the value 0 will make the image completely transparent (invisible) and passing in the value 255 will make the image completely opaque (the default). The image should start out with transparency 255 and when it reaches zero, it should disappear. The actor can be drawn (like a circle or square), or it can use an image file.

For now, manually add one or more to the world to test that they work correctly. They will actually be added to the world when the user clicks the mouse in the finished program.

Add Fading Actors to the World

Write the code in the act method of the world that will add a Fader actor to the spot where the user clicks with the mouse. That is, every time the user clicks on the world with the mouse, a Fader will appear in that spot and begin fading away.


Submitting the Assignment

Once you have completed your work, you will submit the zipped up version of the Lab 9 scenario.

For directions on submitting, please see here.

Please recall that you must achieve a grade of at least 50% on each of the labs to be allowed to take the third practical exam. This lab is technically due on Monday, May 2nd at 11:59:59pm. However, if you want to stay current with the course, I would recommend having this assignment completed within a week. You will need mastery of the skills you learn in this lab to be successful at practical exam 3.


Grading Information

Please make sure to look at your grading information on Web-CAT. See the grading information page for more details about how to interpret Web-CAT grade reports. (Currently, the grading is not enabled for this assignment.)

The following tests were run on your assignment submission. Each test was given equal weight (10 points each).

  1. When the scenario begins, the background has a generated design containing at least two colors and at least one shape.
  2. The background randomly changes during the course of the running of the scenario.
  3. When the scenario begins, there are a random number of GrowShrink actors in the world positioned randomly.
  4. The GrowShrink actor grows to a maximum size and then shrinks to a minimum size back and forth the entire time the actor is in the world.
  5. Every fifth time the GrowShrink actor reaches its maximum size, between 1 and 5 Grower actors appear in the world at random locations.
  6. Every tenth time the GrowShrink actor reaches its minimum size, between 1 and 5 Shrinker actors appear in the world at random locations.
  7. Grower actors grow in size every time act is called and when they reach their maximum size, they disappear from the world.
  8. Shrinker actors shrink in size every time act is called and when they reach their minimum size, they disappear from the world.
  9. Every time the user clicks the mouse in the world, a Fader actor appears in the place where the mouse clicked.
  10. The Fader actor starts out with opaque transparency and every time act is called, the transparency increases until it reaches it becomes invisible and then disappears from the world.

Lab authored by Adrienne Decker

CSE 113 - Spring 2011 - Footer

Page maintained by Adrienne Decker

Contact: adrienne@buffalo.edu | 130 Bell Hall | (716)645-3184