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

📄 poptang.java

📁 这是一个毕业设计的泡泡堂源代码
💻 JAVA
字号:
/*
 * 创建日期 2007-2-20
 * @author cpiz
 */
package com.cpiz.poptang;

import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

/**
 * 游戏主Midlet类
 * @author cpiz
 */
public class PopTang extends MIDlet
{
    private Display display = null;
    NcuscSplash ncuscSplash = null;
    Splash splash = null;
    Menu menu = null;
    Game game = null;
    
    /**
     * PopTang构造函数
     */
    public PopTang()
    {
        ncuscSplash = new NcuscSplash(this);
        splash = new Splash(this);
        menu = new Menu(this);
        game = new Game(this);
                
        display = Display.getDisplay(this);
    }

    protected void destroyApp(boolean arg0) throws MIDletStateChangeException
    {
    }

    protected void pauseApp()
    {
    }

    /**
     * 启动游戏,显示splash
     */
    protected void startApp() throws MIDletStateChangeException
    {        
        ncuscSplash.showMe();
    }
    
    /**
     * 显示displayable内容
     * 
     * @param displayable
     *            可显示的对象
     */
    public void setDisplayable(Displayable displayable)
    {
        display.setCurrent(displayable);
    }

    /**
     * 退出游戏
     */
    public void quitGame()
    {
        try
        {
            destroyApp(true);
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
        notifyDestroyed();
    }
    
    /***********************************************************************************
     * 
     *                                  splash常量
     * 
     ***********************************************************************************/   
    
    /**
     * splash显示时间,默认为3000毫秒
     */
    public static final int SPLASH_TIME = 3000;
    
    /**
     * splash跳过提示
     */
    public static final String SKIP_SPLASH_TIP = "Press any key to skip";
    
    /**
     * splash文字行距
     */
    public static final int SPLASH_ROW_SPACING = 2;
    
    /**
     * splash文字内容
     */
    public static final String[] SPLASH_TEXT = {
        "软件学院", 
        "2007届毕业设计", 
        "学生姓名: 蔡剑文", 
        "指导老师: 万立中"
        };
    
    /***********************************************************************************
     * 
     *                                   菜单常量
     * 
     ***********************************************************************************/   
    
    /**
     * 菜单选项
     */
    public static final String[] MENU_OPTIONS = {
        "START", 
        "HELP", 
        "ABOUT", 
        "QUIT"};

    /**
     * 白色
     */
    public static final int COLOR_WHITE = 0xFFFFFF;
    
    /**
     * 灰色
     */
    public static final int COLOR_GRAY = 0xD9D9D9;
    
    /**
     * 黑色
     */
    public static final int COLOR_BLACK = 0x000000;
    
    /**
     * 红色
     */
    public static final int COLOR_RED = 0xFF0000;
    
    /**
     * 黄色
     */
    public static final int COLOR_YELLOW = 0xFFFF00;
    
    /**
     * 菜单起始绘制Y轴位置
     */
    public static final int MENU_Y_START = 60;
    
    /**
     * 菜单项行距
     */
    public static final int MENU_ROW_SPACING = 2;
    
    /**
     * 菜单光标与屏幕中线的水平距离
     */
    public static final int MENU_CURSOR_SPACING = 40;
    
    /**
     * 菜单光标闪烁时间
     */
    public static final int MENU_WINK_TIME = 500;
    
    
    /***********************************************************************************
     * 
     *                                   游戏常量
     * 
     ***********************************************************************************/   
    
    /**
     * 第一关
     */
    public static final int FIRST_STAGE = 1;
    
    /**
     * 最后一关
     */
    public static final int LAST_STAGE = 3;
    
    /**
     * 帮助/关于界面操作提示
     */
    public static final String HELP_TIP = "↑↓键翻页, 其它键返回";
    
    /**
     * 帮助文字
     */
    public static final String[] HELP_TEXT = {"帮助", "←↑↓→移动角色\n5键放置泡泡\n左软键返回菜单\n右软键暂停与恢复\n消灭所有敌人后完成关卡"};
    
    /**
     * 关于文字
     */
    public static final String[] ABOUT_TEXT = {"关于", "《手机单人版泡泡堂》\n南昌大学软件学院2007届毕业设计\n指导老师:万立中\n学生姓名:蔡剑文\nwww.cpiz.com"};
    
    /**
     * 帮助及关于背景色
     */
    public static final int HELP_BGCOLOR = 0x00BFFF;
    
    /**
     * 装载提示
     */
    public static final String[] COMPLETED_TIP = {"Completed ", "Stage "};
    
    /**
     * 装载提示
     */
    public static final String[] LOADING_TIP = {"Loading ", "Stage "};
    
    /**
     * 游戏每帧绘制时间,单位为ms
     */
    public static final int GAME_MSPF = 50;
    
    /**
     * 游戏界面高度
     */
    public static final int GAME_HEIGHT = 128;
    
    /**
     * 游戏界面宽度
     */
    public static final int GAME_WIDTH = 128;
    
    /**
     * 地图格列数
     */
    public static final int MAP_COLS = 8;
    
    /**
     * 地图格行数
     */
    public static final int MAP_ROWS = 7;
    
    /**
     * 图像单元格高度
     */
    public static final int CELL_HEIGHT = 16;
    
    /**
     * 图像单元格宽度
     */
    public static final int CELL_WIDTH = 16;
    
    /**
     * 道具产生概率<br>
     * 取值范围为1~100,表示1% ~ 100%,生成的道具为随机类别
     */
    public static final int TOOL_PROBABILITY = 100;
    
    /***********************************************************************************
     * 
     *                                   图片路径
     * 
     ***********************************************************************************/  
    public static final String IMAGE_DIR = "/img/";
    public static final String IMAGE_SRC_NCUNAME = "/img/ncuname.png";
    public static final String IMAGE_SRC_NCULOGO = "/img/nculogo.png";
    public static final String IMAGE_SRC_HERO = "/img/hero.png";
    public static final String IMAGE_SRC_ENEMY = "/img/enemy.png";
    public static final String IMAGE_SRC_CURSOR = "/img/cursorpop.png";
    public static final String IMAGE_SRC_ITEMS = "/img/items.png";
    public static final String IMAGE_SRC_TOOLS = "/img/tools.png";
    public static final String IMAGE_SRC_MENU = "/img/menu.png";
    public static final String IMAGE_SRC_FLOOR = "/img/floor.png";
    
    /**
     * 出生时间<br>
     * 该断时间内精灵做出出生动作
     */
    public static final int BORN_TIME = 30;
    
    /**
     * 休息指定时间<br>
     * 当无操作时,精灵经过一段时间后进入休息状态
     */
    public static final int REST_WAITTIME = 10;
    
    /**
     * 死亡时间<br>
     * 死亡时间内人物进行死亡动作,完成后人物失效
     */
    public static final int DEAD_WAITTIME = 30;
    
    public static final int HERO_WIDTH = 16;
    public static final int HERO_HEIGHT = 24;
    
    public static final int GOLD_COIN_SCORE = 20;
    public static final int SILVER_COIN_SCORE = 10;
    
}

⌨️ 快捷键说明

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