public GamePage(string launchArguments) { this.InitializeComponent(); // Create the game. _game = XamlGame <CosmicRocksPartIIIGame> .Create(launchArguments, Window.Current.CoreWindow, this); }
//------------------------------------------------------------------------------------- // Class constructors and initialization functions internal BulletObject(CosmicRocksPartIIIGame game, Texture2D texture) : base(game, Vector2.Zero, texture) { // Store a strongly-typed reference to the game _game = game; // Set the origin to the top-center of the sprite Origin = new Vector2(texture.Width / 2, 0); }
//------------------------------------------------------------------------------------- // Class constructors internal StarObject(CosmicRocksPartIIIGame game, Texture2D texture) : base(game, Vector2.Zero, texture) { // Store a strongly-typed reference to the game _game = game; // Set a random position PositionX = GameHelper.RandomNext(0, _game.GraphicsDevice.Viewport.Bounds.Width); PositionY = GameHelper.RandomNext(0, _game.GraphicsDevice.Viewport.Bounds.Height); // Set the origin Origin = new Vector2(texture.Width, texture.Height) / 2; // Set the scale range _scaleMin = GameHelper.RandomNext(0.1f, 0.6f); _scaleMax = _scaleMin + GameHelper.RandomNext(0.1f, 0.4f); }
//------------------------------------------------------------------------------------- // Class constructors internal RockObject(CosmicRocksPartIIIGame game, Texture2D texture, int generation, float size, float speed) : base(game, Vector2.Zero, texture) { // Store a strongly-typed reference to the game _game = game; // Set a random position PositionX = GameHelper.RandomNext(0, _game.GraphicsDevice.Viewport.Bounds.Width); PositionY = GameHelper.RandomNext(0, _game.GraphicsDevice.Viewport.Bounds.Height); // Set the origin Origin = new Vector2(texture.Width, texture.Height) / 2; // Store the other constructor parameters _constructorSpeed = speed; _generation = generation; // Initialize the remainder of the rock properties InitializeRock(size); }
//------------------------------------------------------------------------------------- // Class constructors internal SpaceshipObject(CosmicRocksPartIIIGame game, Texture2D texture, Vector2 position) : base(game, position, texture) { // Store a strongly-typed reference to the game _game = game; // Set the origin Origin = new Vector2(texture.Width, texture.Height) / 2; // Set the scale Scale = new Vector2(0.2f, 0.2f); // We are not (yet) exploding ExplosionUpdateCount = 0; // Activate the shield _shieldTime = MaxShieldTime; // Create and initialise the thruster sound effect instance _thrusterSound = _game.SoundEffects["Thruster"].CreateInstance(); _thrusterSound.IsLooped = true; }