⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mapmaker.java

📁 很不错的泡泡堂手机游戏
💻 JAVA
字号:
package com.cpiz.poptang;

import java.io.IOException;
import java.util.Random;

/*
 * 创建日期 2007-3-19 @author caipiz
 */

public class MapMaker
{
    public static void main(String[] args)
    {
        Stage stage = null;
        
        stage = getStage3();
        
        try
        {
            stage.save(3);
            System.out.println("Save Done");
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        
//        readTest(1);
    }
    
    public static Stage getStage3()
    {
        Stage stage = new Stage();
        
        byte[][][] tiles = 
        {
            { 
                { 6, 6, 6, 6, 6, 6, 6, 6 }, 
                { 6, 6, 6, 6, 6, 6, 6, 6 },
                { 6, 6, 6, 6, 6, 6, 6, 6 },
                { 6, 6, 6, 6, 6, 6, 6, 6 },
                { 6, 6, 6, 6, 6, 6, 6, 6 },
                { 6, 6, 6, 6, 6, 6, 6, 6 },
                { 6, 6, 6, 6, 6, 6, 6, 6 }
            },

            {
                { 11,  0,  0,  0,  0,  0,  0, 11 },
                { 21, 11,  0,  2,  4,  0, 11, 21 },
                { 11, 21, 11,  5,  7, 11, 21, 11 },
                { 21, 11, 26, 16, 16, 26, 11, 21 },
                { 11,  2,  4, 26, 26,  2,  4, 11 },
                { 21,  5,  7,  0,  0,  5,  7, 21 },
                { 11, 21,  11, 0,  0, 11, 21, 11 }
            },

            { 
                { 2, 1, 1, 1, 1, 1, 1, 2 }, 
                { 2, 2, 1, 0, 0, 1, 2, 2 },
                { 2, 2, 2, 0, 0, 2, 2, 2 },
                { 2, 2, 2, 2, 2, 2, 2, 2 },
                { 2, 0, 0, 2, 2, 0, 0, 2 },
                { 2, 0, 0, 1, 1, 0, 0, 2 },
                { 2, 2, 2, 1, 1, 2, 2, 2 }
            } ,   
        };
        
        stage.imgIndex = 2;
        stage.midIndex = 2;
        stage.mapData = tiles;
        
        stage.heroPosition[0] = 6;
        stage.heroPosition[1] = 3;
        
        stage.enemyPosition[0] = 0;
        stage.enemyPosition[1] = 1;
        stage.enemyPosition[2] = 0;
        stage.enemyPosition[3] = 6;
        stage.enemyPosition[4] = -1;
        stage.enemyPosition[5] = -1;
        stage.enemyPosition[6] = -1;
        stage.enemyPosition[7] = -1;
        stage.enemyPosition[8] = -1;
        stage.enemyPosition[9] = -1;
        
        return stage;
    }
    
    public static Stage getStage2()
    {
        Stage stage = new Stage();
        
        byte[][][] tiles = 
        {
            { 
                { 1, 2, 1, 2, 1, 2, 1, 2 }, 
                { 2, 1, 2, 1, 2, 1, 2, 1 },
                { 1, 2, 1, 2, 1, 2, 1, 2 }, 
                { 2, 1, 2, 1, 2, 1, 2, 1 },
                { 1, 2, 1, 2, 1, 2, 1, 2 }, 
                { 2, 1, 2, 1, 2, 1, 2, 1 },
                { 1, 2, 1, 2, 1, 2, 1, 2 } 
            },

            { 
                { 11, 0, 11, 0, 11, 0, 11, 0 }, 
                { 0, 0, 0, 0, 0, 0, 0, 0 },
                { 11, 0, 11, 0, 11, 0, 11, 0 }, 
                { 0, 0, 0, 0, 0, 0, 0, 0 },
                { 11, 0, 11, 0, 11, 0, 11, 0 }, 
                { 0, 0, 0, 0, 0, 0, 0, 0 },
                { 11, 0, 11, 0, 11, 0, 11, 0 } 
            },

            { 
                { 6, 1, 6, 1, 6, 1, 6, 1 }, 
                { 1, 1, 1, 1, 1, 1, 1, 1 },
                { 6, 1, 6, 1, 6, 1, 6, 1 }, 
                { 1, 1, 1, 1, 1, 1, 1, 1 },
                { 6, 1, 6, 1, 6, 1, 6, 1 }, 
                { 1, 1, 1, 1, 1, 1, 1, 1 },
                { 6, 1, 6, 1, 6, 1, 6, 1 } 
            } 
        };
        
        stage.imgIndex = 1;
        stage.midIndex = 2;
        stage.mapData = tiles;
        
        stage.heroPosition[0] = 6;
        stage.heroPosition[1] = 7;
        
        stage.enemyPosition[0] = 1;
        stage.enemyPosition[1] = 1;
        stage.enemyPosition[2] = 3;
        stage.enemyPosition[3] = 3;
        stage.enemyPosition[4] = 5;
        stage.enemyPosition[5] = 5;
        stage.enemyPosition[6] = -1;
        stage.enemyPosition[7] = -1;
        stage.enemyPosition[8] = -1;
        stage.enemyPosition[9] = -1;
        
        return stage;
    }
    
    public static Stage getStage1()
    {
        Stage stage = new Stage();
        
        byte[][][] tiles = 
        {
            { 
                { 1, 1, 1, 4, 4, 1, 1, 1 }, 
                { 1, 1, 1, 2, 2, 1, 1, 1 },
                { 1, 1, 1, 2, 2, 1, 1, 1 },
                { 1, 1, 1, 2, 2, 1, 1, 1 },
                { 1, 1, 1, 2, 2, 1, 1, 1 },
                { 1, 1, 1, 2, 2, 1, 1, 1 },
                { 1, 1, 1, 4, 4, 1, 1, 1 }
            },
        
            {
                { 0, 0, 6, 11, 0, 6, 16, 21 },
                { 0, 21, 5, 0, 11, 5, 7, 11 },
                { 6, 16, 6, 11, 0, 0, 21, 16 },
                { 5, 6, 5, 0, 11, 5, 6, 5 },
                { 16, 21, 0, 11, 0, 6, 21, 6 },
                { 11, 8, 5, 0, 11, 5, 16, 0 },
                { 21, 16, 6, 11, 0, 6, 0, 0 }
            },
        
            { 
                { 1, 1, 0, 6, 1, 0, 2, 2 }, 
                { 1, 2, 3, 1, 6, 3, 0, 6 },
                { 0, 2, 0, 6, 1, 1, 2, 2 },
                { 3, 0, 3, 1, 6, 3, 0, 3 },
                { 2, 2, 1, 6, 1, 0, 2, 0 },
                { 6, 0, 3, 1, 6, 3, 2, 1 },
                { 2, 2, 0, 6, 1, 0, 1, 1 }                         
            } ,   
        };
        
        stage.imgIndex = 1;
        stage.midIndex = 1;
        stage.mapData = tiles;
        
        stage.heroPosition[0] = 6;
        stage.heroPosition[1] = 7;
        
        stage.enemyPosition[0] = 0;
        stage.enemyPosition[1] = 0;
        stage.enemyPosition[2] = -1;
        stage.enemyPosition[3] = -1;
        stage.enemyPosition[4] = -1;
        stage.enemyPosition[5] = -1;
        stage.enemyPosition[6] = -1;
        stage.enemyPosition[7] = -1;
        stage.enemyPosition[8] = -1;
        stage.enemyPosition[9] = -1;
        
        return stage;
    }
    
    public static void readTest(int stage)
    {
        Stage stageData = null;
        try
        {
            stageData = Stage.loadStage(stage);
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
        
        System.out.println(stageData.imgIndex);
        for(int i = 0; i < 3; i++)
        {
            for(int j = 0; j < 7; j++)
            {
                for(int k = 0; k < 8; k++)
                {
                    System.out.print(stageData.mapData[i][j][k] + ", ");
                }
                System.out.println();
            }
            System.out.println();
        }
        
        System.out.println(stageData.heroPosition[0]);
        System.out.println(stageData.heroPosition[1]);
        System.out.println();
        System.out.println(stageData.enemyPosition[0]);
        System.out.println(stageData.enemyPosition[1]);
        System.out.println(stageData.enemyPosition[2]);
        System.out.println(stageData.enemyPosition[3]);
        System.out.println(stageData.enemyPosition[4]);
        System.out.println(stageData.enemyPosition[5]);
        System.out.println(stageData.enemyPosition[6]);
        System.out.println(stageData.enemyPosition[7]);
        System.out.println(stageData.enemyPosition[8]);
        System.out.println(stageData.enemyPosition[9]);
    }
    
    public static void writeTest(int stage)
    {
        Random rand = new Random();
        Stage stageData = new Stage();
        
        for(int i = 0; i < 3; i++)
        {
            for(int j = 0; j < 7; j++)
            {
                for(int k = 0; k < 8; k++)
                {
                    stageData.mapData[i][j][k] = (byte)Math.abs(rand.nextInt(255));
                    System.out.print(stageData.mapData[i][j][k] + ", ");
                }
                System.out.println();
            }
            System.out.println();
        }
        
        stageData.heroPosition[0] = 2;
        stageData.heroPosition[1] = 2;
        
        stageData.enemyPosition[0] = 3;
        stageData.enemyPosition[1] = 3;
        stageData.enemyPosition[2] = 4;
        stageData.enemyPosition[3] = 4;
        
        try
        {
            stageData.save(stage);
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -