/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); skybox = new Skybox("Textures/Background1", Content); spriteFont = Content.Load <SpriteFont>("Fonts/Font1"); gameManager.RegisterModel(EntityType.Asteroid, new GameModel(GraphicsDevice, Content, "Models/asteroid")); //gameManager.RegisterModel(EntityType.Player, new GameModel(GraphicsDevice, Content, "Models/Ship")); gameManager.RegisterModel(EntityType.PlanetEarth, new GameModel(GraphicsDevice, Content, "Models/earth")); ShipEntity playerEntity = new ShipEntity(this, new Sphere(new BEPUutilities.Vector3(0, 10, 350), 1, 100)); playerEntity.SetScale(0.001f); cameraTarget = gameManager.RegisterEntity(playerEntity); PlanetEntity earthEntity = new PlanetEntity(this, EntityType.PlanetEarth, new Sphere(new BEPUutilities.Vector3(0, 0, -200), 225)); earthEntity.SetScale(50f); earthEntity.PhysicsEntity.AngularVelocity = MathConverter.Convert(new Vector3(0.005f, 0.001f, 0.001f)); earthEntity.PhysicsEntity.AngularDamping = 0f; gameManager.RegisterEntity(earthEntity); inputManager = new InputManager(this, gameManager, playerEntity); GenerateAsteroids(); textureRearviewMirror = Content.Load <Texture2D>("Textures/rearviewmirror"); textureRearviewMirrorMask = Content.Load <Texture2D>("Textures/rearviewmirror_mask"); textureSideviewMirrorLeft = Content.Load <Texture2D>("Textures/sideviewmirrorleft"); textureSideviewMirrorLeftMask = Content.Load <Texture2D>("Textures/sideviewmirrorleft_mask"); textureSideviewMirrorRight = Content.Load <Texture2D>("Textures/sideviewmirrorright"); textureSideviewMirrorRightMask = Content.Load <Texture2D>("Textures/sideviewmirrorright_mask"); rearviewMirrorMask = new Color[textureRearviewMirrorMask.Width * textureRearviewMirrorMask.Height]; sideviewMirrorLeftMask = new Color[textureSideviewMirrorLeftMask.Width * textureSideviewMirrorLeftMask.Height]; sideviewMirrorRightMask = new Color[textureSideviewMirrorRightMask.Width * textureSideviewMirrorRightMask.Height]; textureRearviewMirrorMask.GetData(rearviewMirrorMask); textureSideviewMirrorLeftMask.GetData(sideviewMirrorLeftMask); textureSideviewMirrorRightMask.GetData(sideviewMirrorRightMask); starfield = new Starfield(this, spriteBatch, Window.ClientBounds.Width, Window.ClientBounds.Height); InitializeCamera(); }
public InputManager(SpaceGame game, GameManager gameManager, ShipEntity playerEntity) { this.game = game; this.gameManager = gameManager; this.playerEntity = playerEntity; savedMousePosX = -1; savedMousePosY = -1; mouseSmoothingCache = new Vector2[MOUSE_SMOOTHING_CACHE_SIZE]; mouseSmoothingSensitivity = DEFAULT_MOUSE_SMOOTHING_SENSITIVITY; mouseIndex = 0; mouseMovement = new Vector2[2]; mouseMovement[0].X = 0.0f; mouseMovement[0].Y = 0.0f; mouseMovement[1].X = 0.0f; mouseMovement[1].Y = 0.0f; Rectangle clientBounds = game.Window.ClientBounds; Mouse.SetPosition(clientBounds.Width / 2, clientBounds.Height / 2); }