Today we will put Reality.java programs on your web page. This means everything needs to be in your ~/public_html folder, and since we are also upgrading to version 1_01 we might as well start from scratch. So make a ~/public_html/reality directory and download into it the contents of
/afs/acpub.duke.edu/project/web/egr54/src/1_01
Then make a ~/public_html/reality/std_graphics directory and download into it the contents of
/afs/acpub.duke.edu/project/web/egr54/lib/std_graphics
Compile and run the DemoBox program and run it, as follows:
javac DemoBox.java javac Reality.java java Reality DemoBoxThen follow the instructions in the Support menu under How to include applets to make yourself a web page that can launch DemoBox using netscape.
Add an velocity attenuation of 10% each time an entity hits the wall. In other words, multiply the magnitude of the entity's velocity by 0.9, leaving its direction unchanged. Do this by editing only the ReBox.java object.
Change ReBox.java and DemoBox.java so that two new options are available for the behavior of entities at the boundary of the box, besides ReBox::bounce():
(1) ReBox::wrap() which causes the entity to appear at the opposite edge of the box with the same velocity vector, and
(2) ReBox::stop() which causes the entity simply to stop at the boundary of the box. Edit DemoBox.java so that you can switch Bob's behavior at the boundary by typing the following characters:
'b' bounce
'w' wrap
's' stop
Make the entity's motion always occur along its orientation vector, so that when you change orientation, the direction of motion changes to match the entity's new oreintation.