// Path: core/src/main/java/net/panuska/tlappy/awt/Color.java
// public enum Color {
//     BLACK(0xff000000),
//     RED(0xffff0000),
//     BLUE(0xff0000ff),
//     YELLOW(0xffffff00),
//     WHITE(0xffffffff),
//     DARK_GRAY(0xff404040),
//     LIGHT_GRAY(0xffc0c0c0),
//     TRANSPARENT(0x00000000),
// 
//     black(0xff000000),
//     red(0xffff0000),
//     blue(0xff0000ff),
//     yellow(0xffffff00),
//     white(0xffffffff),
//     dark_gray(0xff404040);
// 
//     private final int color;
//     Color(int color) { this.color = color; }
//     public int getValue() { return color; }
// }
// 
// Path: core/src/main/java/net/panuska/tlappy/Constants.java
// public class Constants {
// 
//     static final int SCREEN_WIDTH = 320;
//     static final int SCREEN_HEIGHT = 200;
//     static final int NUM_SCENES = 200;
//     static final int LIVES = 5;
//     public static final int SPRITE_SIZE = 16;
//     public static final int SPRITE_HALF = 8;
//     public static final int FONT_WIDTH = SPRITE_HALF;
// 
//     static final int UP = 1;
//     static final int DOWN = 2;
//     static final int LEFT = 3;
//     static final int RIGHT = 4;
//     static final int FIRE = 5;
//     static final int ESC = 255;
//     
//     static final int INTRO = -1;
//     static final int GAME = -2;
//     static final int SETUP = -3;
// 
//     static final byte SPACE = 0;
//     static final byte MUSHROOM = 0x10;
//     static final byte CHICKEN = 0x20;
//     static final byte BLUE_ENEMY = 0x30;
//     static final byte RED_ENEMY = 0x40;
//     static final byte RED_BALL = 0x50;
//     static final byte BLUE_BALL = 0x60;
//     static final byte WALL = 0x70;
//     static final byte BLUE_WALL = 0x71; // ORIGINAL: (byte) 0x80;
//     
// }
// 
// Path: core/src/main/java/net/panuska/tlappy/Device.java
// public class Device {
//     private static final String TAG = Device.class.getSimpleName();
//     public static Keyboard keyboard;
//     public static VRAM vram;
//     public static Music music;
// 
//     public static int displayWidth;
//     public static int displayHeight;
// 
//     public static boolean initialized = false;
//     public static void init (SurfaceView view) {
//         if (initialized) {
//             Log.d(TAG, "Device already initialized");
//             return;
//         }
//         Log.d(TAG, "Init");
//         Images.load(view.getResources());
//         keyboard = Keyboard.getInstance();
//         vram = VRAM.getInstance();
//         vram.createWindow(view);
//         music = Music.getInstance(view.getContext());
//         WindowManager wm = (WindowManager) view.getContext().getSystemService(Context.WINDOW_SERVICE);
//         Display display = wm.getDefaultDisplay();
//         displayWidth = display.getWidth();
//         displayHeight = display.getHeight();
//         if (displayHeight > displayWidth) {
//             Log.d(TAG, "Swapping display width and height "+displayWidth+", "+displayHeight);
//             displayWidth = displayWidth + displayHeight;
//             displayHeight = displayWidth - displayHeight;
//             displayWidth = displayWidth - displayHeight;
//         }
//         initialized = true;
//     }
// 
//     public static void destroy() {
//         music.destroy();
//         initialized = false;
//     }
// }


import android.util.Log;
import android.view.SurfaceView;
import net.panuska.tlappy.awt.Color;
import static net.panuska.tlappy.Constants.*;
import static net.panuska.tlappy.Device.*;
                // todo shift the scenes also upon unsuccessful run
                Main.setState(NORMAL_WAIT);
                lives--;
                if (lives == 0) {
                    s.gameOver();
                    return;
                }
            } else {
                listener.gameFinished(scNo, score, lives, 0); //todo time should be also saved here
                previousScore += score;             // re-initialize score
                score = 0;
                if (scNo % 5 == 0) {
                    scNoRestart = scNo + 1;
                    password = s.printPassword(scNo / 5);
                }
                scNo++;
                if (scNo > 200) {
                    finalScr.finalCertificate();
                    scNoRestart = 1;
                    sel = INTRO;
                }
            }
        }
    }

    private int setup() {
        keyboard.clear();
        music.stop();
        vram.clear();
        Scene.drawSimpleBorder();
// Path: core/src/main/java/net/panuska/tlappy/awt/Color.java
// public enum Color {
//     BLACK(0xff000000),
//     RED(0xffff0000),
//     BLUE(0xff0000ff),
//     YELLOW(0xffffff00),
//     WHITE(0xffffffff),
//     DARK_GRAY(0xff404040),
//     LIGHT_GRAY(0xffc0c0c0),
//     TRANSPARENT(0x00000000),
// 
//     black(0xff000000),
//     red(0xffff0000),
//     blue(0xff0000ff),
//     yellow(0xffffff00),
//     white(0xffffffff),
//     dark_gray(0xff404040);
// 
//     private final int color;
//     Color(int color) { this.color = color; }
//     public int getValue() { return color; }
// }
// 
// Path: core/src/main/java/net/panuska/tlappy/Constants.java
// public class Constants {
// 
//     static final int SCREEN_WIDTH = 320;
//     static final int SCREEN_HEIGHT = 200;
//     static final int NUM_SCENES = 200;
//     static final int LIVES = 5;
//     public static final int SPRITE_SIZE = 16;
//     public static final int SPRITE_HALF = 8;
//     public static final int FONT_WIDTH = SPRITE_HALF;
// 
//     static final int UP = 1;
//     static final int DOWN = 2;
//     static final int LEFT = 3;
//     static final int RIGHT = 4;
//     static final int FIRE = 5;
//     static final int ESC = 255;
//     
//     static final int INTRO = -1;
//     static final int GAME = -2;
//     static final int SETUP = -3;
// 
//     static final byte SPACE = 0;
//     static final byte MUSHROOM = 0x10;
//     static final byte CHICKEN = 0x20;
//     static final byte BLUE_ENEMY = 0x30;
//     static final byte RED_ENEMY = 0x40;
//     static final byte RED_BALL = 0x50;
//     static final byte BLUE_BALL = 0x60;
//     static final byte WALL = 0x70;
//     static final byte BLUE_WALL = 0x71; // ORIGINAL: (byte) 0x80;
//     
// }
// 
// Path: core/src/main/java/net/panuska/tlappy/Device.java
// public class Device {
//     private static final String TAG = Device.class.getSimpleName();
//     public static Keyboard keyboard;
//     public static VRAM vram;
//     public static Music music;
// 
//     public static int displayWidth;
//     public static int displayHeight;
// 
//     public static boolean initialized = false;
//     public static void init (SurfaceView view) {
//         if (initialized) {
//             Log.d(TAG, "Device already initialized");
//             return;
//         }
//         Log.d(TAG, "Init");
//         Images.load(view.getResources());
//         keyboard = Keyboard.getInstance();
//         vram = VRAM.getInstance();
//         vram.createWindow(view);
//         music = Music.getInstance(view.getContext());
//         WindowManager wm = (WindowManager) view.getContext().getSystemService(Context.WINDOW_SERVICE);
//         Display display = wm.getDefaultDisplay();
//         displayWidth = display.getWidth();
//         displayHeight = display.getHeight();
//         if (displayHeight > displayWidth) {
//             Log.d(TAG, "Swapping display width and height "+displayWidth+", "+displayHeight);
//             displayWidth = displayWidth + displayHeight;
//             displayHeight = displayWidth - displayHeight;
//             displayWidth = displayWidth - displayHeight;
//         }
//         initialized = true;
//     }
// 
//     public static void destroy() {
//         music.destroy();
//         initialized = false;
//     }
// }


// Path: core/src/main/java/net/panuska/tlappy/Main.java
import android.util.Log;
import android.view.SurfaceView;
import net.panuska.tlappy.awt.Color;
import static net.panuska.tlappy.Constants.*;
import static net.panuska.tlappy.Device.*;

                // todo shift the scenes also upon unsuccessful run
                Main.setState(NORMAL_WAIT);
                lives--;
                if (lives == 0) {
                    s.gameOver();
                    return;
                }
            } else {
                listener.gameFinished(scNo, score, lives, 0); //todo time should be also saved here
                previousScore += score;             // re-initialize score
                score = 0;
                if (scNo % 5 == 0) {
                    scNoRestart = scNo + 1;
                    password = s.printPassword(scNo / 5);
                }
                scNo++;
                if (scNo > 200) {
                    finalScr.finalCertificate();
                    scNoRestart = 1;
                    sel = INTRO;
                }
            }
        }
    }

    private int setup() {
        keyboard.clear();
        music.stop();
        vram.clear();
        Scene.drawSimpleBorder();
        vram.printText(16, 5, "M E N U", Color.BLUE);