📄 gamecanvas.java
字号:
img_jtl = ImageSet.readImage("/img/Picture.Lib", 1498);
}
if(img_jtr == null)
{
img_jtr = ImageSet.readImage("/img/Picture.Lib", 5324);
}
break;
case Configration.SS_INTRO:
if(img_AnyKey == null)
{
img_AnyKey = ImageSet.readImage("/img/Picture.Lib", 1680);
}
break;
case Configration.SS_GAMING:
if(img_Hero == null)
{
img_Hero = ImageSet.readImage("/img/Picture.Lib", 2850);
}
if(img_Map == null)
{
img_Map = ImageSet.readImage("/img/Picture.Lib", 5508);
}
if(img_Title == null)
{
img_Title = ImageSet.readImage("/img/Picture.Lib", 31736);
}
if(img_jtl == null)
{
img_jtl = ImageSet.readImage("/img/Picture.Lib", 1498);
}
if(img_jtr == null)
{
img_jtr = ImageSet.readImage("/img/Picture.Lib", 5324);
}
break;
case Configration.SS_END:
if(img_AnyKey == null)
{
img_AnyKey = ImageSet.readImage("/img/Picture.Lib", 1680);
}
break;
case Configration.SS_ABOUT:
break;
}
}
private void FreeImage() //图片御载
{
switch(SS_NOW)
{
case Configration.SS_LOGO:
if(img_Logo != null)
{
img_Logo = null;
}
break;
case Configration.SS_TITLE:
if(img_Title != null)
{
img_Title = null;
}
if(img_AnyKey != null)
{
img_AnyKey = null;
}
break;
case Configration.SS_MENU:
if(img_Title != null)
{
img_Title = null;
}
if(img_jtl != null)
{
img_jtl = null;
}
if(img_jtr != null)
{
img_jtr = null;
}
break;
case Configration.SS_INTRO:
if(img_AnyKey != null)
{
img_AnyKey = null;
}
break;
case Configration.SS_GAMING:
if(img_Hero != null)
{
img_Hero = null;
}
if(img_Map != null)
{
img_Map = null;
}
if(img_Title != null)
{
img_Title = null;
}
if(img_jtl != null)
{
img_jtl = null;
}
if(img_jtr != null)
{
img_jtr = null;
}
break;
case Configration.SS_END:
if(img_AnyKey != null)
{
img_AnyKey = null;
}
break;
case Configration.SS_ABOUT:
break;
}
System.gc();
}
public void keyPressed(int keyCode)
{
switch(SS_NOW)
{
case Configration.SS_LOGO:
break;
case Configration.SS_TITLE:
FreeImage();
SS_NOW = Configration.SS_MENU;
LoadImage();
break;
case Configration.SS_MENU:
switch(keyCode)
{
case Configration.KEY_UP:
case KEY_NUM2:
b_Selected --;
if(b_Selected < 0)
{
b_Selected = 3;
}
break;
case Configration.KEY_DOWN:
case KEY_NUM8:
b_Selected ++;
if(b_Selected > 3)
{
b_Selected = 0;
}
break;
case Configration.KEY_OK:
case KEY_NUM5:
switch(b_Selected)
{
case 0: //开始新游戏
is_Loaded = false;
FreeImage();
offestY = i_lcdHeight - 30;
SS_NOW = Configration.SS_INTRO;
LoadImage();
break;
case 1: //继续游戏
is_Loaded = false;
FreeImage();
SS_NOW = Configration.SS_GAMING;
LoadImage();
initGame();
LoadGame();
initStage();
break;
case 2: //游戏说明
FreeImage();
SS_NOW = Configration.SS_ABOUT;
LoadImage();
break;
case 3: //结束游戏
ExitGame();
break;
}
b_Selected = 0;
break;
}
break;
case Configration.SS_INTRO:
FreeImage();
SS_NOW = Configration.SS_GAMING;
LoadImage();
initGame();
initStage();
break;
case Configration.SS_GAMING:
switch(CurrentState)
{
case Configration.NORMAL:
if(is_Move)
{
switch(keyCode)
{
case Configration.KEY_LEFT:
case KEY_NUM4:
Direction = Configration.LEFT;
if(CanMove())
{
map.move(32,0);
b_x--;
}
break;
case Configration.KEY_RIGHT:
case KEY_NUM6:
Direction = Configration.RIGHT;
if(CanMove())
{
map.move(-32,0);
b_x++;
}
break;
case Configration.KEY_UP:
case KEY_NUM2:
Direction = Configration.UP;
if(CanMove())
{
map.move(0,32);
b_y--;
}
break;
case Configration.KEY_DOWN:
case KEY_NUM8:
Direction = Configration.DOWN;
if(CanMove())
{
map.move(0,-32);
b_y++;
}
break;
case Configration.KEY_OK:
case KEY_NUM5:
CurrentState = Configration.SHOWMENU;
break;
case KEY_NUM1:
if(b_Stage != 21 && hasLuoPan)
{
b_Selected = 1;
CurrentState = Configration.LUOPAN;
}
break;
case KEY_NUM3:
if(hasBaoDian)
{
b_Dx = b_x;
b_Dy = b_y;
CurrentState = Configration.INFO;
}
break;
}
}
break;
case Configration.INFO:
switch(keyCode)
{
case KEY_NUM3:
map.setPosition(-b_x * 32 + i_lcdCenterX - 16, -b_y * 32 + i_lcdCenterY - 15);
CurrentState = Configration.NORMAL;
break;
case Configration.KEY_UP:
case KEY_NUM2:
if(b_Dy > 0)
{
b_Dy--;
map.move(0, 32);
}
break;
case Configration.KEY_DOWN:
case KEY_NUM8:
if(b_Dy < 10)
{
b_Dy++;
map.move(0, -32);
}
break;
case Configration.KEY_LEFT:
case KEY_NUM4:
if(b_Dx > 0)
{
b_Dx--;
map.move(32, 0);
}
break;
case Configration.KEY_RIGHT:
case KEY_NUM6:
if(b_Dx < 10)
{
b_Dx++;
map.move(-32, 0);
}
break;
}
break;
case Configration.SHOWMENU:
switch(keyCode)
{
case Configration.KEY_UP:
case KEY_NUM2:
b_Selected--;
if(b_Selected < 0)
{
b_Selected = 4;
}
break;
case Configration.KEY_DOWN:
case KEY_NUM8:
b_Selected++;
if(b_Selected > 4)
{
b_Selected = 0;
}
break;
case Configration.KEY_OK:
case KEY_NUM5:
switch(b_Selected)
{
case 0:
CurrentState = Configration.NORMAL;
break;
case 1:
SaveMap();
SaveGame();
CurrentState = Configration.NORMAL;
break;
case 2:
LoadGame();
initStage();
CurrentState = Configration.NORMAL;
break;
case 3:
CurrentState = Configration.ABOUT;
break;
case 4:
FreeImage();
SS_NOW = Configration.SS_MENU;
LoadImage();
CurrentState = Configration.NORMAL;
break;
}
b_Selected = 0;
break;
}
break;
case Configration.SHOPING:
switch(keyCode)
{
case Configration.KEY_UP:
case KEY_NUM2:
b_Selected--;
if(b_Selected < 0)
{
b_Selected = 3;
}
break;
case Configration.KEY_DOWN:
case KEY_NUM8:
b_Selected++;
if(b_Selected > 3)
{
b_Selected = 0;
}
break;
case Configration.KEY_OK:
case KEY_NUM5:
if(b_Stage == 3 && HeroMoney >= 25 && b_Selected!= 3)
{
HeroMoney -= 25;
switch(b_Selected)
{
case 0:
HeroLp += 800;
break;
case 1:
HeroAc += 4;
break;
case 2:
HeroDc += 4;
break;
}
}
else if(b_Stage == 11 && HeroMoney >= 100 && b_Selected != 3)
{
HeroMoney -= 100;
switch(b_Selected)
{
case 0:
HeroLp += 4000;
break;
case 1:
HeroAc += 20;
break;
case 2:
HeroDc += 20;
break;
}
}
else if(b_Selected == 3)
{
CurrentState = Configration.NORMAL;
b_Selected = 0;
}
break;
}
break;
case Configration.LEVELUP:
switch(b_Stage)
{
case 2:
case 15:
if(!is_DialogedForLevelUp && Message != null)
{
b_DialogIndexForLevelUp++;
DialogForLevelUp();
}
else
{
Message = null;
is_DialogedForLevelUp = false;
CurrentState = Configration.NORMAL;
}
break;
case 5:
switch(keyCode)
{
case Configration.KEY_UP:
case KEY_NUM2:
b_Selected--;
if(b_Selected < 0)
{
b_Selected = 3;
}
break;
case Configration.KEY_DOWN:
case KEY_NUM8:
b_Selected++;
if(b_Selected > 3)
{
b_Selected = 0;
}
break;
case Configration.KEY_OK:
case KEY_NUM5:
switch(b_Selected)
{
case 0:
if(HeroExp >= 100)
{
HeroExp -= 100;
HeroLvUp(1);
}
break;
case 1:
if(HeroExp >= 30)
{
HeroExp -= 30;
HeroAc += 5;
}
break;
case 2:
if(HeroExp >= 30)
{
HeroExp -= 30;
HeroDc += 5;
}
break;
case 3:
CurrentState = Configration.NORMAL;
b_Selected = 0;
break;
}
break;
}
break;
case 13:
switch(keyCode)
{
case Configration.KEY_UP:
case KEY_NUM2:
b_Selected--;
if(b_Selected < 0)
{
b_Selected = 3;
}
break;
case Configration.KEY_DOWN:
case KEY_NUM8:
b_Selected++;
if(b_Selected > 3)
{
b_Selected = 0;
}
break;
case Configration.KEY_OK:
case KEY_NUM5:
switch(b_Selected)
{
case 0:
if(HeroExp >= 270)
{
HeroExp -= 270;
HeroLvUp(3);
}
break;
case 1:
if(HeroExp >= 95)
{
HeroExp -= 95;
HeroAc += 17;
}
break;
case 2:
if(HeroExp >= 95)
{
HeroExp -= 95;
HeroDc += 17;
}
break;
case 3:
CurrentState = Configration.NORMAL;
b_Selected = 0;
break;
}
break;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -