import chess.*;//GEN-BEGIN:header
import java.awt.Color;

/**
 * Wasd.java
 *
 * Created on Jun 15, 2007, 1:20:16 PM by G0706_SVOLLM
 */
public class Wasd {
    public void run() {//GEN-END:header
        
        
        // Here you go!
        
        
        boolean gameNotDone= true;
        int x;
        int y;
        
        y=10;
        
        Screen myScreen;
        Sprite car;
        
        
        
        myScreen= Chess.newScreen(807,588);
        
        x=10;
        int oldx, oldy;
        
        myScreen.drawImage("/sprites/back.GIF",0,0);
        car= myScreen.newSprite("/sprites/mrdot.png",x,y);
        // game loop
        while ( gameNotDone ) {
            char key= myScreen.getKey();  // 1=left, 3=right, 5=up, 2=down
            
            oldx= x;
            oldy= y;
            
            if ( key=='4' ) {
                x= x-5;
            } else if ( key=='6' ) {
                x= x+5;
            } else if ( key=='9' ) {
                y= y-5;
            } else if ( key=='2' ) {
                y= y+5;
            }
            
            Color c= myScreen.getPixelColor( x, y );
            if ( c.equals( Color.black ) ) {
                x= oldx;
                y= oldy;
            }
            
            car.setPosition(x,y);
            
            
            Chess.waitForNextFrame(30);
        }
        
    } //run//GEN-BEGIN:footer

    public static void main(String[] args) {
       new Wasd().run();
    } //main
    
} //class//GEN-END:footer
