Esempio n. 1
0
        /// <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);

            // TODO: use this.Content to load your game content here
            texture = Content.Load<Texture2D>("gamepad.png");
			caracter = Content.Load<Texture2D>("monogameicon");
			font = Content.Load<SpriteFont>("font");
			
			// Set the virtual GamePad
			ButtonDefinition BButton = new ButtonDefinition();
			BButton.Texture = texture;
			BButton.Position = new Vector2(200,150);
			BButton.Type = Buttons.B;
			BButton.TextureRect = new Rectangle(72,77,36,36);
			
			ButtonDefinition AButton = new ButtonDefinition();
			AButton.Texture = texture;
			AButton.Position = new Vector2(150,150);
			AButton.Type = Buttons.A;
			AButton.TextureRect = new Rectangle(73,114,36,36);
			
			GamePad.ButtonsDefinitions.Add(BButton);
			GamePad.ButtonsDefinitions.Add(AButton);
			
			ThumbStickDefinition thumbStick = new ThumbStickDefinition();
			thumbStick.Position = new Vector2(200,200);
			thumbStick.Texture = texture;
			thumbStick.TextureRect = new Rectangle(2,2,68,68);
			
			GamePad.LeftThumbStickDefinition = thumbStick;
        }
Esempio n. 2
0
        /// <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);

            // TODO: use this.Content to load your game content here
            Services.AddService(typeof(SpriteBatch), spriteBatch);

			// Setup virtual gamepad
			gamepadTexture = Content.Load<Texture2D>("gamepad.png");  
			ButtonDefinition BButton = new ButtonDefinition();
			BButton.Texture = gamepadTexture;
			BButton.Position = new Vector2(100,420);
			BButton.Type = Buttons.Back;
			BButton.TextureRect = new Rectangle(72,77,36,36);
			
			ButtonDefinition AButton = new ButtonDefinition();
			AButton.Texture = gamepadTexture;
			AButton.Position = new Vector2(150,420);
			AButton.Type = Buttons.A;
			AButton.TextureRect = new Rectangle(73,114,36,36);
			
			GamePad.ButtonsDefinitions.Add(BButton);
			GamePad.ButtonsDefinitions.Add(AButton);
			
			ThumbStickDefinition thumbStick = new ThumbStickDefinition();
			thumbStick.Position = new Vector2(220,400);
			thumbStick.Texture = gamepadTexture;
			thumbStick.TextureRect = new Rectangle(2,2,68,68);	
			GamePad.LeftThumbStickDefinition = thumbStick;
			
            // Create the audio bank
            audio = new AudioLibrary(Content);
            Services.AddService(typeof(AudioLibrary), audio);
			
            // Create the Start Scene
            smallFont = Content.Load<SpriteFont>("menuSmall");
			largeFont = Content.Load<SpriteFont>("menuLarge");
			startElementsTexture = Content.Load<Texture2D>("startsceneelements.png");            
            startBackgroundTexture = Content.Load<Texture2D>("startbackground");
            startScene = new StartScene(this, smallFont, largeFont,startBackgroundTexture, startElementsTexture);
            Components.Add(startScene);
			
            // Start the game in the start Scene :)
            startScene.Show();
            activeScene = startScene;
        }
Esempio n. 3
0
		/// <summary>
		/// Load your content.
		/// </summary>
		protected override void LoadContent ()
		{
			spriteBatch = new SpriteBatch (GraphicsDevice);

			font = Content.Load<SpriteFont> ("Font");

#if ANDROID || IPHONE
			gamePadTexture = Content.Load<Texture2D>("gamepad.png");
			
			ThumbStickDefinition thumbStickLeft = new ThumbStickDefinition();
			thumbStickLeft.Position = new Vector2(10,400);
			thumbStickLeft.Texture = gamePadTexture;
			thumbStickLeft.TextureRect = new Rectangle(2,2,68,68);
			
			GamePad.LeftThumbStickDefinition = thumbStickLeft;
			
			ThumbStickDefinition thumbStickRight = new ThumbStickDefinition();
			thumbStickRight.Position = new Vector2(240,400);
			thumbStickRight.Texture = gamePadTexture;
			thumbStickRight.TextureRect = new Rectangle(2,2,68,68);
			
			GamePad.RightThumbStickDefinition = thumbStickRight;
#endif
		}
Esempio n. 4
0
		private void RenderThumbStick(ThumbStickDefinition theStick, SpriteBatch batch)
		{
			if (batch == null)
			{
				throw new InvalidOperationException("SpriteBatch not set.");
			}
			batch.Draw(theStick.Texture,theStick.Position + theStick.Offset,theStick.TextureRect,_alphaColor);
		}
Esempio n. 5
0
 private bool CheckThumbStickHit(ThumbStickDefinition theStick, Vector2 location)
 {
     Vector2 stickPosition = theStick.Position + theStick.Offset;
     Rectangle thumbRect = new Rectangle((int)stickPosition.X, (int)stickPosition.Y, theStick.TextureRect.Width, theStick.TextureRect.Height);
     return thumbRect.Contains((int)location.X, (int)location.Y);
 }
        /// <summary>
        /// Load graphics content for the game.
        /// </summary>
        public override void LoadContent()
        {
            if (content == null)
            {
                content = new ContentManager(ScreenManager.Game.Services, "Content");
            }
            spriteBatch = new SpriteBatch(ScreenManager.GraphicsDevice);
            lineBatch = new LineBatch(ScreenManager.GraphicsDevice);
            spriteFont = content.Load<SpriteFont>("Fonts/retroSmall");
            starTexture = content.Load<Texture2D>("Textures/blank");

            // update the projection in the line-batch
            lineBatch.SetProjection(Matrix.CreateOrthographicOffCenter(0.0f,
                ScreenManager.GraphicsDevice.Viewport.Width,
                ScreenManager.GraphicsDevice.Viewport.Height, 0.0f, 0.0f, 1.0f));
            #if ANDROID || IOS
            gamePadTexture = content.Load<Texture2D>("Textures/gamepad");

            ThumbStickDefinition thumbStickLeft = new ThumbStickDefinition();
            thumbStickLeft.Position = new Vector2(10,400);
            thumbStickLeft.Texture = gamePadTexture;
            thumbStickLeft.TextureRect = new Rectangle(2,2,68,68);

            GamePad.LeftThumbStickDefinition = thumbStickLeft;

            ThumbStickDefinition thumbStickRight = new ThumbStickDefinition();
            thumbStickRight.Position = new Vector2(240,400);
            thumbStickRight.Texture = gamePadTexture;
            thumbStickRight.TextureRect = new Rectangle(2,2,68,68);

            GamePad.RightThumbStickDefinition = thumbStickRight;
            #endif
        }
Esempio n. 7
0
        /// <summary>
        /// Loads graphics content for this screen. The background texture is quite
        /// big, so we use our own local ContentManager to load it. This allows us
        /// to unload before going from the menus into the game itself, wheras if we
        /// used the shared ContentManager provided by the Game class, the content
        /// would remain loaded forever.
        /// </summary>
        public override void LoadContent()
        {
            title = ScreenManager.Game.Content.Load<Texture2D>("title");
            background = ScreenManager.Game.Content.Load<Texture2D>("background");
            // Setup virtual gamepad
            gamepadTexture = ScreenManager.Game.Content.Load<Texture2D>("gamepad");
            ButtonDefinition BButton = new ButtonDefinition();
            BButton.Texture = gamepadTexture;
            BButton.Position = new Vector2(270,240);
            BButton.Type = Buttons.Back;
            BButton.TextureRect = new Rectangle(72,77,36,36);

            ButtonDefinition AButton = new ButtonDefinition();
            AButton.Texture = gamepadTexture;
            AButton.Position = new Vector2(30,420);
            AButton.Type = Buttons.A;
            AButton.TextureRect = new Rectangle(73,114,36,36);

            GamePad.ButtonsDefinitions.Add(BButton);
            GamePad.ButtonsDefinitions.Add(AButton);

            ThumbStickDefinition thumbStick = new ThumbStickDefinition();
            thumbStick.Position = new Vector2(220,400);
            thumbStick.Texture = gamepadTexture;
            thumbStick.TextureRect = new Rectangle(2,2,68,68);

            GamePad.LeftThumbStickDefinition = thumbStick;
        }
Esempio n. 8
0
        /// <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);
            AwesomeAsteroid = ObjModelLoader.LoadFromFile("Models/rock.obj");
            asteroid = Texture2D.FromFile(graphics.GraphicsDevice,"Models/rock.jpg",256,256);

            gamePadTexture = Content.Load<Texture2D> ("gamepad.png");
            var ship1t = gameType == GameType.Retro ? "Content/Retro/ship.pdf" : "Content/ship.pdf";
            var ship2t = gameType == GameType.Retro ? "Content/Retro/ship.pdf" : "Content/ship-thrust.pdf";
            var ship1 = Texture2D.FromFile(graphics.GraphicsDevice,ship1t,35,35);
            var ship2 = Texture2D.FromFile(graphics.GraphicsDevice,ship2t,35,35);
            ship = new Ship (ship1,ship2);
            //ship.Scale = .05f;
            bullet = new Sprite (Content.Load<Texture2D> ("shot-frame1"));
            //bullet.Scale = .05f;
            ReloadAsteroids();

            myFont = Content.Load<SpriteFont> ("Fonts/SpriteFont1");

            banner = Content.Load<Texture2D> ("BANNER");

            var gamePadH = ScreenHeight - 100;
            var gamePadLeft = ScreenWidth -80;
            //Console.WriteLine (gamePadH);
            // Set the virtual GamePad
            ButtonDefinition BButton = new ButtonDefinition ();
            BButton.Texture = gamePadTexture;
            BButton.Position = new Vector2 (gamePadLeft, gamePadH + 10);
            BButton.Type = Buttons.B;
            BButton.TextureRect = new Rectangle (72, 77, 36, 36);

            ButtonDefinition AButton = new ButtonDefinition ();
            AButton.Texture = gamePadTexture;
            AButton.Position = new Vector2 (gamePadLeft - 75, gamePadH + 10);
            AButton.Type = Buttons.A;
            AButton.TextureRect = new Rectangle (73, 114, 36, 36);

            GamePad.ButtonsDefinitions.Add (BButton);
            GamePad.ButtonsDefinitions.Add (AButton);

            ThumbStickDefinition thumbStick = new ThumbStickDefinition ();
            thumbStick.Position = new Vector2 (50, gamePadH);
            thumbStick.Texture = gamePadTexture;
            thumbStick.TextureRect = new Rectangle (2, 2, 68, 68);

            GamePad.LeftThumbStickDefinition = thumbStick;
        }
Esempio n. 9
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        public override void LoadContent()
        {
            ScreenWidth = ScreenManager.Width;
            ScreenHeight = ScreenManager.Height;
            gameType = Settings.GameType;
            useAccel = Settings.UseAccel;
            if (Content == null)
                Content = new ContentManager (ScreenManager.Game.Services, "Content");
            // Create a new SpriteBatch, which can be used to draw textures.
            //spriteBatch = ScreenManager.SpriteBatch;
            //AwesomeAsteroid = ObjModelLoader.LoadFromFile ("Models/rock.obj");
            //asteroid = Texture2D.FromFile (ScreenManager.GraphicsDevice, "Models/rock.jpg", 256, 256);
            pauseButtonTexture = Content.Load<Texture2D> ("pause.png");
            var ship1t = gameType == GameType.Retro ? "Content/Retro/ship.pdf" : "Content/ship.pdf";
            var ship2t = gameType == GameType.Retro ? "Content/Retro/ship.pdf" : "Content/ship-thrust.pdf";
            var ship1 = Texture2D.FromFile (ScreenManager.GraphicsDevice, ship1t, 35, 35);
            var ship2 = Texture2D.FromFile (ScreenManager.GraphicsDevice, ship2t, 35, 35);
            ship = new Ship (ship1, ship2);
            freeManSprite = new Sprite (ship2);
            //ship.Scale = .05f;
            bullet = new Sprite (Content.Load<Texture2D> ("shot-frame1"));
            //bullet.Scale = .05f;
            ReloadAsteroids ();

            myFont = Content.Load<SpriteFont> ("Fonts/SpriteFont1");

            alienFired = ScreenManager.Game.Content.Load<SoundEffect> ("fire");
            alienDied = ScreenManager.Game.Content.Load<SoundEffect> ("Alien_Hit");
            playerFired = ScreenManager.Game.Content.Load<SoundEffect> ("fire");
            playerDied = ScreenManager.Game.Content.Load<SoundEffect> ("Player_Hit");

            //Console.WriteLine (gamePadLeft);
            // Set the virtual GamePad
            GamePad.ButtonsDefinitions.Clear ();
            var gamePadH = ScreenHeight - 100;
            var gamePadLeft = ScreenWidth - 80;

            ButtonDefinition XButton = new ButtonDefinition ();
            XButton.Texture = pauseButtonTexture;
            XButton.Position = new Vector2 (gamePadLeft, 0 + 10 + (int)myFont.FontSize + 10);
            XButton.Type = Buttons.X;
            XButton.TextureRect = new Rectangle (0, 0, 30, 30);
            GamePad.ButtonsDefinitions.Add (XButton);

            if (!useAccel) {
                //Setup the controller if they are not using the accelerometer
                gamePadTexture = Content.Load<Texture2D> ("gamepad.png");
                //leftButtonTexture = Content.Load<Texture2D>("leftArrow.png");
                //rightButtonTexture = Content.Load<Texture2D>("rightArrow.png");
                //upButtonTexture = Content.Load<Texture2D>("upArrow.png");
                //ButtonDefinition left = new ButtonDefinition();
                //Console.WriteLine (gamePadH);
                // Set the virtual GamePad
                                /*
                ButtonDefinition BButton = new ButtonDefinition ();
                BButton.Texture = gamePadTexture;
                BButton.Position = new Vector2 (gamePadLeft, gamePadH + 10);
                BButton.Type = Buttons.B;
                BButton.TextureRect = new Rectangle (72, 77, 36, 36);

                ButtonDefinition AButton = new ButtonDefinition ();
                AButton.Texture = gamePadTexture;
                AButton.Position = new Vector2 (gamePadLeft - 75, gamePadH + 10);
                AButton.Type = Buttons.A;
                AButton.TextureRect = new Rectangle (73, 114, 36, 36);

                ButtonDefinition LeftButton = new ButtonDefinition();
                LeftButton.Texture = leftButtonTexture;
                LeftButton.Position = new Vector2(50,gamePadH);
                LeftButton.Type = Buttons.DPadLeft;
                LeftButton.TextureRect = new Rectangle(0,0,40,40);

                ButtonDefinition RightButton = new ButtonDefinition();
                RightButton.Texture = rightButtonTexture;
                RightButton.Position = new Vector2(50 + 40 +4,gamePadH);
                RightButton.Type = Buttons.DPadRight;
                RightButton.TextureRect = new Rectangle(0,0,40,40);

                ButtonDefinition UpButton = new ButtonDefinition();
                UpButton.Texture = upButtonTexture;
                UpButton.Position = new Vector2(50 + 22,gamePadH - 44);
                UpButton.Type = Buttons.DPadUp;
                UpButton.TextureRect = new Rectangle(0,0,40,40);

                GamePad.ButtonsDefinitions.Add(LeftButton);
                GamePad.ButtonsDefinitions.Add(RightButton);
                GamePad.ButtonsDefinitions.Add(UpButton);
                GamePad.ButtonsDefinitions.Add (BButton);
                GamePad.ButtonsDefinitions.Add (AButton);
                */

                ThumbStickDefinition thumbStick = new ThumbStickDefinition ();
                thumbStick.Position = new Vector2 (50, gamePadH);
                thumbStick.Texture = gamePadTexture;
                thumbStick.TextureRect = new Rectangle (2, 2, 68, 68);

                GamePad.LeftThumbStickDefinition = thumbStick;

            } else {
                GamePad.LeftThumbStickDefinition = null;
            }
            SetupGame ();

            if (gameType != GameType.Retro)
                particles = new ParticleSystem (ScreenManager.Game.Content, ScreenManager.SpriteBatch);
            ScreenManager.Game.ResetElapsedTime ();
        }