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

📄 framecanvas.java

📁 J2ME手机游戏的矿架程序
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/*********************************
 * Title:       Game Frame
 * Description: ACT Game
 * Copyright:   Copyright (c) 2005
 * Company:     ???信息技术有限公司
 * Begin Time:  2005 12 11
 * Programer:   狗尾巴
 * version      1.0
 **********************************/
import java.io.*;
import java.util.*;
import javax.microedition.lcdui.*;
import javax.microedition.rms.*;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
//nokia
import com.nokia.mid.sound.*;
import com.nokia.mid.ui.*;
//import com.nokia.mid.ui.DirectUtils;
//==============================================================================
//Nokia
public final class frameCanvas
       extends     FullCanvas
       implements  Runnable
//no Nokia
//public final class frameCanvas
//       extends     Canvas
//       implements  Runnable
{
  //
  private int  wordY =0;
  private byte wordSp=2;
  private final byte max_wordSp=8;
  //Thread
  frameMIDlet       game;
  private Thread    gameThread;
  //radom
  private Random    random   = new Random();
  //quit?
  private boolean   quitGame = false;//游戏结束
  //screen big
  private final short WIDTH  = (short)getWidth(); //11
  private final short HEIGHT = (short)getHeight();//13
  //game   time
  byte InitTime1=127;
  int  InitTime = 100;

  InitTime-=50;
  int  TIME_PER_FRAME = InitTime;   //游戏速度的控制
  private final static Font defaultFont = Font.getFont(Font.FACE_PROPORTIONAL,
                                          Font.STYLE_PLAIN, Font.SIZE_SMALL);
//**********************************RES*****************************************
//Sound
  frameMidi       midi=null;     //Midi
  public  boolean PlaySound=true;//声音开关
  public  boolean isMidiOpen=false;
//Data Home
  private RecordStore rStore;//游戏保存使用的数据库
  private byte saveWin=0;
//Img
  private static DirectGraphics dg; //用于图片反转
  private Image   imgLogo[]   =null;
  private Image   imgGameLogo =null;
//  private Image   imgBack     =null;
  private Image   imgMapCell  =null;
  private Image   imgMenuBack =null;

  private Image   imgArrow    =null;
  private Image   imgIs       =null;

  private Image   imgMan[]    =null;
  private Image   imgManBlood =null;
  private Image   imgTalk[]   =null;
  private Image   imgIcon     =null;

  private Image   imgMonster[][]   =null;
  //MENU
  private byte    menu_from_who=99;
  private byte    lp_help_word = 0;
  private byte    menu_choose=0;
//******************************************************************************
  //game_state
  public  byte       game_state    =  0;

  public final byte GAME_LOAD      = 0;//游戏最先进入的状态
  public final byte GAME_RUN       = 1;//游戏状态
  public final byte GAME_ABOUT     = 2;//游戏结束
  public final byte GAME_SMALL_MAP = 3;//小地图
  public final byte GAME_MAIN_MENU = 4;//主彩单
  public final byte GAME_LOADING   = 5;//载入效果
  public final byte GAME_SUB_MENU  = 6;//子菜单
  public final byte GAME_MAN_DEAD  = 7;//man挂了
  public final byte GAME_ERROR     = 8;//处理出错
  public final byte GAME_LOAD_SOUND= 9;
  public final byte GAME_TALK      =10;//设置按键
  public final byte GAME_START_CG  =11;//游戏开始动画
  public final byte GAME_HELP      =12;//帮助
  public final byte GAME_WORK      =13;//显示任务
  public final byte GAME_ALL_WIN   =14;//通关
//  public final byte GAME_EXIT      =15;//exit
//  public final byte GAME_TEL       =16;//来电
  public final byte GAME_PAUSE     =77;//暂停
  //来电处理
  public  static byte telState     =  0;
  private byte   step              = 16;
  //key
  private byte    init_key_delay   =  3;//按键延迟
  private byte    key_delay        =  init_key_delay;//按键延迟
  private boolean keyRepeat;          //是否按下
  public  int     key;                //键值
  //******************************Debug Data************************************
  private boolean isDebug=true;
  byte    error;
  String  errorString;
  String  errorS;
  String  errorS1;
  //************************Often Change Data in Game***************************
  //game  data
  private final  byte   noThingByte    = 99;
  private final  short  noThingShort   = 999;
  private final  int    noThingInt     = 1999999999;

  public  int    gameTime       =  0;
  private byte   loading        =  0;
  private byte   gate           =  1;
  private final  byte   boot    = 4;
  private final  byte   Gravity = boot;
  //init  final  bearing
  private final  byte   up   =0;
  private final  byte   down =1;
  private final  byte   left =3;
  private final  byte   right=2;
  //mapCellData
  private final  byte mapCellW=32;
  private final  byte mapCellH=32;
  private byte   map[][]=
  {{0,1},{0,1}};

  private short  mapX_max=(short)(map[0].length*mapCellW-WIDTH-mapCellW);
  private byte   mapX_min=mapCellW;
  private short  mapY_max=(short)(map.length*mapCellH   -HEIGHT);
  private byte   mapY_min=mapCellH;
  private short  mapX=mapCellW;
  private short  mapY=mapY_max;//6*16;
  private short  show_map_x=0;
  private short  show_map_y=0;
  //==============
  private final  byte mapMoveSp_slow =  8;
  private final  byte mapMoveSp_fast = (byte)(HEIGHT/4);
  //cjc   data==================================================================
  frameMan man= new frameMan();
  //naruto pic XY
  private short imgD_XY[][]=
  {
    //0 stop 1
    {112,85,28,38},//stop
    //1 stop 2
    {112,85,28,38},//stop
    //2 stop 3
    {112,85,28,38},//stop
    //3 stop 2
    {112,85,28,38},//stop
    //4 run  1
    {140,83,30,39},//run1
    //5 run  2
    {170,86,29,36},//run2
    //6 run  4
    {151,0,29,41}, //run4
    //7 run  5
    {72,119,30,38},//run5
    //8 run  3 noUse
    {31,44,33,38},//gu 1
    //9  gu 1
    {31,44,33,38},//gu 1
    //10 gu 2
    {88, 0,36,41},//gu 2
    //11 gu 3
    {0,137,33,41},//gu 3
    //12 jump1
    {0,0,32,46},  //jump
    //13 jump2
    {197,41,29,45},//jump smile
    //14 down
    {59,0,29,44},//down
    //15 die 1
    {0,49,31,29},//back and down
    //16 die 2
    {0,82,41,16},//lay
    //17 hurt
    {181,124,36,35},//hurt
    //18 att 1
    {40,119,32,38},//att
    //19 att 2
    {33,157,54,40},//att
    //20 att 3
    {0,98,40,39},//att
    //21 att 4
    {102,123,50,36},//att
    //22 jump att1
    {124,0,27,44},//jump att 1
    //23 jump att2
    {180,0,46,41},//jump att 2
    //24 jump att3
    {30,0,27,44},//jump att 3
    //25 xiang jiao 1
    {64,44,70,41}, //big att 1
    //26 xiang jiao 2
    {134,44,63,39},//big att 2
    //27 xiang jiao 3
    {64,44,70,41}, //big att 1
    //28 xiang jiao 1
    {134,44,63,39},//big att 2
    //29 xiang jiao 2
    {64,44,70,41}, //big att 1
    //30 xiang jiao 3
    {134,44,63,39},//big att 2
    //31 导弹 1
    {152,122,29,38},//big att long
    //32 导弹 2
    {40,119,32,38},//att
    //33 导弹 3
    {41,85,71,34}, //big att long
    //34 导弹 4
    {41,85,71,34}, //big att long
    //35 导弹 5
    {102,123,50,36},//att
    //36 冲出去
    {171,160,52,28},
    //37 冲出去
    {171,160,52,28},
    //38 冲出去
    {171,160,52,28},
    //39 冲出去
    {171,160,52,28},
    //40 冲出去
    {171,160,52,28},
    //41 冲出去
    {171,160,52,28},
    //42 冲出去
    {171,160,52,28},
    //43 抓
    {33,157,54,40},
    //44 抓
    {33,157,54,40},
    //45 抓
    {41,85,71,34}, //big att long
    //46 抓
    {86,161,85,40},
  };

  private short imgMonster_XY[][][]=
  {
   {//0 monster1
     //0  stop  1
     {  0,43},
     //1  stop  2
     {  0,43},
     //2  stop  3
     {  0,43},
     //3  stop  4
     {  0,43},
     //4  run   1
     {  0,43},
     //5  run   2
     { 43, 86-43},
     //6  run   3
     { 86,124-86},
     //7  att   1
     {124,160-124},
     //8  att   2
     {160,198-167},
     //9  att   3
     {198,241-203},
     //10 hurt
     {241,270-241},
     //11 hurt
     {241,270-241},
     //12 die   1
     {270,313-270},
     //13 die   1
     {270,313-270},
     //14 die   2
     {313,351-313},
   },
   {//1---枪兵
     //0 run 1
     {255,37},
     //1 run 2
     {292,34},
     //2 run 3
     {326,36},
     //3 throw 1
     {170,39},
     //4 throw 3
     {209,46},
     //5 throw 2
     {129,41},
     //6 hurt
     { 93,36},
     //7 die 1
     { 50,43},
     //8 die 2
     {  7,43},
     //9 kinfe
     {  0, 7},
   },
   {//2---dog
     //0  stop  1
     {  0,25},
     //1  stop  2
     {  0,25},
     //2  stop  3
     {  0,25},
     //3  stop  4
     {  0,25},
     //4  run   1
     {  0,25},
     //5  run   2
     { 25,48-25},
     //6  run   3
     { 48,71-48},
     //7  att   1
     { 71,95-71},
     //8  att   2
     { 95,118-95},
     //9  att   3
     {118,152-118},
     //10 hurt
     {152,182-152},
     //11 hurt
     {152,182-152},
     //12 die   1
     {182,220-182},
     //13 die   1
     {182,220-182},
     //14 die   2
     {220,263-220},
   },
   {//3---大炮
     {142,40},
     { 92,50},
     { 48,44},
     {  0,48},
   },
   {//4---飞刀

   },
   {//5---炮弹

   },
   {//6---food
     //1 +blood
     { 0,16},
     //2 +magic
     {16,11},
   },
   {//7---boss
     {218,263-218},//0 stop
     {218,263-218},//1 stop
     {218,263-218},//2 stop
     {313,354-313},//3 run 1
     {354,393-354},//4 run 2
     {263,313-263},//5 att
     {263,313-263},//6 att
     {182,218-182},//7 hurt
   },
   {//8---boss's leg
     {  0,60-0},//leg 1
     { 60,117-60},//leg 2
     {117,182-117},//leg 3
   }
  };
  private byte bomGo_XY[][]=
  {
    {  0,16},
    { 16,19},
    { 35,21},
    { 56,25},
    { 81,19},
    {100,17},
  };
  frameMonster monster[]=null;
//talk==========================================================================
  private byte   lp_whichTalk=0;
  private byte   lp_strTalkIcon=0;
  private byte   lp_strTalk=(byte)(lp_strTalkIcon+1);
  private String strTalk[][]=
  {
    {//gate 1  ===========0
      "man",
      "啊!地面上有很多钉",
      "板看来要很小心了!",
      "一定要将敌人全部",
      "歼灭才能冲过去啊...",
      "exit",
    },
    {//hint ============1
//      "man",
      //游戏中的提示
//      "exit",
    },
    {//gate 2===============2
      "man",
      "一定要将敌人全部",
      "歼灭才能冲过去啊...",
      "exit",
    },
    {//gate 7===============3(开打之前)
      "man",
      "试用版对话",
      "exit",
    },
    {//gate 7===============4(开打)
      "boss",
      "试用版对话",
      "开始战斗吧!",
      "exit",
    },
    {//gate 7================5()
      "boss",
      "试用版对话",
      "结束战斗",
      "exit",
    },
    {//gate 7=================6()
      "man",
      "试用版对话",
      "一切会就这末完结了",
      "吗?",
      "......",
      "......",
      "谢谢使用.",
      "清华联出品,必是精品.",
      "敬请期待下一力作!",
      "全部剧情结束",
      "exit",
    },
  };
//******************************************************************************
  public frameCanvas(frameMIDlet game)
  {
    this.game=game;
//    this.setFullScreenMode(true);
  }

  public final void game_start() //开始线程
  {
    gameThread=new Thread(this);
    gameThread.start();
  }

  public final void game_stop()
  {
    gameThread=null;
    System.gc();
  }
//==============================================================================

⌨️ 快捷键说明

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