import chess.*;//GEN-BEGIN:header
import java.awt.*;
import java.awt.event.KeyEvent;

/**
 * PenguinChase.java
 *
 * Created on Jun 20, 2007, 2:14:15 PM by G0706_IYE
 */
public class PenguinChase {
    public void run() {//GEN-END:header
        boolean PenguinChase= true;
        int joex=10;
        int joey=14;
        int timx=488;
        int timy=302;
        
        Screen myscreen= Chess.newScreen(1000,900);
        myscreen.clear(Color.blue.brighter());
        Sprite tim= myscreen.newSprite("/peng-movie.4.gif");
        Sprite joe= myscreen.newSprite("/seal.jpg.png");
        
        int lives= 2;
        
        do {
            if ( myscreen.keyDown(KeyEvent.VK_RIGHT )) {
                timx= timx+20;
            }
            if (myscreen.keyDown(KeyEvent.VK_LEFT )) {
                timx= timx-20;
            }
            if ( myscreen.keyDown(KeyEvent.VK_DOWN ) ) {
                timy= timy+20;
            }
            if ( myscreen.keyDown(KeyEvent.VK_UP)){
                timy= timy -20;
            }
            
            
            if ( timx < joex ) {
                joex= joex - 18;
            }
            if ( timx> joex ) {
                joex= joex + 18;
            }
            if ( timy < joey ) {
                joey= joey - 18;
            }
            if ( timy> joey ) {
                joey= joey + 18;
            }
            
            
            if ( Math.abs( timx-joex ) < 18 ) {
                if ( Math.abs( timy-joey ) < 18 ) {
                    Chess.report( "He got you!" );
                    lives= lives -1;
                    timx= 400;
                    timy= 300;
                    joex= 10;
                    joey= 14;
                    myscreen.clearKeys();
                    if (lives < 1){ System.exit(0);   }
                }   
            }
            
            tim.setPosition(timx,timy);
            joe.setPosition(joex,joey);
            
            
            
            Chess.waitForNextFrame(30);
            
            
        } while ( PenguinChase );
        
        
    } //run//GEN-BEGIN:footer

    public static void main(String[] args) {
       new PenguinChase().run();
    } //main
    
} //class//GEN-END:footer
