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

J2ME

开发平台:

Java

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