|
CSE 490RA Exercise 3
|
|
Elevator simulation
This assignment has two parts - the first is to write an elevator simulator, and the second is to do something cool with ink. So far, I have only implemented the first part.
Part 1
Write an elevator simulator that moves a car up and down in response to buttons. The main purpose of this exercise is to pick up some experience with
basic window form graphics. Here is my effort. It is primitive - but the car
does move up and down.
Hints
Here are the steps I went through. You will get the
most out of this assignment if you only refer to these as necessary.
- Create control panel and main panel with a splitter
- Put an inkCollector in main panel and set references
- Add buttons
- Begin drawing the elevator - create a DrawElevator method
which is called by the main panels OnPaint method. The graphics context
is extracted from the eventargs in the OnPaint handler.
- Note that the Pen constructor takes a float, so 10.0 had to be written
10.0f.
- To clean the screen after resizing the form, add an OnResize method for
the resize even - the method just needs to make an invalidate call.
- Draw the car in a stationary position.
- We will have fixed floor positions which evenly divide the panel. Set
a minimum form size, so we don't need to shrink the car.
- Add the buttons to send the car instantaneously to the pressed floor. You
may need to put in invalidate calls to get a repaint when the button
is pushed
- Now animate the elevator moving. I did this with a loop with a call to
Thread.Sleep(100) [using System.Threading]. Following the invalidate
call by an update call forced the repaints to occur immediately.
Part 2
Now the part I haven't got to, is to do something cool with ink. What I am wanting to do is to have any ink drawn in the elevator car move up and down with the elevator. I haven't tried to do this yet - so I don't know how hard
it will be.
|
|
Department of Computer Science & Engineering
University of Washington
Box 352350
Seattle, WA 98195-2350
(206) 543-1695 voice, (206) 543-2969 FAX
[comments to anderson]
|