Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
Hero.java
Package: HauntedCastle.zip [view]
Upload User: qinghua
Upload Date: 2022-06-06
Package Size: 523k
Code Size: 11k
Category:
J2ME
Development Platform:
Java
- import javax.microedition.midlet.*;
- import javax.microedition.lcdui.*;
- public class Hero
- {
- public static int bally,walky;
- public byte wr,wl,t,cu,cd,a,direction,hb;
- public int standy,pow;
- public int panru[]=new int[]{-830,-1325,-2220};
- public int panlu[]=new int[]{-190,-1115,-1715,-1105};
- public int panrd[]=new int[]{-340,-1005,-1610,-2440};
- public int panld[]=new int[]{-70,-940,-1430,-2320};
- public static boolean panlflag,panrflag;
- public void walkright(Graphics g)
- {
- //System.out.print("PANX: ");
- //System.out.println((HauntedCastle.panx -70));
- //System.out.print("PANY: ");
- //System.out.println(HauntedCastle.pany);
- //************************TO STOP PANNING*******************************
- if(HauntedCastle.right==true && HauntedCastle.pany == 0)
- {
- panrflag = true;
- for(int i=0;i<panrd.length;i++)
- {
- if((HauntedCastle.panx-70) == panrd[i])
- {
- panrflag = false;
- }
- }
- if(panrflag)
- {
- HauntedCastle.panx-=5;
- }
- }
- if(HauntedCastle.right==true && HauntedCastle.pany !=0)
- {
- panrflag = true;
- for(int i=0;i<panru.length;i++){
- if((HauntedCastle.panx-70) == panru[i])
- {
- panrflag = false;
- }
- }
- if(panrflag)
- {
- HauntedCastle.panx-=5;
- }
- }
- //***********************************************************************
- if(HauntedCastle.pany!=0)
- walky=62;
- else
- walky=158;
- if(HauntedCastle.right==true)
- {
- if(wr==0)
- {
- g.drawImage(HauntedCastle.hero2,70,walky,Graphics.TOP|Graphics.LEFT );
- wr++;
- }
- else if(wr==1)
- {
- g.drawImage(HauntedCastle.hero3,70,walky,Graphics.TOP|Graphics.LEFT );
- wr++;
- }
- else if(wr==2)
- {
- g.drawImage(HauntedCastle.hero4,70,walky,Graphics.TOP|Graphics.LEFT );
- wr++;
- }
- else if(wr==3)
- {
- g.drawImage(HauntedCastle.hero5,70,walky,Graphics.TOP|Graphics.LEFT );
- wr=0;
- }
- }
- }
- public void walkleft(Graphics g)
- {
- if(HauntedCastle.pany!=0)
- walky=62;
- else
- walky=158;
- // System.out.println((HauntedCastle.panx -70));
- if(HauntedCastle.left==true && HauntedCastle.pany == 0)
- {
- panlflag = true;
- for(int i=0;i<panld.length;i++)
- {
- if((HauntedCastle.panx-70) == panld[i])
- {
- panlflag = false;
- }
- }
- if(panlflag)
- {
- HauntedCastle.panx+=5;
- }
- }
- if(HauntedCastle.left==true && HauntedCastle.pany != 0)
- {
- panlflag = true;
- for(int i=0;i<panlu.length;i++)
- {
- if((HauntedCastle.panx-70) == panlu[i])
- {
- panlflag = false;
- }
- }
- if(panlflag)
- {
- HauntedCastle.panx+=5;
- }
- }
- if(HauntedCastle.action==HauntedCastle.MOVELEFT)
- {
- if(wl==0)
- {
- g.drawImage(HauntedCastle.hero2f,70,walky,Graphics.TOP|Graphics.LEFT );
- wl++;
- }
- else if(wl==1)
- {
- g.drawImage(HauntedCastle.hero3f,70,walky,Graphics.TOP|Graphics.LEFT );
- wl++;
- }
- else if(wl==2)
- {
- g.drawImage(HauntedCastle.hero4f,70,walky,Graphics.TOP|Graphics.LEFT );
- wl++;
- }
- else if(wl==3)
- {
- g.drawImage(HauntedCastle.hero5f,70,walky,Graphics.TOP|Graphics.LEFT );
- wl=0;
- }
- }
- }
- public void standright(Graphics g)
- {
- if (HauntedCastle.pany==0)
- g.drawImage(HauntedCastle.hero1,70,158,Graphics.TOP|Graphics.LEFT );
- else
- g.drawImage(HauntedCastle.hero1,70,62,Graphics.TOP|Graphics.LEFT );
- }
- public void standleft(Graphics g)
- {
- if (HauntedCastle.pany==0)
- g.drawImage(HauntedCastle.hero1f,70,158,Graphics.TOP|Graphics.LEFT );
- else
- g.drawImage(HauntedCastle.hero1f,70,62,Graphics.TOP|Graphics.LEFT );
- }
- public void climbupright(Graphics g)
- {
- if(cu==0)
- {
- g.drawImage(HauntedCastle.hero6,70,158+HauntedCastle.pany,Graphics.TOP|Graphics.LEFT );
- cu++;
- HauntedCastle.pany-=5;
- HauntedCastle.panx-=5;
- }
- else if(cu==1)
- {
- g.drawImage(HauntedCastle.hero5,70,158+HauntedCastle.pany,Graphics.TOP|Graphics.LEFT );
- cu++;
- HauntedCastle.pany-=5;
- HauntedCastle.panx-=5;
- }
- else if(cu==2)
- {
- g.drawImage(HauntedCastle.hero7,70,158+HauntedCastle.pany,Graphics.TOP|Graphics.LEFT );
- cu++;
- HauntedCastle.pany-=5;
- HauntedCastle.panx-=5;
- }
- else if(cu==3)
- {
- g.drawImage(HauntedCastle.hero5,70,158+HauntedCastle.pany,Graphics.TOP|Graphics.LEFT );
- cu=0;
- HauntedCastle.pany-=5;
- HauntedCastle.panx-=5;
- }
- }
- public void climbupleft(Graphics g)
- {
- if(cu==0)
- {
- g.drawImage(HauntedCastle.hero6f,70,158+HauntedCastle.pany,Graphics.TOP|Graphics.LEFT );
- cu++;
- HauntedCastle.pany-=5;
- HauntedCastle.panx+=5;
- }
- else if(cu==1)
- {
- g.drawImage(HauntedCastle.hero5f,70,158+HauntedCastle.pany,Graphics.TOP|Graphics.LEFT );
- cu++;
- HauntedCastle.pany-=5;
- HauntedCastle.panx+=5;
- }
- else if(cu==2)
- {
- g.drawImage(HauntedCastle.hero7f,70,158+HauntedCastle.pany,Graphics.TOP|Graphics.LEFT );
- cu++;
- HauntedCastle.pany-=5;
- HauntedCastle.panx+=5;
- }
- else if(cu==3)
- {
- g.drawImage(HauntedCastle.hero5f,70,158+HauntedCastle.pany,Graphics.TOP|Graphics.LEFT );
- cu=0;
- HauntedCastle.pany-=5;
- HauntedCastle.panx+=5;
- }
- }
- public void climbdownright(Graphics g)
- {
- if(cd==0)
- {
- g.drawImage(HauntedCastle.hero8,70,158+HauntedCastle.pany,Graphics.TOP|Graphics.LEFT );
- cd++;
- HauntedCastle.pany+=5;
- HauntedCastle.panx-=5;
- }
- else if(cd==1)
- {
- g.drawImage(HauntedCastle.hero5,70,158+HauntedCastle.pany,Graphics.TOP|Graphics.LEFT );
- cd++;
- HauntedCastle.pany+=5;
- HauntedCastle.panx-=5;
- }
- else if(cd==2)
- {
- g.drawImage(HauntedCastle.hero9,70,158+HauntedCastle.pany,Graphics.TOP|Graphics.LEFT );
- cd++;
- HauntedCastle.pany+=5;
- HauntedCastle.panx-=5;
- }
- else if(cd==3)
- {
- g.drawImage(HauntedCastle.hero5,70,158+HauntedCastle.pany,Graphics.TOP|Graphics.LEFT );
- cd=0;
- HauntedCastle.pany+=5;
- HauntedCastle.panx-=5;
- }
- }
- public void climbdownleft(Graphics g)
- {
- if(cd==0)
- {
- g.drawImage(HauntedCastle.hero8f,70,158+HauntedCastle.pany,Graphics.TOP|Graphics.LEFT );
- cd++;
- HauntedCastle.pany+=5;
- HauntedCastle.panx+=5;
- }
- else if(cd==1)
- {
- g.drawImage(HauntedCastle.hero5f,70,158+HauntedCastle.pany,Graphics.TOP|Graphics.LEFT );
- cd++;
- HauntedCastle.pany+=5;
- HauntedCastle.panx+=5;
- }
- else if(cd==2)
- {
- g.drawImage(HauntedCastle.hero9f,70,158+HauntedCastle.pany,Graphics.TOP|Graphics.LEFT );
- cd++;
- HauntedCastle.pany+=5;
- HauntedCastle.panx+=5;
- }
- else if(cd==3)
- {
- g.drawImage(HauntedCastle.hero5f,70,158+HauntedCastle.pany,Graphics.TOP|Graphics.LEFT );
- cd=0;
- HauntedCastle.pany+=5;
- HauntedCastle.panx+=5;
- }
- }
- public void blink(Graphics g)
- {
- if(HauntedCastle.pany!=0)
- {
- walky=62;
- }
- else
- {
- walky=158;
- }
- if(hb==0||hb==2||hb==4){
- hb++;
- if(HauntedCastle.rightflag==true)
- {
- g.drawImage(HauntedCastle.hero1,70,walky,Graphics.TOP|Graphics.LEFT );
- }
- else if(HauntedCastle.leftflag==true)
- {
- g.drawImage(HauntedCastle.hero1f,70,walky,Graphics.TOP|Graphics.LEFT );
- }
- }
- else if(hb==1||hb==3||hb==5){ hb++;}
- if(hb==6){
- hb=0;
- HauntedCastle.action = HauntedCastle.STAND;
- }
- }
- public void duck(Graphics g)
- {
- if(HauntedCastle.pany!=0)
- {
- walky=62;
- }
- else
- {
- walky=158;
- }
- if(HauntedCastle.rightflag==true)
- {
- g.drawImage(HauntedCastle.hero10,70,walky,Graphics.TOP|Graphics.LEFT );
- }
- else if(HauntedCastle.leftflag==true)
- {
- g.drawImage(HauntedCastle.hero10f,70,walky,Graphics.TOP|Graphics.LEFT );
- }
- }
- public void charge(Graphics g)
- {
- if(HauntedCastle.pany!=0)
- {
- walky=62;bally=68;
- }
- else
- {
- walky=158;bally=167;
- }
- if(HauntedCastle.rightflag==true)
- {
- g.drawImage(HauntedCastle.hero11,70,walky,Graphics.TOP|Graphics.LEFT );
- g.drawImage(HauntedCastle.firepower1,68,bally,Graphics.TOP|Graphics.LEFT );
- }
- else if(HauntedCastle.leftflag==true)
- {
- g.drawImage(HauntedCastle.hero11f,70,walky,Graphics.TOP|Graphics.LEFT );
- g.drawImage(HauntedCastle.firepower1,90,bally,Graphics.TOP|Graphics.LEFT );
- }
- }
- public void attack(Graphics g)
- {
- if(HauntedCastle.pany!=0)
- {
- walky=62;bally=68;
- }
- else
- {
- walky=158;bally=167;
- }
- if(HauntedCastle.rightflag==true)
- {
- if(HauntedCastle.fireright == true)
- {
- g.drawImage(HauntedCastle.hero12,70,walky,Graphics.TOP|Graphics.LEFT );
- }
- else if(HauntedCastle.fireup == true)
- {
- g.drawImage(HauntedCastle.hero13,70,walky,Graphics.TOP|Graphics.LEFT );
- }
- else if(HauntedCastle.firedown == true)
- {
- g.drawImage(HauntedCastle.hero14,70,walky,Graphics.TOP|Graphics.LEFT );
- }
- }
- if(HauntedCastle.leftflag==true)
- {
- if(HauntedCastle.fireleft == true)
- {
- g.drawImage(HauntedCastle.hero12f,70,walky,Graphics.TOP|Graphics.LEFT );
- }
- else if(HauntedCastle.fireup == true)
- {
- g.drawImage(HauntedCastle.hero13f,70,walky,Graphics.TOP|Graphics.LEFT );
- }
- else if(HauntedCastle.firedown == true)
- {
- g.drawImage(HauntedCastle.hero14f,70,walky,Graphics.TOP|Graphics.LEFT );
- }
- }
- }
- public void fireBall(Graphics g)
- {
- if(HauntedCastle.pany!=0)
- bally=68;
- else
- bally=167;
- if(HauntedCastle.rightflag==true)
- {
- if(HauntedCastle.fireright == true)
- {
- HauntedCastle.panballx+=15;
- g.drawImage(HauntedCastle.firepower2,80+HauntedCastle.panballx,bally,Graphics.TOP|Graphics.LEFT );
- }
- else if(HauntedCastle.fireup == true)
- {
- HauntedCastle.panballx+=15;
- HauntedCastle.panbally-=15;
- g.drawImage(HauntedCastle.firepower3,80+HauntedCastle.panballx,bally+HauntedCastle.panbally,Graphics.TOP|Graphics.LEFT );
- }
- else if(HauntedCastle.firedown == true)
- {
- HauntedCastle.panballx+=15;
- HauntedCastle.panbally+=15;
- g.drawImage(HauntedCastle.firepower4,80+HauntedCastle.panballx,bally+HauntedCastle.panbally,Graphics.TOP|Graphics.LEFT );
- }
- }
- if(HauntedCastle.leftflag==true)
- {
- if(HauntedCastle.fireleft == true)
- {
- HauntedCastle.panballx-=15;
- g.drawImage(HauntedCastle.firepower2,80+HauntedCastle.panballx,bally,Graphics.TOP|Graphics.LEFT );
- }
- else if(HauntedCastle.fireup == true)
- {
- HauntedCastle.panballx-=15;
- HauntedCastle.panbally-=15;
- g.drawImage(HauntedCastle.firepower3,80+HauntedCastle.panballx,bally+HauntedCastle.panbally,Graphics.TOP|Graphics.LEFT );
- }
- else if(HauntedCastle.firedown == true)
- {
- HauntedCastle.panballx-=15;
- HauntedCastle.panbally+=15;
- g.drawImage(HauntedCastle.firepower4,80+HauntedCastle.panballx,bally+HauntedCastle.panbally,Graphics.TOP|Graphics.LEFT );
- }
- }
- }
- }