Beispiel #1
0
 public Asteroid(Game1 _game, int side)
 {
     game = _game;
     tex = game.Content.Load<Texture2D>("asteroid");
     if (side == -1) { side = rand.Next(0, 4); };
     if (side == 0)
     {
         position = new Vector2(-100, (int)(rand.NextDouble() * game.GraphicsDevice.Viewport.Height));//move right
         speed = new Vector2((float)rand.NextDouble() * rand.Next(1, 5)+1, (float)rand.NextDouble() * rand.Next(-3, 2)+1);
     }
     else if (side == 1)
     {
         position = new Vector2(game.GraphicsDevice.Viewport.Width+100, (int)(rand.NextDouble() * game.GraphicsDevice.Viewport.Height));
         speed = new Vector2((float)rand.NextDouble() * rand.Next(-4, 0), (float)rand.NextDouble() * rand.Next(-3, 2));//move left
     }
     else if(side == 2)
     {
         position = new Vector2((int)(rand.NextDouble() * game.GraphicsDevice.Viewport.Width), -100);//move down
         speed = new Vector2((float)rand.NextDouble() * rand.Next(-3, 2), (float)rand.NextDouble() * rand.Next(1, 5));
     }
     else if(side == 3)
     {
         position = new Vector2((int)(rand.NextDouble() * game.GraphicsDevice.Viewport.Width), game.GraphicsDevice.Viewport.Height+100);
         speed = new Vector2((float)rand.NextDouble() * rand.Next(-3, 2), (float)rand.NextDouble() * rand.Next(-4, 0));//move up
     }
     rotation = (float)rand.NextDouble();
     sourceRect = new Rectangle(0, 0, tex.Width, tex.Height);
     scale = 1f;
     origin = new Vector2(tex.Width / 2, tex.Height / 2);
     inputController = game.inputController;
     objectController = game.objectController;
     radius = (float)Math.Sqrt(Math.Pow(tex.Height, 2) + Math.Pow(tex.Width, 2));
 }
Beispiel #2
0
 protected override void LoadContent()
 {
     cursorTex = Content.Load<Texture2D>("cursortex");
     //initiate controllers and the world
     objectController = new ObjectController(this);
     inputController = new InputController(this);
     playerControls = new PlayerControls(this);
     levelController = new LevelController(this);
     //soundController = new SoundController(this);
     world = new World(this);
     spriteBatch = new SpriteBatch(GraphicsDevice);
 }
Beispiel #3
0
 public Bullet(Game1 _game, Vector2 direction, Vector2 offset, Vector2 _position)
 {
     game = _game;
     tex = game.Content.Load<Texture2D>("bullet");
     position = _position + offset;
     rotation = 0f;
     sourceRect = new Rectangle(0, 0, tex.Width, tex.Height);
     scale = 1f;
     origin = new Vector2(tex.Width / 2, tex.Height / 2);
     speed = new Vector2(direction.X/8, direction.Y/8);
     inputController = game.inputController;
     objectController = game.objectController;
     radius = (float)Math.Sqrt(Math.Pow(tex.Height, 2) + Math.Pow(tex.Width, 2));
 }
Beispiel #4
0
 public Bomb(Game1 _game, Vector2 direction)
 {
     game = _game;
     tex = game.Content.Load<Texture2D>("Bomb");
     position = new Vector2(game.GraphicsDevice.Viewport.Width / 2, game.GraphicsDevice.Viewport.Height / 2);
     rotation = 0f;
     sourceRect = new Rectangle(0, 0, tex.Width, tex.Height);
     scale = 1f;
     origin = new Vector2(tex.Width / 2, tex.Height / 2);
     speed = new Vector2(direction.X / 8, direction.Y / 8);
     inputController = game.inputController;
     objectController = game.objectController;
     time = 0;
     radius = (float)Math.Sqrt(Math.Pow(tex.Height, 2) + Math.Pow(tex.Width, 2));
 }
 public ObjectController(Game1 _game)
 {
     game = _game;
     inputController = game.inputController;
     basespeed = new Vector2(0, 0);
     entityList = new List<Entity>();
     cleanList = new List<int>();
     points = 0;
     highscore = 0;
     verdana = game.Content.Load<SpriteFont>("Verdana");
     countDown = "";
     levelType = "";
     weaponMode = 1;
     ship = new Ship(game, new Vector2(game.GraphicsDevice.Viewport.Width / 2, game.GraphicsDevice.Viewport.Height / 2), 0f);
     gun = new Gun(game, new Vector2(game.GraphicsDevice.Viewport.Width / 2, game.GraphicsDevice.Viewport.Height / 2));
     entityList.Add(ship);
     entityList.Add(gun);
 }
 public PlayerControls(Game1 _game)
 {
     game = _game;
     inputController = game.inputController;
     game.IsMouseVisible = false;
 }