/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package game;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;
import java.io.IOException;

public class GameDesign {

    //<editor-fold defaultstate="collapsed" desc=" Generated Fields ">//GEN-BEGIN:|fields|0|
    private Image duke;
    private Sprite dukeWhite;
    public int dukeWhiteseq001Delay = 200;
    public int[] dukeWhiteseq001 = {0, 1, 2, 0};
    private Image james;
    private Sprite JamesG;
    public int JamesGseq001Delay = 200;
    public int[] JamesGseq001 = {0, 1, 2, 3};
    private Image brick;
    private TiledLayer bricks;
    private Image bord;
    private TiledLayer border;
    //</editor-fold>//GEN-END:|fields|0|

    //<editor-fold defaultstate="collapsed" desc=" Generated Methods ">//GEN-BEGIN:|methods|0|
    //</editor-fold>//GEN-END:|methods|0|

    public Image getDuke() throws java.io.IOException {//GEN-BEGIN:|1-getter|0|1-preInit
        if (duke == null) {//GEN-END:|1-getter|0|1-preInit
            // write pre-init user code here
            duke = Image.createImage("/images/duke.png");//GEN-BEGIN:|1-getter|1|1-postInit
        }//GEN-END:|1-getter|1|1-postInit
        // write post-init user code here
        return this.duke;//GEN-BEGIN:|1-getter|2|
    }
//GEN-END:|1-getter|2|

    public Sprite getDukeWhite() throws java.io.IOException {//GEN-BEGIN:|2-getter|0|2-preInit
        if (dukeWhite == null) {//GEN-END:|2-getter|0|2-preInit
            // write pre-init user code here
            dukeWhite = new Sprite(getDuke(), 25, 25);//GEN-BEGIN:|2-getter|1|2-postInit
            dukeWhite.setFrameSequence(dukeWhiteseq001);//GEN-END:|2-getter|1|2-postInit
            // write post-init user code here
        }//GEN-BEGIN:|2-getter|2|
        return dukeWhite;
    }
//GEN-END:|2-getter|2|

    public Image getJames() throws java.io.IOException {//GEN-BEGIN:|4-getter|0|4-preInit
        if (james == null) {//GEN-END:|4-getter|0|4-preInit
            // write pre-init user code here
            james = Image.createImage("/images/james.png");//GEN-BEGIN:|4-getter|1|4-postInit
        }//GEN-END:|4-getter|1|4-postInit
        // write post-init user code here
        return this.james;//GEN-BEGIN:|4-getter|2|
    }
//GEN-END:|4-getter|2|

    public Sprite getJamesG() throws java.io.IOException {//GEN-BEGIN:|5-getter|0|5-preInit
        if (JamesG == null) {//GEN-END:|5-getter|0|5-preInit
            // write pre-init user code here
            JamesG = new Sprite(getJames(), 25, 25);//GEN-BEGIN:|5-getter|1|5-postInit
            JamesG.setFrameSequence(JamesGseq001);//GEN-END:|5-getter|1|5-postInit
            // write post-init user code here
        }//GEN-BEGIN:|5-getter|2|
        return JamesG;
    }
//GEN-END:|5-getter|2|

    public Image getBrick() throws java.io.IOException {//GEN-BEGIN:|7-getter|0|7-preInit
        if (brick == null) {//GEN-END:|7-getter|0|7-preInit
            // write pre-init user code here
            brick = Image.createImage("/images/brick.png");//GEN-BEGIN:|7-getter|1|7-postInit
        }//GEN-END:|7-getter|1|7-postInit
        // write post-init user code here
        return this.brick;//GEN-BEGIN:|7-getter|2|
    }
//GEN-END:|7-getter|2|

    public TiledLayer getBricks() throws java.io.IOException {//GEN-BEGIN:|8-getter|0|8-preInit
        if (bricks == null) {//GEN-END:|8-getter|0|8-preInit
            // write pre-init user code here
            bricks = new TiledLayer(20, 20, getBrick(), 25, 25);//GEN-BEGIN:|8-getter|1|8-midInit
            int[][] tiles = {
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
            };//GEN-END:|8-getter|1|8-midInit
            // write mid-init user code here
            for (int row = 0; row < 20; row++) {//GEN-BEGIN:|8-getter|2|8-postInit
                for (int col = 0; col < 20; col++) {
                    bricks.setCell(col, row, tiles[row][col]);
                }
            }
        }//GEN-END:|8-getter|2|8-postInit
        // write post-init user code here
        return bricks;//GEN-BEGIN:|8-getter|3|
    }
//GEN-END:|8-getter|3|

    public Image getBord() throws java.io.IOException {//GEN-BEGIN:|9-getter|0|9-preInit
        if (bord == null) {//GEN-END:|9-getter|0|9-preInit
            // write pre-init user code here
            bord = Image.createImage("/images/bord.png");//GEN-BEGIN:|9-getter|1|9-postInit
        }//GEN-END:|9-getter|1|9-postInit
        // write post-init user code here
        return this.bord;//GEN-BEGIN:|9-getter|2|
    }
//GEN-END:|9-getter|2|

    public TiledLayer getBorder() throws java.io.IOException {//GEN-BEGIN:|10-getter|0|10-preInit
        if (border == null) {//GEN-END:|10-getter|0|10-preInit
            // write pre-init user code here
            border = new TiledLayer(20, 20, getBord(), 25, 25);//GEN-BEGIN:|10-getter|1|10-midInit
            int[][] tiles = {
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }
            };//GEN-END:|10-getter|1|10-midInit
            // write mid-init user code here
            for (int row = 0; row < 20; row++) {//GEN-BEGIN:|10-getter|2|10-postInit
                for (int col = 0; col < 20; col++) {
                    border.setCell(col, row, tiles[row][col]);
                }
            }
        }//GEN-END:|10-getter|2|10-postInit
        // write post-init user code here
        return border;//GEN-BEGIN:|10-getter|3|
    }
//GEN-END:|10-getter|3|

    public void updateLayerManagerForLevel1(LayerManager lm) throws java.io.IOException {//GEN-LINE:|11-updateLayerManager|0|11-preUpdate
        // write pre-update user code here
        getJamesG().setPosition(29, 445);//GEN-BEGIN:|11-updateLayerManager|1|11-postUpdate
        getJamesG().setVisible(true);
        lm.append(getJamesG());
        getDukeWhite().setPosition(29, 27);
        getDukeWhite().setVisible(true);
        lm.append(getDukeWhite());
        getBorder().setPosition(0, 0);
        getBorder().setVisible(true);
        lm.append(getBorder());
        getBricks().setPosition(0, 0);
        getBricks().setVisible(true);
        lm.append(getBricks());//GEN-END:|11-updateLayerManager|1|11-postUpdate
        // write post-update user code here
    }//GEN-BEGIN:|11-updateLayerManager|2|
//GEN-END:|11-updateLayerManager|2|

}
