コード例 #1
0
ファイル: Game1.cs プロジェクト: Catchouli-old/Graveroids
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (!Keyboard.GetState().IsKeyDown(Keys.Escape) && _keyboardStatePrevious.IsKeyDown(Keys.Escape))
            {
                if (_gameState == GameState.MENU)
                    this.Exit();
                else
                    _gameState = GameState.MENU;
            }

            switch (_gameState)
            {
                case GameState.MENU:
                    if (Mouse.GetState().LeftButton == ButtonState.Released && _mouseStatePrevious.LeftButton == ButtonState.Pressed)
                    {
                        if (_mouseStatePrevious.X > 521 && _mouseStatePrevious.Y > 321 && _mouseStatePrevious.X < 618 && _mouseStatePrevious.Y < 370)
                        {
                            _planets.Clear();
                            _objects.Clear();
                            _projectiles.Clear();
                            _player = new Player(_rocket);
                            stationHealth = 100;
                            stationRepair = 100;
                            resources[0] = 0;
                            resources[1] = 0;
                            resources[2] = 0;
                            respawnTimer = 0;
                            _station = new SpaceStation(_stationTexture);
                            _objects.Add(_player);
                            _objects.Add(_station);
                            livesLeft = 3;
                            score = 0;
                            _gameState = GameState.PLAY;
                        }
                        else if (_mouseStatePrevious.X > 523 && _mouseStatePrevious.Y > 371 && _mouseStatePrevious.X < 614 && _mouseStatePrevious.Y < 418)
                        {
                            this.Exit();
                        }
                    }
                    break;
                case GameState.PLAY:
                    UpdateGame(gameTime);
                    break;
                case GameState.GAMEOVER:
                    if (Keyboard.GetState().IsKeyDown(Keys.Enter))
                        _gameState = GameState.MENU;
                    break;
                default:
                    this.Exit();
                    break;
            }

            // TODO: Add your update logic here
            _mouseStatePrevious = Mouse.GetState();
            _keyboardStatePrevious = Keyboard.GetState();

            base.Update(gameTime);
        }
コード例 #2
0
ファイル: Game1.cs プロジェクト: Catchouli-old/Graveroids
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            _circle = Content.Load<Texture2D>("circle");
            _fourpx = Content.Load<Texture2D>("fourpx");
            _square = Content.Load<Texture2D>("square");
            _rocket = Content.Load<Texture2D>("rocket");
            _starfield = Content.Load<Texture2D>("starfield");
            _needle = Content.Load<Texture2D>("needle");
            _stationTexture = Content.Load<Texture2D>("deathstar");
            _theFuckingMoon = Content.Load<Texture2D>("moon");
            _menuBackground = Content.Load<Texture2D>("menuBackground");
            _playUp = Content.Load<Texture2D>("playUp");
            _playDown = Content.Load<Texture2D>("playDown");
            _exitUp = Content.Load<Texture2D>("exitUp");
            _exitDown = Content.Load<Texture2D>("exitDown");
            _kerchingSE = Content.Load<SoundEffect>("kerching");
            _explosionSE = Content.Load<SoundEffect>("explosion");
            _whipSE = Content.Load<SoundEffect>("whip");
            _laserSE = Content.Load<SoundEffect>("laser");
            _spriteFont = Content.Load<SpriteFont>("SpriteFont1");
            _screenPosition = Vector2.Zero;

            // Post load init
            /*objects.Add(new PointMass(_circle, new Vector2(640, 50), Vector2.Zero, 50, 100));
            objects.Add(new PointMass(_circle, new Vector2(1100, 300), Vector2.Zero, 50, 100));
            objects.Add(new PointMass(_circle, new Vector2(380.192379f, 500.0f), Vector2.Zero, 25, 50));*/
            _player = new Player(_rocket);
            _station = new SpaceStation(_stationTexture);
            _objects.Add(_player);
            _objects.Add(_station);

            _objects.Add((MassiveObject)new DynamicMass(_circle, new Vector2(400, 350), new Vector2(0f, 10.0f), 10, 50));

            //objects.Add((PointMass)new DynamicMass(_circle, new Vector2(890, 350), new Vector2(0f, -10.0f), 100, 25));

            // TODO: use this.Content to load your game content here
        }
コード例 #3
0
ファイル: Bullet.cs プロジェクト: Catchouli-old/Graveroids
 public Bullet(Player player, Texture2D texture, Vector2 position, Vector2 velocity, double mass, float radius)
     : base(texture, position, velocity, mass, radius)
 {
 }
コード例 #4
0
ファイル: Bullet.cs プロジェクト: Catchouli-old/Graveroids
 public Bullet(Player player, Texture2D texture, Vector2 position, Vector2 velocity)
     : base(texture, position, velocity)
 {
 }
コード例 #5
0
ファイル: Bullet.cs プロジェクト: Catchouli-old/Graveroids
 public Bullet(Player player, Texture2D texture, Vector2 position)
     : base(texture, position)
 {
 }
コード例 #6
0
ファイル: Bullet.cs プロジェクト: Catchouli-old/Graveroids
 public Bullet(Player player, Texture2D texture)
     : base(texture)
 {
 }