Example #1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            Util.Initialize(this);

            map = new InfiniteEnemiesMap(25, 15);

            map.AddEntity(new Player(Content.Load<Texture2D>("Octocat"))
            {
                Position = new Vector2(200, 100),
                Width = 100,
                Height = 82,
                Source = new Rectangle(0, 0, 100, 82)
            });

            player = (Player)map.Entities[0];

            Weapon.ReloadSound = Content.Load<SoundEffect>("sounds/gun_reload");
            //Weapon.EmptyShootSound = Content.Load<SoundEffectInstance>("sounds/gun_empty_click");

            base.Initialize();
        }
Example #2
0
        public virtual bool Collides(Map map)
        {
            int x1 = CollisionBox.Left / map.TileSize;
            int y1 = CollisionBox.Top / map.TileSize;
            int x2 = CollisionBox.Right / map.TileSize;
            int y2 = CollisionBox.Bottom / map.TileSize;

            Tile t;

            for (int y = y1; y <= y2; y++)
            {
                for (int x = x1; x <= x2; x++)
                {
                    t = map.GetTile(x, y);
                    if (t != null && t.Color == Color.Red)
                    {
                        return true;
                    }
                }
            }
            return false;
        }