Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Microsoft.Xna.Framework;
- using Microsoft.Xna.Framework.Audio;
- using Microsoft.Xna.Framework.Content;
- using Microsoft.Xna.Framework.GamerServices;
- using Microsoft.Xna.Framework.Graphics;
- using Microsoft.Xna.Framework.Input;
- using Microsoft.Xna.Framework.Media;
- namespace SpaceInvaders
- {
- /// <summary>
- /// This is a game component that implements IUpdateable.
- /// </summary>
- public class MiniMap : Microsoft.Xna.Framework.DrawableGameComponent
- {
- private Game1 Game;
- private Texture2D original;
- private Texture2D minienemy;
- public List<Vector2> points;
- public MiniMap(Game game)
- : base(game)
- {
- // TODO: Construct any child components here
- this.Game = (Game1)game;
- }
- /// <summary>
- /// Allows the game component to perform any initialization it needs to before starting
- /// to run. This is where it can query for any required services and load content.
- /// </summary>
- public override void Initialize()
- {
- // TODO: Add your initialization code here
- original = Game.Content.Load<Texture2D>("minimap");
- minienemy = Game.Content.Load<Texture2D>("enemymini");
- points = new List<Vector2>();
- foreach (Enemy en in Game.enemies.enemies)
- {
- Vector2 point = new Vector2();
- point.X = (en.position.X / 4) + 300;
- point.Y = en.position.Y / 4;
- points.Add(point);
- }
- base.Initialize();
- }
- /// <summary>
- /// Allows the game component to update itself.
- /// </summary>
- /// <param name="gameTime">Provides a snapshot of timing values.</param>
- public override void Update(GameTime gameTime)
- {
- // TODO: Add your update code here
- for (int i = 0; i < Game.enemies.enemies.Count; i++)
- {
- Vector2 point = points.ElementAt(i);
- point.X = (Game.enemies.enemies.ElementAt(i).position.X / 4) + 300;
- point.Y = (Game.enemies.enemies.ElementAt(i).position.Y / 4);
- points[i] = point;
- }
- base.Update(gameTime);
- }
- public override void Draw(GameTime gameTime)
- {
- foreach (Vector2 point in points)
- {
- Game.spriteBatch.Draw(minienemy, point, Color.White);
- }
- base.Draw(gameTime);
- }
- }
- }
Add Comment
Please, Sign In to add comment