Ejemplo n.º 1
0
        /// <summary>
        /// Checks whether the rectangle of player touches the rectangle of any tile.
        /// </summary>
        /// <param name="player"></param>
        /// <param name="tile"></param>
        /// <returns></returns>
        private bool playerAndTileCollide(Player player, Tile tile)
        {
            Rectangle playerRect = new Rectangle((int)player.position.X, (int)player.position.Y, player.image.Width, player.image.Height);
            Rectangle tileRect = new Rectangle((int)tile.position.X, (int)tile.position.Y, tile.image.Width, tile.image.Height);

            return playerRect.Intersects(tileRect);
        }
Ejemplo 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);

            // Load images.
            backgroundImage = Content.Load<Texture2D>("background");
            player = new Player(Content.Load<Texture2D>("player"), new Vector2((GameConstants.WINDOW_WIDTH / 2) - (GameConstants.PLAYER_WIDTH / 2), GameConstants.WINDOW_HEIGHT - GameConstants.PLAYER_START_HEIGHT_OFFSET));
            energyBarTexture = Content.Load<Texture2D>("energy");

            fallingParticleTexture = Content.Load<Texture2D>("fallingparticle");

            // Load fonts.
            smallfont = Content.Load<SpriteFont>("smallfont");
            font = Content.Load<SpriteFont>("font");
            bigfont = Content.Load<SpriteFont>("bigfont");
            hugefont = Content.Load<SpriteFont>("hugefont");

            gameSong = Content.Load<Song>("gamesong");
            startPlayingGameSong();
            // Sound
            // soundEffect = Content.Load<SoundEffect>("gamesound.mp3");
            //  soundEffect.Play();
        }