Guest User

Untitled

a guest
Jun 18th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. package
  2. {
  3. import flash.display.Stage;
  4. import flash.events.MouseEvent;
  5. import net.flashpunk.FP;
  6. import net.flashpunk.graphics.Image;
  7. import net.flashpunk.utils.Draw;
  8. import net.flashpunk.World;
  9. import spaceShip.ShipModel;
  10. import flash.events.Event;
  11. import spaceShip.ShipView;
  12. import spaceShip.ShipController;
  13. import starField.StarFieldModel;
  14. import starField.StarFieldView;
  15. import flash.ui.Mouse;
  16.  
  17. /**
  18. * ...
  19. * @author Joe Newbry
  20. */
  21. public class GameWorldView extends World
  22. {
  23. private var shipModel:ShipModel;
  24. private var shipView:ShipView;
  25. private var shipController:ShipController;
  26. private var starFieldView:StarFieldView;
  27. private var starFieldModel:StarFieldModel;
  28.  
  29.  
  30. public function GameWorldView(stage:Stage)
  31. {
  32. shipModel = new ShipModel();
  33. starFieldModel = new StarFieldModel();
  34. shipController = new ShipController(shipModel);
  35. shipView = new ShipView(shipModel, shipController);
  36. starFieldView = new StarFieldView(shipModel); // star doesn't need starfieldfield model becuase
  37. // this class just stores constants
  38.  
  39.  
  40. /*
  41. * add in paralax background
  42. * figure out how to draw shapes and add them as entities in flashpunk
  43. * parallax based on ships speed, with transition boost towards the end of the map
  44. * then add in the distance traveled tracker
  45. */
  46.  
  47. //var myImage:Image = new Image(Draw.circle(100, 100, 0xfde222);
  48.  
  49. // add player ship to the stage
  50. addStars();
  51. add(shipView);
  52.  
  53. //add(myImage);
  54. //Position the player in the center of the stage
  55. shipModel.setX = 275;
  56. shipModel.setY = 200;
  57. // updates the model
  58. //mouseX = camera.x;
  59. //mouseY = camera.y;
  60. stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
  61. stage.addEventListener(MouseEvent.CLICK, onMouseClick);
  62. }
  63.  
  64. override public function update():void
  65. {
  66. shipController.processFrame();
  67. shipModel.update();
  68. }
  69. public function onMouseMove(event:MouseEvent):void
  70. {
  71. shipModel.update();
  72. }
  73. private function onMouseClick(event:MouseEvent):void
  74. {
  75.  
  76. }
  77. private function addStars():void
  78. {
  79. for (var i:uint = 0; i <starFieldModel.NUMBER_OF_STARS; i++)
  80. {
  81. var a:StarFieldView = new StarFieldView(shipModel);
  82. add(a);
  83. }
  84. }
  85.  
  86. }
  87.  
  88. }
Add Comment
Please, Sign In to add comment