import chess.*;//GEN-BEGIN:header
import java.awt.Color;
import java.awt.event.KeyEvent;

/**
 * Game1.java
 *
 * Created on Jun 15, 2007, 1:09:34 PM by G0706_ESHEPH
 */
public class Game1 {
    public void run() {//GEN-END:header
        
        
        boolean gameNotDone= true;
        int y;
        int x;
        
        int level=1;
        
        y=57;
        
        Screen myScreen;
        Sprite car;
        
        
        // initialization
        myScreen= Chess.newScreen(800, 600);
        x=8;
        car= myScreen.newSprite("/sprites/kool.png",x,y );
        myScreen.drawImage("/sprites/maz.png",0,0);
        
        Color targetColor;
        
        
        targetColor= Color.GRAY;
        
        Chess.report("The object of all the mazes in this game...");
        Chess.report("Is to find the end of the maze and go to it");
        Chess.report("To advance to the next level you must touch a gray pixel with the ball");
        Chess.report("Ready, Go!");
        // game loop
        while ( true ) {
            
            char key= myScreen.getKey();
            
            if ( key=='a' ) {
                
                if ( ! myScreen.getPixelColor( x - 10, y ).equals( Color.BLACK ) ) {
                    x= x-10;
                }
            } else if ( key =='d' ) {
                if ( ! myScreen.getPixelColor( x + 10, y ).equals( Color.BLACK ) ) {
                    x= x+10;
                }
            } else if ( key=='w' ) {
                if ( ! myScreen.getPixelColor( x, y - 10 ).equals( Color.BLACK ) ) {
                    
                    y= y-10;
                }
            }else if (key=='s') {
                if ( ! myScreen.getPixelColor( x, y + 10 ).equals( Color.BLACK ) ) {
                    
                    y= y+10;
                    
                }
            }
            
            if ( myScreen.getPixelColor( x, y).equals(Color.GRAY) ){
                
                level= level+ 1;
                
                if ( level==2 ) {
                    Chess.report("On To Level Two!");
                    
                    x=25;
                    y=20;
                    myScreen.drawImage("/sprites/maz2.png",0,0);
                    car.setPosition(x,y);
                    
                    
                } else if ( level==3 ) {
                    Chess.report("On To Level Three!");
                    Chess.report("This level requires you to find the end of the maze");
                    Chess.report("Good Luck!");
                    
                    myScreen.drawImage("/sprites/maz3.png",0,0);
                    x=10;
                    y=10;
                    car.setPosition(x,y);
                
                    
                 } else if (level==4 ) {
                    Chess.report("Now for level four!");
                    Chess.report("You need to touch the gray dot to be able to reach the finish");
                    x=461;
                    y=368;
                    myScreen.drawImage("/sprites/maz4.png",0,0);
                    car.setPosition(x,y);
                    targetColor= Color.BLUE;
                                                
                   
                } else if ( level==5 ) {
                    
                    Chess.report("You got the key!");
                    myScreen.drawImage("/sprites/maz5.png",0,0);
                    targetColor= Color.GRAY;
                }
            }
            
            
            
            gameNotDone = false;
            
            
            car.setPosition(x,y);
            
        } // while
        
        
        
    } //run//GEN-BEGIN:footer

    public static void main(String[] args) {
       new Game1().run();
    } //main
    
} //class//GEN-END:footer
