Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package
- {
- import flash.display.Stage;
- import flash.events.MouseEvent;
- import net.flashpunk.FP;
- import net.flashpunk.graphics.Image;
- import net.flashpunk.utils.Draw;
- import net.flashpunk.World;
- import spaceShip.ShipModel;
- import flash.events.Event;
- import spaceShip.ShipView;
- import spaceShip.ShipController;
- import starField.StarFieldModel;
- import starField.StarFieldView;
- import flash.ui.Mouse;
- /**
- * ...
- * @author Joe Newbry
- */
- public class GameWorldView extends World
- {
- private var shipModel:ShipModel;
- private var shipView:ShipView;
- private var shipController:ShipController;
- private var starFieldView:StarFieldView;
- private var starFieldModel:StarFieldModel;
- public function GameWorldView(stage:Stage)
- {
- shipModel = new ShipModel();
- starFieldModel = new StarFieldModel();
- shipController = new ShipController(shipModel);
- shipView = new ShipView(shipModel, shipController);
- starFieldView = new StarFieldView(shipModel); // star doesn't need starfieldfield model becuase
- // this class just stores constants
- /*
- * add in paralax background
- * figure out how to draw shapes and add them as entities in flashpunk
- * parallax based on ships speed, with transition boost towards the end of the map
- * then add in the distance traveled tracker
- */
- //var myImage:Image = new Image(Draw.circle(100, 100, 0xfde222);
- // add player ship to the stage
- addStars();
- add(shipView);
- //add(myImage);
- //Position the player in the center of the stage
- shipModel.setX = 275;
- shipModel.setY = 200;
- // updates the model
- //mouseX = camera.x;
- //mouseY = camera.y;
- stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
- stage.addEventListener(MouseEvent.CLICK, onMouseClick);
- }
- override public function update():void
- {
- shipController.processFrame();
- shipModel.update();
- }
- public function onMouseMove(event:MouseEvent):void
- {
- shipModel.update();
- }
- private function onMouseClick(event:MouseEvent):void
- {
- }
- private function addStars():void
- {
- for (var i:uint = 0; i <starFieldModel.NUMBER_OF_STARS; i++)
- {
- var a:StarFieldView = new StarFieldView(shipModel);
- add(a);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment