Guest User

Untitled

a guest
Oct 21st, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.92 KB | None | 0 0
  1. package
  2. {
  3. import adobe.utils.CustomActions;
  4. import org.flixel.*;
  5.  
  6. public class TitleState extends FlxState
  7. {
  8. //[Embed (source = "../data/block/bg.png")] private var bg_img:Class;
  9. [Embed(source = "../data/font/visitor1.ttf", fontFamily = "BlockFont")] public var BlockFont:String;
  10.  
  11.  
  12. public const MAX_BULLETS:int = 300;
  13. public const MAX_BLOOD:int = 300;
  14. public const MAX_BONE:int = 300;
  15. public const MAX_SHARD:int = 300;
  16.  
  17. public const MAX_GUYS:int = 10;
  18.  
  19. public var slowmoverlay:FlxSprite = new FlxSprite (0,0);
  20.  
  21. public var cursor:FlxSprite;
  22. public var hellgate:Boolean = true;
  23.  
  24. public var bg:FlxSprite = new FlxSprite(0, 0);
  25. public var group_walls:FlxGroup = new FlxGroup();
  26. public var player:Player;
  27. //public var group_bullets:FlxGroup = new FlxGroup();
  28.  
  29. //public var group_shards:FlxGroup = new FlxGroup();
  30.  
  31. public var group_bones:FlxGroup = new FlxGroup();
  32.  
  33. public var group_guys:FlxGroup = new FlxGroup();
  34.  
  35. public var group_eyes:FlxGroup = new FlxGroup();
  36. public var group_eyeballs:FlxGroup = new FlxGroup();
  37. public var group_blocks:FlxGroup = new FlxGroup();
  38.  
  39. //public var group_blood:FlxGroup = new FlxGroup();
  40.  
  41.  
  42. public var timer:int = 60000;
  43.  
  44. //premade groups
  45. public var bulletGroup:FlxGroup;
  46. public var bloodGroup:FlxGroup;
  47. public var boneGroup:FlxGroup;
  48. public var shardGroup:FlxGroup;
  49.  
  50. public var dummy:Guy;
  51.  
  52. public var guyGroup:FlxGroup;
  53.  
  54.  
  55. public var gate_N:Gate;
  56. public var gate_E:Gate;
  57. public var gate_S:Gate;
  58. public var gate_W:Gate;
  59.  
  60. public var group_gates:FlxGroup = new FlxGroup();
  61.  
  62. public var group_gate_blockers:FlxGroup = new FlxGroup();
  63.  
  64.  
  65. public var group_hudtext:FlxGroup = new FlxGroup();
  66.  
  67. public var txtAmmo:FlxText;
  68. public var txtAmmoNumber:FlxText;
  69. public var txtScore:FlxText;
  70. public var txtScoreNumber:FlxText;
  71.  
  72. public var txtHighScore:FlxText;
  73.  
  74. public var txtLevel:FlxText;
  75. public var txtLevelNumber:FlxText;
  76.  
  77. public var paused:Boolean = false;
  78.  
  79. public var sidebar_R:SideBar;
  80. public var sidebar_L:SideBar;
  81.  
  82. public function TitleState()
  83. {
  84. super()
  85. }
  86.  
  87. public function makeGuy(x:int, y:int, hcolor:uint, bcolor:uint, zombie:Boolean):void
  88. {
  89. var s:Guy = guyGroup.getFirstAvailable() as Guy;
  90. if (s != null)
  91. {
  92. s.spawn(x, y, hcolor, bcolor, zombie);
  93. }
  94. }
  95.  
  96.  
  97. public function makeBullet(x:int, y:int, vx:Number, vy:Number, color:uint):void
  98. {
  99. var s:Bullet = bulletGroup.getFirstAvailable() as Bullet;
  100. if (s != null)
  101. {
  102. s.spawn(x, y, vx, vy, color);
  103. }
  104. }
  105. public function makeBlood(x:int, y:int, vx:Number, vy:Number, color:uint):void
  106. {
  107. var s:Blood = bloodGroup.getFirstAvailable() as Blood;
  108. if (s != null)
  109. {
  110. s.spawn(x, y, vx, vy, color);
  111. }
  112. }
  113. public function makeBone(x:int, y:int, vx:Number, vy:Number):void
  114. {
  115. var s:Bone = boneGroup.getFirstAvailable() as Bone;
  116. if (s != null)
  117. {
  118. s.spawn(x, y, vx, vy);
  119. }
  120. }
  121. public function makeShard(x:int, y:int, vx:Number, vy:Number, color:uint):void
  122. {
  123. var s:Shard = shardGroup.getFirstAvailable() as Shard;
  124. if (s != null)
  125. {
  126. s.spawn(x, y, vx, vy, color);
  127. }
  128. }
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. override public function create():void
  137. {
  138. super.create();
  139. bg.makeGraphic(400,400,0x000000)
  140. bg.color = 0x000000;
  141.  
  142. slowmoverlay.makeGraphic(400, 400, 0xffffffff);
  143. slowmoverlay.alpha = 0;
  144.  
  145. //premade groups
  146. bulletGroup = new FlxGroup();
  147. bloodGroup = new FlxGroup();
  148. boneGroup = new FlxGroup();
  149. shardGroup = new FlxGroup();
  150.  
  151. guyGroup = new FlxGroup();
  152.  
  153. /*
  154. for (var c:int = 0; c < MAX_BULLETS; c++)
  155. {
  156. bulletGroup.add(new Bullet());
  157. }
  158. */
  159. FlxG.stage.quality = "LOW";
  160.  
  161.  
  162. //outer walls
  163. for (var i:int = 0; i < 79; i++)
  164. {
  165. group_walls.add(new Wall((i * 4) + 40, 40));
  166. group_walls.add(new Wall((i * 4) + 44, 356));
  167. group_walls.add(new Wall(356, 40 + (i*4)));
  168. group_walls.add(new Wall(40, 44 + (i * 4)));
  169.  
  170. group_walls.add(new Wall(12, 40 + (i * 4)));
  171. group_walls.add(new Wall(384, 40 + (i*4)));
  172. }
  173.  
  174. //horizontal extra
  175. for (var j:int = 0; j < 10; j++)
  176. {
  177. group_walls.add(new Wall((j * 4), 40));
  178. group_walls.add(new Wall((j * 4)+360, 40));
  179. group_walls.add(new Wall((j * 4), 356));
  180. group_walls.add(new Wall((j * 4)+360, 356));
  181. }
  182.  
  183.  
  184.  
  185. //right sidebar:slowmo
  186.  
  187. sidebar_L = new SideBar(16, 44, 24, 312, 0, 0xff279ea5);
  188. sidebar_R = new SideBar(360, 44, 24, 312, 1, 0xffffa257);
  189.  
  190. //N Gate
  191. gate_N = new Gate(180, 60, "N");
  192. gate_E = new Gate(336, 180, "E");
  193. gate_S = new Gate(180, 336, "S");
  194. gate_W = new Gate(60, 180, "W");
  195.  
  196. player = new Player();
  197.  
  198. //player.health_color = 0x35d2dc;
  199. //player.fill_health();
  200. //player.block = new Block(player.x + 2, player.y + 2);
  201. //player.block.block_color = 0xff279ea5;
  202. //player.block.fill_block();
  203. //player.block.guy = player;
  204. //player.eye = new Eye(0, 0);
  205. //player.eyeball = new Eyeball(0, 0);
  206. sidebar_L.fill_bar();
  207.  
  208. //group_guys.add(player);
  209. //group_eyes.add(player.eye);
  210. //group_eyeballs.add(player.eyeball);
  211. //group_blocks.add(player.block);
  212.  
  213.  
  214. //group_bullets.add(player.group_bullets);
  215.  
  216.  
  217. txtAmmo = new FlxText(16, 360, 120, "AMMO:");
  218. txtAmmo.setFormat("BlockFont", 40);
  219. group_hudtext.add(txtAmmo);
  220.  
  221. txtAmmoNumber = new FlxText(128, 360, 120, String(player.ammo));
  222. txtAmmoNumber.setFormat("BlockFont", 40,0xffffff,"left");
  223. group_hudtext.add(txtAmmoNumber);
  224.  
  225.  
  226. txtScore = new FlxText(100, 0, 200, "SCORE:");
  227. txtScore.setFormat("BlockFont", 40,0xffffff,"center");
  228. group_hudtext.add(txtScore);
  229.  
  230. txtScoreNumber = new FlxText(240, 0, 150, String(player.score));
  231. txtScoreNumber.setFormat("BlockFont", 40, 0xffffff,"right");
  232. group_hudtext.add(txtScoreNumber);
  233.  
  234. txtHighScore = new FlxText(16, 0, 160, String(FlxG.high_score));
  235. txtHighScore.setFormat("BlockFont", 40, 0xffffff, "left");
  236. group_hudtext.add(txtHighScore);
  237.  
  238. txtLevel = new FlxText(220, 360, 150, "LEVEL:");
  239. txtLevel.setFormat("BlockFont", 40);
  240. group_hudtext.add(txtLevel);
  241.  
  242. txtLevelNumber = new FlxText(360, 360, 120, String(FlxG.block_level));
  243. txtLevelNumber.setFormat("BlockFont", 40);
  244. group_hudtext.add(txtLevelNumber);
  245.  
  246. //FlxG.timeScale = 1;
  247.  
  248. add(bg);
  249.  
  250. add(gate_N.group_gate);
  251. add(gate_E.group_gate);
  252. add(gate_S.group_gate);
  253. add(gate_W.group_gate);
  254.  
  255. add(group_walls);
  256.  
  257. add(sidebar_R);
  258. sidebar_R.fill_bar();
  259. add(sidebar_L);
  260. sidebar_L.fill_bar();
  261.  
  262. group_gate_blockers.add(new GateBlocker(40, 40));
  263. group_gate_blockers.add(new GateBlocker(320, 40));
  264. group_gate_blockers.add(new GateBlocker(40, 320));
  265. group_gate_blockers.add(new GateBlocker(320, 320));
  266.  
  267. add(group_gate_blockers);
  268.  
  269. add(gate_N);
  270. group_walls.add(gate_N.group_walls_a)
  271. group_walls.add(gate_N.group_walls_b)
  272. group_walls.add(gate_N.group_walls_c)
  273. group_walls.add(gate_N.group_walls_d)
  274.  
  275. add(gate_E);
  276. group_walls.add(gate_E.group_walls_a)
  277. group_walls.add(gate_E.group_walls_b)
  278. group_walls.add(gate_E.group_walls_c)
  279. group_walls.add(gate_E.group_walls_d)
  280.  
  281. add(gate_S);
  282. group_walls.add(gate_S.group_walls_a)
  283. group_walls.add(gate_S.group_walls_b)
  284. group_walls.add(gate_S.group_walls_c)
  285. group_walls.add(gate_S.group_walls_d)
  286.  
  287. add(gate_W);
  288. group_walls.add(gate_W.group_walls_a)
  289. group_walls.add(gate_W.group_walls_b)
  290. group_walls.add(gate_W.group_walls_c)
  291. group_walls.add(gate_W.group_walls_d)
  292.  
  293. add(group_hudtext);
  294.  
  295. //add(group_blood);
  296. add(bloodGroup);
  297. for (var e: int = 0; e < MAX_BLOOD; e++)
  298. {
  299. bloodGroup.add(new Blood());
  300. }
  301. add(boneGroup);
  302. for (var f: int = 0; f < MAX_BONE; f++)
  303. {
  304. boneGroup.add(new Bone());
  305. }
  306. add(shardGroup);
  307. for (var g: int = 0; g < MAX_SHARD; g++)
  308. {
  309. shardGroup.add(new Shard());
  310. }
  311.  
  312.  
  313. add(guyGroup);
  314. for (var h:int = 0; h < MAX_GUYS; h++)
  315. {
  316. var newguy:Guy = new Guy();
  317. guyGroup.add(newguy);
  318.  
  319. group_blocks.add(newguy.block);
  320. group_eyes.add(newguy.eye);
  321. group_eyeballs.add(newguy.eyeball);
  322. }
  323.  
  324.  
  325.  
  326. //player.spawn(64 + (Math.random() * 244), 64 + (Math.random() * 244), 0xff35d2dc, 0xff279ea5, false);
  327.  
  328. //add(group_guys);
  329. add(group_eyes);
  330. add(group_eyeballs);
  331. add(group_blocks);
  332.  
  333. //add(group_bullets);
  334.  
  335. //add(group_shards);
  336. //add(group_bones);
  337.  
  338. //new
  339. add(bulletGroup);
  340. for (var d: int = 0; d < MAX_BULLETS; d++)
  341. {
  342. bulletGroup.add(new Bullet());
  343. }
  344.  
  345.  
  346. cursor = new FlxSprite(0, 0);
  347. cursor.makeGraphic(12, 12, 0xffffff);
  348. cursor.drawLine(0, 1, 12, 1, 0xffffff, 2);
  349. cursor.drawLine(11, 0, 11, 12, 0xffffff, 2);
  350. cursor.drawLine(0, 11, 12, 11, 0xffffff, 2);
  351. cursor.drawLine(1, 0, 1, 12, 0xffffff, 2);
  352. cursor.alpha = 0.3;
  353. cursor.drawLine(5, 6, 7, 6, 0xffffff, 2);
  354. cursor.offset.x = 6;
  355. cursor.offset.y = 6;
  356. //FlxG.mouse.cursor = cursor;
  357. add(cursor);
  358.  
  359. //FlxG.mouse.show();
  360. FlxKongregate.init(apiHasLoaded);
  361.  
  362.  
  363. for (var a:int = 0; a < gate_N.num_walls; a++)
  364. {
  365. gate_N.group_gate.members[a].color = 0x05df05;
  366. }
  367.  
  368. for (var b:int = 0; b < gate_W.num_walls; b++)
  369. {
  370. gate_W.group_gate.members[b].color = 0xff0000;
  371. }
  372.  
  373. //dummy = new Guy(190, 190);
  374. //dummy.hits = 0;
  375.  
  376.  
  377.  
  378. add(slowmoverlay);
  379.  
  380.  
  381. makeGuy(64 + (Math.random() * 244), 64 + (Math.random() * 244), 0xffffa257, 0xffff3b3b, false);
  382.  
  383. }
  384.  
  385. public function move_dummy(dummy:Guy):void
  386. {
  387. if (Math.random() < .05)
  388. {
  389. dummy.dest_x = (Math.random() - .5) * 60;
  390. dummy.dest_y = (Math.random() - .5) * 60;
  391. }
  392. if (Math.random() < .05)
  393. {
  394. dummy.pushing_space = true;
  395. }
  396. if(Math.random() < .5)
  397. {
  398. dummy.pushing_space = false;
  399. }
  400.  
  401. if (Math.random() < .02)
  402. {
  403. if (Math.abs(dummy.dest_x) > 20 || Math.abs(dummy.dest_y) > 20)
  404. {
  405. dummy.shoot();
  406. }
  407. }
  408.  
  409.  
  410. }
  411.  
  412.  
  413. public function block_hit_guy(a:Block, b:Guy):void
  414. {
  415. if (b.block != a)
  416. {
  417. if (a.hit_timer == 0)
  418. {
  419. b.get_hit_by_block(a);
  420. FlxObject.separate(a, b);
  421. }
  422.  
  423. }
  424.  
  425. }
  426.  
  427.  
  428. public function vaporize(a:Guy,b:Wall):void
  429. {
  430. makeBullet(a.x, a.y + 10, 666, 0, 0xffff0000);
  431.  
  432. }
  433.  
  434.  
  435. public function check_goal(bullet:Bullet,wall:Wall):void
  436. {
  437. //trace(bullet.color,player.health_color)
  438. if (wall.color == 0x05df05 && bullet.color == 0x35d2dc)
  439. {
  440. player.score_points(50);
  441. }
  442. bullet.kill();
  443. }
  444.  
  445.  
  446.  
  447.  
  448. public function block_hit_block(a:Block, b:Block):void
  449. {
  450. a.guy.recoil_timer = 3;
  451. b.guy.recoil_timer = 3;
  452. }
  453.  
  454. public function bullet_collision(a:Bullet, b:Bullet):void
  455. {
  456. var shard_vy:int;
  457. var shard_vx:int;
  458. if (a.life_timer > 10 && b.life_timer > 6)
  459. {
  460. if (a.color == player.health_color && b.color == player.health_color)
  461. {
  462. player.score_points(25);
  463. }
  464.  
  465. for (var i:int = 0; i < 4; i++)
  466. {
  467. //var shardya:Shard = new Shard(a.x, a.y);
  468. shard_vx = ((a.velocity.x + b.velocity.x) / 2) * (Math.random() - .5);
  469. shard_vy = ((a.velocity.y + b.velocity.y) / 2) * (Math.random() - .5);
  470. if (shard_vx == 0)
  471. {
  472. shard_vx = 10*(Math.random() - .5);
  473. }
  474. if (shard_vy == 0)
  475. {
  476. shard_vy = 10*(Math.random() - .5);
  477. }
  478. //shardya.color = a.color;
  479. //group_shards.add(shardya);
  480.  
  481. makeShard(a.x, a.y, shard_vx, shard_vy, a.color);
  482.  
  483. }
  484.  
  485. for (var j:int = 0; j < 5;j++)
  486. {
  487. shard_vx = ((a.velocity.x + b.velocity.x) / 2) * (Math.random() - .5);
  488. shard_vy = ((a.velocity.y + b.velocity.y) / 2) * (Math.random() - .5);
  489. if (shard_vx == 0)
  490. {
  491. shard_vx = 10*(Math.random() - .5);
  492. }
  493. if (shard_vy == 0)
  494. {
  495. shard_vy = 10*(Math.random() - .5);
  496. }
  497. //shardya.color = a.color;
  498. //group_shards.add(shardya);
  499.  
  500. makeShard(b.x, b.y, shard_vx, shard_vy, b.color);
  501. }
  502. a.kill();
  503. b.kill();
  504. }
  505. }
  506.  
  507. public function block_hit_bullet(a:Block, b:Bullet):void
  508. {
  509. //b.color = a.guy.color;
  510. b.hit_block(a);
  511. }
  512.  
  513. public function bullet_hit_wall(a:Bullet, b:Wall):void
  514. {
  515. if (a.life_timer > 6)
  516. {
  517. //a.color = 0xffffff;
  518. }
  519.  
  520. }
  521.  
  522. public function bullet_hit_guy(a:Bullet, b:Guy):void
  523. {
  524. b.get_hit(a);
  525. }
  526.  
  527. public function bullet_hit_player(a:Bullet, b:Player):void
  528. {
  529. b.get_hit(a);
  530. }
  531.  
  532. public function pause_game():void
  533. {
  534. if (paused)
  535. {
  536. paused = false;
  537. }
  538. else
  539. {
  540. paused = true;
  541. }
  542. //trace(paused);
  543. }
  544.  
  545.  
  546. public function get_bone(a:Player,b:Bone):void
  547. {
  548. a.pickup_ammo();
  549. //a.slowmo += 10;
  550. //sidebar_L.fill_bar();
  551. b.kill();
  552. }
  553.  
  554.  
  555. public function move_gate_W():void
  556. {
  557. if (Math.random() > .99)
  558. {
  559. gate_W.velocity.y = (Math.random() - .5) * 200;
  560. }
  561. if (Math.random() > .99)
  562. {
  563. gate_W.acceleration.y = (Math.random() - .5) * 200;
  564. }
  565. if (gate_W.y < 60)
  566. {
  567. gate_W.velocity.y = Math.random() * 100;
  568. }
  569. if (gate_W.y > 332-gate_W.opening_width)
  570. {
  571. gate_W.velocity.y *= (Math.random() -1)* 100;
  572. }
  573. if (Math.random() > .87)
  574. {
  575. if (gate_W.y < 332 - gate_W.opening_width)
  576. {
  577. if(gate_W.opening_width < gate_W.max_width)
  578. {
  579. gate_W.opening_width += 1;
  580. }
  581. }
  582. }
  583. if (Math.random() > .9)
  584. {
  585. gate_W.opening_width -= 1;
  586. }
  587.  
  588. if (gate_W.velocity.y > 500)
  589. {
  590. gate_W.velocity.y = 500;
  591. }
  592. if (gate_W.velocity.y < -500)
  593. {
  594. gate_W.velocity.y = -500;
  595. }
  596.  
  597. //shoot
  598. if (Math.random() > .98 && hellgate==true)
  599. {
  600. for (var a:int = 0; a < gate_W.opening_width / 40; a++)
  601. {
  602. //var y_spawn:Number = gate_W.y +4 + (Math.random() * gate_W.opening_width - 4);
  603. /*
  604. var gate_shot:Bullet = new Bullet(gate_W.x-8, y_spawn);
  605. gate_shot.velocity.x = Math.random() * 200 + 100;
  606. gate_shot.velocity.y = gate_W.velocity.y + (gate_W.velocity.y * (Math.random() - .5));
  607. gate_shot.color = 0xff0000;
  608. group_bullets.add(gate_shot);
  609. */
  610. makeBullet(gate_W.x-8, gate_W.y +8 + (Math.random() * gate_W.opening_width - 4), Math.random() * 200 + 100, gate_W.velocity.y + (gate_W.velocity.y * (Math.random() - .5)), 0xff0000);
  611. //trace("bang");
  612. }
  613. }
  614.  
  615. }
  616.  
  617. public function move_gate_N():void
  618. {
  619. if (Math.random() > .99)
  620. {
  621. gate_N.velocity.x = (Math.random() - .5) * 200;
  622. }
  623. if (Math.random() > .99)
  624. {
  625. gate_N.acceleration.x = (Math.random() - .5) * 200;
  626. }
  627. if (gate_N.x < 60)
  628. {
  629. gate_N.velocity.x = Math.random() * 100;
  630. }
  631. if (gate_N.x > 332-gate_N.opening_width)
  632. {
  633. gate_N.velocity.x = (Math.random()-1)* 100;
  634. }
  635. if (Math.random() > .87)
  636. {
  637. if (gate_N.x < 332 - gate_N.opening_width)
  638. {
  639. if(gate_N.opening_width < gate_N.max_width)
  640. {
  641. gate_N.opening_width += 1;
  642. }
  643. }
  644. }
  645. if (Math.random() > .9)
  646. {
  647. gate_N.opening_width -= 1;
  648. }
  649.  
  650. if (gate_N.velocity.x > 500)
  651. {
  652. gate_N.velocity.x = 500;
  653. }
  654. if (gate_N.velocity.x < -500)
  655. {
  656. gate_N.velocity.x = -500;
  657. }
  658.  
  659. }
  660.  
  661. override public function update():void
  662. {
  663. //if (!FlxG.kong) (FlxG.kong = parent.addChild(new FlxKong()) as FlxKong).init();
  664.  
  665. timer -= FlxG.elapsed;
  666. if (timer % 20 == 0)
  667. {
  668. sidebar_R.fill_bar();
  669. }
  670.  
  671.  
  672. cursor.x = FlxG.mouse.screenX;
  673. cursor.y = FlxG.mouse.screenY;
  674.  
  675. super.update();
  676.  
  677.  
  678. if (player.life_timer < 60)
  679. {
  680. //FlxG.timeScale = 0.2;
  681. }
  682. else
  683. {
  684. if (!FlxG.keys.SHIFT || player.slowmo == 0)
  685. {
  686.  
  687. FlxG.timeScale = 1;
  688. }
  689. }
  690.  
  691.  
  692. for (var s:int = 0; s < guyGroup.members.length; s++)
  693. {
  694. if (guyGroup.members[s] != null)
  695.  
  696. {
  697. move_dummy(guyGroup.members[s]);
  698.  
  699. }
  700. }
  701.  
  702.  
  703. move_gate_W();
  704. move_gate_N();
  705.  
  706. //player.move_eye();
  707.  
  708. //ONE OR MORE OF THESE CALLS IS BREAKING THE GAME.
  709.  
  710. //FIX IT!
  711.  
  712. ///FlxG.overlap(guyGroup, gate_W.group_gate, vaporize);
  713.  
  714. ///FlxG.collide(guyGroup, group_walls);
  715. ///FlxG.collide(group_blocks, group_walls);
  716.  
  717. //FlxG.collide(group_blocks, group_bullets, block_hit_bullet);
  718.  
  719. ///FlxG.collide(group_blocks, bulletGroup, block_hit_bullet);
  720. FlxG.collide(bulletGroup, group_walls);
  721. ///FlxG.collide(bulletGroup, bulletGroup, bullet_collision);
  722.  
  723. ///FlxG.overlap(bulletGroup, guyGroup, bullet_hit_guy );
  724.  
  725. ///FlxG.overlap(group_blocks, guyGroup, block_hit_guy );
  726.  
  727. ////FlxG.overlap(bulletGroup, player, bullet_hit_player);
  728.  
  729. //////FlxG.collide(bulletGroup, gate_N.group_gate, check_goal);
  730. //////FlxG.collide(bulletGroup, gate_E.group_gate, check_goal);
  731. //////FlxG.collide(bulletGroup, gate_S.group_gate, check_goal);
  732. //FlxG.collide(bulletGroup, gate_W.group_gate, check_goal);
  733.  
  734. //FlxG.collide(group_bullets, group_walls, bullet_hit_wall );
  735. //FlxG.collide(group_bullets, group_bullets, bullet_collision);
  736. //FlxG.overlap(group_bullets, group_guys, bullet_hit_guy );
  737.  
  738.  
  739. /////FlxG.collide(shardGroup, group_walls);
  740. /////FlxG.collide(boneGroup, group_walls);
  741.  
  742. /////FlxG.collide(bloodGroup, group_walls);
  743.  
  744.  
  745. ////////FlxG.collide(guyGroup, guyGroup);
  746.  
  747. //FlxG.collide(group_guys, player);
  748.  
  749. ///////FlxG.collide(group_blocks, group_blocks);
  750.  
  751. //FlxG.collide(group_bullets, gate_N.group_gate, check_goal);
  752. //FlxG.collide(group_bullets, gate_E.group_gate, check_goal);
  753. //FlxG.collide(group_bullets, gate_S.group_gate, check_goal);
  754. //FlxG.collide(group_bullets, gate_W.group_gate, check_goal);
  755.  
  756.  
  757. ///////FlxG.collide(group_walls, group_gate_blockers);
  758.  
  759. //FlxG.overlap(player, boneGroup, get_bone);
  760.  
  761.  
  762. if (timer % 500 == 0)
  763. {
  764. makeGuy(64 + (Math.random() * 244), 64 + (Math.random() * 244), 0xffffa257, 0xffff3b3b, false);
  765. }
  766.  
  767.  
  768. if (FlxG.keys.justPressed("Q"))
  769. {
  770. FlxG.mode = 1;
  771. }
  772. if (FlxG.keys.justPressed("W"))
  773. {
  774. FlxG.mode = 2;
  775. }
  776. if (FlxG.keys.justPressed("E"))
  777. {
  778. FlxG.mode = 3;
  779. }
  780. if (FlxG.keys.justPressed("A"))
  781. {
  782. player.pickup_ammo();
  783. /*
  784. var olden_bullet:Bullet = new Bullet(Math.random()*400,Math.random()*400);
  785. olden_bullet.life_timer = 10;
  786. olden_bullet.velocity.x = (Math.random()-.5)*2000;
  787. olden_bullet.velocity.y = (Math.random() - .5) * 2000;
  788. olden_bullet.color = 0xff0000;
  789. group_bullets.add(olden_bullet);
  790.  
  791. makeBullet(gate_W.x - 8, y_spawn, Math.random() * 200 + 100, gate_W.velocity.y + (gate_W.velocity.y * (Math.random() - .5)), 0xff0000);
  792. */
  793. }
  794. if (FlxG.keys.justPressed("S") || player.hits == 0)
  795. {
  796. player.score_points(player.score * -1);
  797. player.spawn(64 + (Math.random() * 244), 64 + (Math.random() * 244), 0xff35d2dc, 0xff279ea5, false);
  798.  
  799. player.slowmo = player.max_slowmo;
  800.  
  801. sidebar_L.fill_bar();
  802. gate_W.opening_width = 30;
  803. gate_W.y = 160;
  804. gate_W.acceleration.y = 0;
  805. gate_W.acceleration.x = 0;
  806. gate_W.velocity.y = 0;
  807. gate_W.velocity.x = 0;
  808. gate_N.opening_width = 30;
  809. gate_N.x = 160;
  810. gate_N.acceleration.y = 0;
  811. gate_N.acceleration.x = 0;
  812. gate_N.velocity.y = 0;
  813. gate_N.velocity.x = 0;
  814. }
  815.  
  816. if (FlxG.keys.justPressed("D"))
  817. { /*
  818. var golden_bullet:Bullet = new Bullet(player.x, player.y);
  819. golden_bullet.life_timer = 10;
  820. golden_bullet.velocity.x = (Math.random()-.5)*2000;
  821. golden_bullet.velocity.y = (Math.random()-.5)*2000;
  822. group_bullets.add(golden_bullet);
  823. */
  824. //makeBullet(player.x, player.y, Math.random() * 200 + 100, gate_W.velocity.y + (gate_W.velocity.y * (Math.random() - .5)), 0xff0000);
  825. //player.die();
  826. }
  827.  
  828. if (FlxG.keys.justPressed("Z"))
  829. {
  830.  
  831. makeGuy(64 + (Math.random() * 244), 64 + (Math.random() * 244), 0xffffa257, 0xffff3b3b, true); //
  832. //FlxKongregate.submitStats("ShotsFired", player.shots_fired);
  833. //FlxG.kong.API.stats.submit("ShotsFired",player.shots_fired);
  834. }
  835.  
  836. if (FlxG.keys.justPressed("F"))
  837. {
  838.  
  839. makeGuy(64 + (Math.random() * 244), 64 + (Math.random() * 244), 0xffffa257, 0xffff3b3b, false); //
  840. //FlxKongregate.submitStats("ShotsFired", player.shots_fired);
  841. //FlxG.kong.API.stats.submit("ShotsFired",player.shots_fired);
  842. }
  843. if (FlxG.keys.justPressed("G"))
  844. {
  845.  
  846. makeGuy(332, 190, 0xffffa257, 0xffff3b3b, false); //
  847. //FlxKongregate.submitStats("ShotsFired", player.shots_fired);
  848. //FlxG.kong.API.stats.submit("ShotsFired",player.shots_fired);
  849. }
  850.  
  851. if (FlxG.keys.P)
  852. {
  853. //move gate
  854. gate_N.x += 1;
  855. //trace(timer);
  856. }
  857. if (FlxG.keys.O)
  858. {
  859. //move gate
  860. gate_N.x -= 1;
  861. }
  862. if (FlxG.keys.LBRACKET)
  863. {
  864. //move gate
  865. gate_N.opening_width -= 1;
  866. }
  867. if (FlxG.keys.RBRACKET)
  868. {
  869. //move gate
  870. gate_N.opening_width += 1;
  871. }
  872.  
  873. if (FlxG.keys.NUMPADEIGHT)
  874. {
  875. //move gate
  876. gate_E.y -= 1;
  877. }
  878. if (FlxG.keys.NUMPADTWO)
  879. {
  880. //move gate
  881. gate_E.y += 1;
  882. }
  883. if (FlxG.keys.NUMPADNINE)
  884. {
  885. //move gate
  886. gate_E.opening_width += 1;
  887. }
  888. if (FlxG.keys.NUMPADTHREE)
  889. {
  890. //move gate
  891. gate_E.opening_width -= 1;
  892. }
  893.  
  894.  
  895. if (FlxG.keys.NUMPADFOUR)
  896. {
  897. //move gate
  898. gate_S.x -= 1;
  899. }
  900. if (FlxG.keys.NUMPADSIX)
  901. {
  902. //move gate
  903. gate_S.x += 1;
  904. }
  905. if (FlxG.keys.NUMPADONE)
  906. {
  907. //shrink
  908. gate_S.opening_width -= 1;
  909. }
  910. if (FlxG.keys.NUMPADTHREE)
  911. {
  912. //widen
  913. gate_S.opening_width += 1;
  914. }
  915.  
  916.  
  917.  
  918.  
  919. if (FlxG.keys.justPressed("G"))
  920. {
  921. var gate_goal:Gate;
  922. var randgate:Number = Math.random();
  923. if (randgate > 0.666)
  924. {
  925. gate_goal = gate_N;
  926. }
  927. else if (randgate > 0.333)
  928. {
  929. gate_goal = gate_E;
  930. }
  931. else
  932. {
  933. gate_goal = gate_S;
  934. }
  935.  
  936. for (var g:int = 0; g < gate_goal.num_walls; g++)
  937. {
  938. gate_N.group_gate.members[g].color = 0xffffff;
  939. gate_E.group_gate.members[g].color = 0xffffff;
  940. gate_S.group_gate.members[g].color = 0xffffff;
  941. gate_goal.group_gate.members[g].color = 0x05df05;
  942. }
  943. if (hellgate)
  944. {
  945. hellgate = false;
  946. }
  947. else
  948. {
  949. hellgate = true;
  950. }
  951.  
  952. }
  953.  
  954.  
  955. if (FlxG.timeScale != 1)
  956. {
  957. slowmoverlay.alpha = 0.3;
  958. }
  959. else
  960. {
  961. slowmoverlay.alpha = 0;
  962. }
  963.  
  964.  
  965. }
  966.  
  967.  
  968. private function apiHasLoaded():void
  969. {
  970. FlxKongregate.connect();
  971. }
  972.  
  973.  
  974. public function start_game():void
  975. {
  976. //FlxG.state = new GameState();
  977. FlxG.switchState(new GameState());
  978. }
  979.  
  980. }
  981. }
Add Comment
Please, Sign In to add comment