コード例 #1
0
ファイル: Asteroid.cs プロジェクト: Stickypatrol/AsteroidShip
 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));
 }
コード例 #2
0
ファイル: Game1.cs プロジェクト: Stickypatrol/AsteroidShip
 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);
 }
コード例 #3
0
ファイル: Bullet.cs プロジェクト: Stickypatrol/AsteroidShip
 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));
 }
コード例 #4
0
ファイル: Bomb.cs プロジェクト: Stickypatrol/AsteroidShip
 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));
 }
コード例 #5
0
 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);
 }
コード例 #6
0
 public PlayerControls(Game1 _game)
 {
     game = _game;
     inputController = game.inputController;
     game.IsMouseVisible = false;
 }