2016-10-19

posted Oct 19, 2016, 6:23 AM by Samuel Konstantinovich   [ updated Oct 19, 2016, 11:26 AM ]
Goal: Inheritance!

Updated version of the invaders.zip is here!
This includes Javadocs!

Homework:
Try to get the invaders to:
1. cross the screen to the right (they already do this),
2. turn down for a distance of 100,
3. then travel backwards across the screen,
4. then turn down for a distance of 100
5. Then go back to 1...
If they hit the bottom of the screen delete them.
Modifying the enemy code here:
public void keepInBounds() {
    //request that the game deletes the object when 
    //the object it passes out of the screen to the right
    if (getX() > width - getWidth()/2 ){
setX( width - getWidth()/2 - 1 );
moveDown();
    }
}
    
REPLACE THE RED CODE WITH:

    if (getY() > 200){
if (getX() > width - getWidth()/2 ){
   setX(width - getWidth()/2 -1);
   moveDown();
}
    }
    else
    {
if (getX() > width - getWidth()/2 ){
   setX(width - getWidth()/2 -1);
   moveUp();
        }
    }
ċ
invaders.zip
(1690k)
Samuel Konstantinovich,
Oct 19, 2016, 11:01 AM
Comments