Ejemplo n.º 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));
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 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));
 }