?? gbase.java
字號:
/////////////////////////////////////////////////////////////////////////////////////
/////////////// Magic.CY 2004-9-16 10:23//////////////////////////////
/////////////// //////////////////////////////
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import java.util.*;
import java.io.*;
import com.nokia.mid.ui.*;
public class GBase
{
public int x,y;
public int move;
public int direction;
public int hp;
public boolean enemydown = false;
public boolean isfast = false;
public static int [][] imgindex;
public static int[]jump =
{7,4,2,0,-2,-4,-7,};
public int index = 8;
public int state = 0;
public int count = 0;
public GBase()
{
x = 0;
y = 60;
}
public void paint(Graphics bufferg)
{
//DirectGraphics dg = DirectUtils.getDirectGraphics(bufferg);
if(direction == 1)
{
DirectGraphics dg = DirectUtils.getDirectGraphics(bufferg);
Image image = DirectUtils.createImage(110,50,0x00000000);
Graphics ggg = image.getGraphics();
for(int i = 0;i < imgindex[index][0];i++)
{
ggg.setClip(imgindex[index][4+i*7],20+imgindex[index][5+i*7],imgindex[index][6+i*7],imgindex[index][7+i*7]);
ggg.drawImage(GDate.img[imgindex[index][1+i*7]],imgindex[index][4+i*7]-imgindex[index][2+i*7],20+imgindex[index][5+i*7]-imgindex[index][3+i*7],20);
bufferg.setClip(0,0,128,128);
dg.drawImage(image,x-75,y-20,20,0x2000);
}
}
else
{
for(int i = 0;i < imgindex[index][0];i++)
{
bufferg.setClip(x+imgindex[index][4+i*7],y+imgindex[index][5+i*7],imgindex[index][6+i*7],imgindex[index][7+i*7]);
bufferg.drawImage(GDate.img[imgindex[index][1+i*7]],x+imgindex[index][4+i*7]-imgindex[index][2+i*7],y+imgindex[index][5+i*7]-imgindex[index][3+i*7],20);
}
}
}
public void update()
{
if((GManager.gamecount%1)==0)
{
// index ++;
//if(index == 22)index = 8;
switch(state)
{
case 0: //靜止
index = 0;
count = 0;
int key = GCanvas.queueKeyStatesClear();
if((key & GCanvas.K_6)!= 0 ||(key & GCanvas.K_RIGHT)!= 0)
{
move = 0;
state = 1;
index = 1;
count = 2;
direction = 0;
}
else
if((key & GCanvas.K_2)!= 0 ||(key & GCanvas.K_UP)!= 0)
{
move = 2;
state = 1;
index = 1;
count = 2;
}
else
if((key & GCanvas.K_8)!= 0 ||(key & GCanvas.K_DOWN)!= 0)
{
move = 3;
state = 1;
index = 1;
count = 2;
}
else
if((key & GCanvas.K_4)!= 0 ||(key & GCanvas.K_LEFT)!= 0)
{
move = 1;
state = 1;
index = 1;
count = 2;
direction = 1;
}
else
if((key & GCanvas.K_7)!= 0 )
{
state = 4;
index = 8;
count = 4;
}
else
if((key & GCanvas.K_5)!= 0 )
{
if(enemydown)
{
state = 3;
index = 3;
count = 3;
}
else
{
state = 4;
index = 4;
count = 4;
}
}
else
if((key & GCanvas.K_9)!= 0 )
{
state = 4;
index = 12;
count = 13;
}
else
if((key & GCanvas.K_1)!= 0 )
{
state = 5;
count = 7;
direction = 1;
}
else
if((key & GCanvas.K_3)!= 0 )
{
state = 5;
count = 7;
direction = 0;
}
break;
case 1: //走路
if(!isfast)
count --;
if((GManager.gamecount/2)%2==0)
{
index = 0;
}
else
{
index = 1;
}
if(move == 0)
{
if(x<78)
{
x+=2;
if(isfast)x+=2;
}else
if((GManager.bkcount/16)<16)
{
GManager.bkcount+=2;
if(isfast)GManager.bkcount+=2;
}
else
{
state = 0;
isfast = false;
}
}
else
if(move == 1)
{
if(x>5)
{
x-=2;
if(isfast)x-=2;
}else
if((GManager.bkcount)>6)
{
GManager.bkcount-=2;
if(isfast)GManager.bkcount-=2;
}
else
{
state = 0;
isfast = false;
}
}
else
if(move == 2)
{
if(y>28)
{
y-=3;
}
}
if(move == 3)
{
if(y<80)
{
y+=3;
}
}
key = GCanvas.queueNowKeyStates();
if(((key & GCanvas.K_6)!= 0 ||(key & GCanvas.K_RIGHT)!= 0)&&move == 0)
{
count = 1;
}
if(((key & GCanvas.K_2)!= 0 ||(key & GCanvas.K_UP)!= 0)&&move == 2)
{
count = 1;
}
if(((key & GCanvas.K_8)!= 0 ||(key & GCanvas.K_DOWN)!= 0)&&move == 3)
{
count = 1;
}
if(((key & GCanvas.K_4)!= 0 ||(key & GCanvas.K_LEFT)!= 0)&&move == 1)
{
count = 1;
}
key = GCanvas.queueKeyStatesClear();
if(isfast)
{
if(key !=0)
isfast = false;
}
else
{
if(((key & GCanvas.K_6)!= 0 ||(key & GCanvas.K_RIGHT)!= 0)&&move == 0)
{
isfast = true;
}
if(((key & GCanvas.K_4)!= 0 ||(key & GCanvas.K_LEFT)!= 0)&&move == 1)
{
isfast = true;
}
}
if(count == 0)
{
state = 0;
isfast = false;
}
break;
case 2: //格檔
count --;
key = GCanvas.queueNowKeyStates();
if((key & GCanvas.K_7)!= 0 )
{
count = 3;
}
if(count == 0)
{
state = 0;
}
break;
case 3: //刺
count --;
if(count == 0)
{
state = 0;
}
break;
case 4: //攻擊//超殺
count --;
index++;
if(count == 0)
{
state = 0;
index = 0;
}
break;
case 5:
count--;
index = 26;
if(direction ==0)
{
if(x<78)
{
x+=5;
}else
if((GManager.bkcount/16)<16)
{
GManager.bkcount+=5;
}
}
else
{
if(x>8)
{
x-=5;
}else
if((GManager.bkcount)>10)
{
GManager.bkcount-=5;
}
}
y+=jump[count];
if(count ==0)
{
state = 0;
index = 1;
}
break;
}
}
}
public void attack()
{
}
public void beattacked(int type)
{
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -