Exemplo n.º 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()
        {
            // TODO: Add your initialization logic here

            base.Initialize();
            player = new Player(this, 100, 100, Weapon_Type.fist);//arme pour tester, amenée à être supprimée ?
        }
Exemplo n.º 2
0
 public void Reload(Weapon_Type weapon_type)
 {
     player = game.player;
     if (Keyboard.GetState().IsKeyDown(Keys.R))
     {
         player.Bullet_Number = Create_Clip(weapon_type);
     }
 }
Exemplo n.º 3
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()
        {
            // TODO: Add your initialization logic here

            base.Initialize();
            player = new Player(this, 100, 100, screenheight, screenwidth);
            player.Initialize();
        }
Exemplo n.º 4
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()
        {
            // TODO: Add your initialization logic here

            base.Initialize();
            player = new Player(this);
            bullet = new Bullet(this);
            weapon = new Weapons(this);
            Enemy_List = new List<Enemy>();
            enemy = new Enemy(this);
            player.Initialize();
            bullet.Initialize();
            enemy.Initialize();
        }
Exemplo n.º 5
0
        public void Update()
        {
            player = game.player;
            if (player.Bullet_List != null)
            {
                foreach (Bullet bullet in player.Bullet_List)
                {
                    bullet.position += bullet.velocity;
                    bullet.rec_ball.X = (int)bullet.position.X;
                    bullet.rec_ball.Y = (int)bullet.position.Y;
                    if (bullet.position.X > game.screenwidth || bullet.position.X < 0 || bullet.position.Y > game.screenheight || bullet.position.Y < 0)
                    {
                        bullet.is_visible = false;
                    }
                }

                for (int i = 0; i < player.Bullet_List.Count; i++) // Si la balle sort de l'écran, on la vire de la liste
                {
                    Bullet bullet = player.Bullet_List[i];
                    if (!bullet.is_visible)
                    {
                        player.Bullet_List.RemoveAt(i);
                        i--;
                    }
                }
            }
        }
Exemplo n.º 6
0
        public void Shoot(MouseState mouse, GameTime gameTime)
        {
            if (x < 0.1f)
            {
                x = x + (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            if (x >= 0.1f)
            {
                can_shoot = true;
            }
            player = game.player;
            if (mouse.LeftButton == ButtonState.Pressed && can_shoot)
              {
            Bullet new_bullet ;
            Vector2 position = new Vector2(player.Rec_Player.X, player.Rec_Player.Y);
            Vector2 distance;
            mouse = Mouse.GetState();

            if (player.Bullet_Number != 0)
            {
                new_bullet = new Bullet(game);
                player.Bullet_Number--;
                distance.X = mouse.X - new_bullet.Rec_ball.X;
                distance.Y = mouse.Y - new_bullet.Rec_ball.Y;
                new_bullet.Position = position;
                new_bullet.Velocity = new_bullet.Bullet_Speed(distance, mouse, new_bullet);
                new_bullet.Position = position + new_bullet.Velocity;
                new_bullet.Is_Visible = true;
                player.Bullet_List.Add(new_bullet);
                x = 0f;
                can_shoot = false;
            }
               }
            Reload(player.P_Weapon);
        }
Exemplo n.º 7
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()
 {
     // TODO: Add your initialization logic here
     base.Initialize();
     player = new Player(this);
     bullet = new Bullet(this);
     weapon = new Weapons(this);
     particle = new Particle(this);
     Enemy_List = new List<Enemy>();
     Particle_list = new List<Particle>();
     enemy = new Enemy(this);
     player.Initialize();
     bullet.Initialize();
     enemy.Initialize();
     camera = new Camera(GraphicsDevice.Viewport, this);
     map1 = new Map();
     map1.Generate(map1.Create_Map(0), 32);
 }