Guest User

Untitled

a guest
Oct 22nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.11 KB | None | 0 0
  1. package com
  2. {
  3. import org.flixel.*;
  4. import org.flixel.plugin.photonstorm.*;
  5. //Kuroki
  6.  
  7. public class RandomPainting extends FlxExtendedSprite
  8. {
  9.  
  10. [Embed(source = '../pics/apartmentA1.png')] public static var ap1:Class;
  11. [Embed(source = '../pics/apartmentA2.png')] public static var ap2:Class;
  12. [Embed(source = '../pics/apartmentA3.png')] public static var ap3:Class;
  13. [Embed(source = '../pics/apartmentA4.png')] public static var ap4:Class;
  14. [Embed(source = '../pics/apartmentA5.png')] public static var ap5:Class;
  15. [Embed(source = '../pics/apartmentA6.png')] public static var ap6:Class;
  16.  
  17. [Embed(source = '../pics/houseA1.png')] public static var hse1:Class;
  18. [Embed(source = '../pics/houseA2.png')] public static var hse2:Class;
  19. [Embed(source = '../pics/houseA3.png')] public static var hse3:Class;
  20. [Embed(source = '../pics/houseA4.png')] public static var hse4:Class;
  21. [Embed(source = '../pics/houseA5.png')] public static var hse5:Class;
  22. [Embed(source = '../pics/houseA6.png')] public static var hse6:Class;
  23.  
  24. [Embed(source = '../pics/towerA1.png')] public static var tow1:Class;
  25. [Embed(source = '../pics/towerA2.png')] public static var tow2:Class;
  26. [Embed(source = '../pics/towerA3.png')] public static var tow3:Class;
  27. [Embed(source = '../pics/towerA4.png')] public static var tow4:Class;
  28. [Embed(source = '../pics/towerA5.png')] public static var tow5:Class;
  29. [Embed(source = '../pics/towerA6.png')] public static var tow6:Class;
  30.  
  31.  
  32. //Formatting
  33. public var PlAYERSON:Boolean;
  34. public var PlAYERSOFF:Boolean;
  35.  
  36. public var IsAbused:Boolean;
  37. protected var _bits:FlxEmitter;
  38.  
  39. public var distributionp:int = 0;
  40.  
  41. public var DISH:int;
  42.  
  43.  
  44. //Movement
  45. private var vx:Number = 0;
  46.  
  47. private var maxspeedG:Number = 9;
  48. private var maxspeed:Number = 6;
  49. private var friction:Number = .92;
  50.  
  51.  
  52. public function RandomPainting(X:int, Y:int,Bits:FlxEmitter):void
  53. {
  54. super(X, Y);
  55.  
  56.  
  57. distributionp = Math.random() * 19;
  58. //distributionp = Math.random() * 0;
  59.  
  60. y = 280;
  61.  
  62. health = 90;
  63. this.immovable = true;
  64.  
  65.  
  66. FlxG.log("Painting - "+distributionp);
  67.  
  68.  
  69. //addAnimation("stopped", [0], 46);
  70. _bits = Bits;
  71. }
  72.  
  73.  
  74.  
  75. override public function update():void
  76. {
  77.  
  78. //Animation Still
  79. //play("stopped");
  80.  
  81. //Moving to the left
  82. x -= vx;
  83.  
  84. if (vx > maxspeed)
  85. vx = maxspeed;
  86. else if (vx < -maxspeed)
  87. vx = -maxspeed;
  88.  
  89. vx += .18;
  90.  
  91. vx *= friction;
  92.  
  93. //Give end piece a fair chance
  94. if (distributionp == 0)
  95. {
  96. distributionp += 1;
  97. }
  98.  
  99. //Apartments
  100. if (distributionp == 1)
  101. {
  102. loadGraphic(ap1, false, false, 64, 32);
  103. DISH = 32;
  104.  
  105. }
  106.  
  107. if (distributionp == 2)
  108. {
  109. loadGraphic(ap2, false, false, 96, 48);
  110. DISH = 48;
  111. }
  112.  
  113. if (distributionp == 3)
  114. {
  115. loadGraphic(ap3, false, false, 128, 64);
  116. DISH = 64;
  117. }
  118.  
  119. if (distributionp == 4)
  120. {
  121. loadGraphic(ap4, false, false, 64, 32);
  122. DISH = 32;
  123. }
  124.  
  125. if (distributionp == 5)
  126. {
  127. loadGraphic(ap5, false, false, 96, 48);
  128. DISH = 48;
  129. }
  130.  
  131. if (distributionp == 6)
  132. {
  133. loadGraphic(ap6, false, false, 96, 64);
  134. DISH = 64;
  135. }
  136.  
  137. //Houses
  138. if (distributionp == 7)
  139. {
  140. loadGraphic(hse1, false, false, 40, 56);
  141. DISH = 56;
  142. }
  143.  
  144. if (distributionp == 8)
  145. {
  146. loadGraphic(hse2, false, false, 40, 56);
  147. DISH = 56;
  148. }
  149.  
  150. if (distributionp == 9)
  151. {
  152. loadGraphic(hse3, false, false, 40, 96);
  153. DISH = 96;
  154. }
  155.  
  156. if (distributionp == 10)
  157. {
  158. loadGraphic(hse4, false, false, 40, 96);
  159. DISH = 96;
  160. }
  161.  
  162. if (distributionp == 11)
  163. {
  164. loadGraphic(hse5, false, false, 40, 144);
  165. DISH = 144;
  166. }
  167.  
  168. if (distributionp == 12)
  169. {
  170. loadGraphic(hse6, false, false, 40, 144);
  171. DISH = 144;
  172. }
  173.  
  174. //Towers
  175. if (distributionp == 13)
  176. {
  177. loadGraphic(tow1, false, false, 32, 56);
  178. DISH = 56;
  179. }
  180.  
  181. if (distributionp == 14)
  182. {
  183. loadGraphic(tow2, false, false, 32, 56);
  184. DISH = 56;
  185. }
  186.  
  187. if (distributionp == 15)
  188. {
  189. loadGraphic(tow3, false, false, 32, 96);
  190. DISH = 96;
  191. }
  192.  
  193. if (distributionp == 16)
  194. {
  195. loadGraphic(tow4, false, false, 32, 96);
  196. DISH = 96;
  197. }
  198.  
  199. if (distributionp == 17)
  200. {
  201. loadGraphic(tow5, false, false, 32, 144);
  202. DISH = 144;
  203. }
  204.  
  205. if (distributionp == 18)
  206. {
  207. loadGraphic(tow6, false, false, 32, 144);
  208. DISH = 144;
  209. }
  210.  
  211. //Give end piece a fair chance
  212. if (distributionp == 19)
  213. {
  214. distributionp - 1;
  215. }
  216.  
  217.  
  218. super.update();
  219.  
  220. //trace("Hi"+height);
  221. y = 280-DISH-16;
  222.  
  223.  
  224.  
  225. }
  226.  
  227. override public function destroy():void
  228. {
  229. super.destroy();
  230. _bits = null;
  231. }
  232.  
  233. override public function kill():void
  234. {
  235. if(!alive)
  236. return;
  237.  
  238. super.kill();
  239. visible = false;
  240. //velocity.make();
  241. //acceleration.make();
  242. if(_bits != null)
  243. {
  244. _bits.at(this);
  245. _bits.start(true,5,0,50);
  246. }
  247. }
  248. }
  249. }
Add Comment
Please, Sign In to add comment