Ghost.java
上传用户:qinghua
上传日期:2022-06-06
资源大小:523k
文件大小:4k
源码类别:

J2ME

开发平台:

Java

  1. import javax.microedition.midlet.*;
  2. import javax.microedition.lcdui.*;
  3. public class Ghost
  4. {
  5. public byte zw,zd;
  6. public int moveghost,movez,ghostx,ghosty,walky,zombilevel;
  7.     boolean ghostdeadflag; 
  8.     public Ghost(int ghostx,int ghosty){
  9.      this.ghostx = ghostx;
  10.      this.ghosty =ghosty;
  11.     
  12.     }
  13.     
  14.     public void  GhostWalk(Graphics g)
  15. {
  16. /* if(ghostx==2)
  17. walky=54;
  18. else
  19. walky=158; */
  20. if(zw==0)
  21. {
  22. g.drawImage(HauntedCastle.casper1,ghostx+HauntedCastle.panx,ghosty,Graphics.TOP|Graphics.LEFT );
  23. ghostx-=5;
  24. zw++;
  25. }
  26. else if(zw==1)
  27. {
  28. g.drawImage(HauntedCastle.casper2,ghostx+HauntedCastle.panx,ghosty,Graphics.TOP|Graphics.LEFT );
  29. zw++;
  30. ghostx-=5;
  31. }
  32. else if(zw==2)
  33. {
  34. g.drawImage(HauntedCastle.casper1,ghostx+HauntedCastle.panx,ghosty,Graphics.TOP|Graphics.LEFT );
  35. zw++;
  36. ghostx-=5;
  37. }
  38. else
  39. if(zw==3)
  40. {
  41. g.drawImage(HauntedCastle.casper2,ghostx+HauntedCastle.panx,ghosty,Graphics.TOP|Graphics.LEFT );
  42. ghostx-=5;
  43. zw++;
  44. }
  45. else if(zw==4)
  46. {
  47. g.drawImage(HauntedCastle.casper1,ghostx+HauntedCastle.panx,ghosty,Graphics.TOP|Graphics.LEFT );
  48. zw++;
  49. ghostx-=5;
  50. }
  51. else if(zw==5)
  52. {
  53. g.drawImage(HauntedCastle.casper2,ghostx+HauntedCastle.panx,ghosty,Graphics.TOP|Graphics.LEFT );
  54. zw++;
  55. ghostx-=5;
  56. }
  57. else if(zw==6)
  58. {
  59. g.drawImage(HauntedCastle.casper1f,ghostx+HauntedCastle.panx,ghosty,Graphics.TOP|Graphics.LEFT );
  60. zw++;
  61. ghostx+=5;
  62. }
  63. else if(zw==7)
  64. {
  65. g.drawImage(HauntedCastle.casper2f,ghostx+HauntedCastle.panx,ghosty,Graphics.TOP|Graphics.LEFT );
  66. zw++;
  67. ghostx+=5;
  68. }
  69. else if(zw==8)
  70. {
  71. g.drawImage(HauntedCastle.casper1f,ghostx+HauntedCastle.panx,ghosty,Graphics.TOP|Graphics.LEFT );
  72. zw++;
  73. ghostx+=5;
  74. }
  75. else if(zw==9)
  76. {
  77. g.drawImage(HauntedCastle.casper2f,ghostx+HauntedCastle.panx,ghosty,Graphics.TOP|Graphics.LEFT );
  78. zw++;
  79. ghostx+=5;
  80. }
  81. else if(zw==10)
  82. {
  83. g.drawImage(HauntedCastle.casper1f,ghostx+HauntedCastle.panx,ghosty,Graphics.TOP|Graphics.LEFT );
  84. zw++;
  85. ghostx+=5;
  86. }
  87. else if(zw==11)
  88. {
  89. g.drawImage(HauntedCastle.casper2f,ghostx+HauntedCastle.panx,ghosty,Graphics.TOP|Graphics.LEFT );
  90. zw=0;
  91. ghostx+=5;
  92. }
  93. }
  94. public void  GhostDies(Graphics g)
  95. {
  96.    /* if(zombiy==2)
  97.     zombilevel=54;
  98.     else
  99.     zombilevel=158;*/
  100.        
  101.     if(zd==0)
  102.     {
  103.         g.drawImage(HauntedCastle.casper1,ghostx+HauntedCastle.panx,ghosty,Graphics.TOP|Graphics.LEFT );
  104. g.drawImage(HauntedCastle.fireblast1,ghostx+HauntedCastle.panx+5,ghosty+10,Graphics.TOP|Graphics.LEFT );
  105. zd++;
  106. }
  107. else if(zd==1)
  108. {
  109. g.drawImage(HauntedCastle.casper1,ghostx+HauntedCastle.panx,ghosty,Graphics.TOP|Graphics.LEFT );
  110. g.drawImage(HauntedCastle.fireblast2,ghostx+HauntedCastle.panx+5,ghosty+5,Graphics.TOP|Graphics.LEFT );
  111. g.drawImage(HauntedCastle.fireblast2,ghostx+HauntedCastle.panx+5,ghosty+15,Graphics.TOP|Graphics.LEFT );
  112. zd++;
  113. //ghostx-=2;
  114. }
  115. else if(zd==2)
  116. {
  117. g.drawImage(HauntedCastle.casper1,ghostx+HauntedCastle.panx,ghosty,Graphics.TOP|Graphics.LEFT );
  118. g.drawImage(HauntedCastle.fireblast3,ghostx+HauntedCastle.panx+5,ghosty,Graphics.TOP|Graphics.LEFT );
  119. g.drawImage(HauntedCastle.fireblast3,ghostx+HauntedCastle.panx+5,ghosty+25,Graphics.TOP|Graphics.LEFT );
  120. zd++;
  121. }
  122. else if(zd==3)
  123. {
  124. // g.drawImage(HauntedCastle.ghost1,ghostx+HauntedCastle.panx,ghosty,Graphics.TOP|Graphics.LEFT );
  125. g.drawImage(HauntedCastle.fireblast3,ghostx+HauntedCastle.panx+5,ghosty-5,Graphics.TOP|Graphics.LEFT );
  126. g.drawImage(HauntedCastle.fireblast3,ghostx+HauntedCastle.panx+5,ghosty+30,Graphics.TOP|Graphics.LEFT );
  127. zd++;
  128. }
  129. }
  130. }