Esempio n. 1
0
 private void LoadContents()
 {
     Begin.LoadContent(this.Content);
     Speler.LoadContent(this.Content);
     BulletPlayer.LoadContent(this.Content);
     Robot.LoadContent(this.Content);
     MonsterRight.LoadContent(this.Content);
     MonsterLeft.LoadContent(this.Content);
     Tank.LoadContent(this.Content);
     FireRobot.LoadContent(this.Content);
     BulletEnemy.LoadContent(this.Content);
     Leven.LoadContent(this.Content);
     PlatformGround.LoadContent(this.Content);
     PlatformLeft.LoadContent(this.Content);
     PlatformGroundReverse.LoadContent(this.Content);
     PlatformMiddle.LoadContent(this.Content);
     PlatformRight.LoadContent(this.Content);
     Flamethrower.LoadContent(this.Content);
     BulletFlame.LoadContent(this.Content);
     Box.LoadContent(this.Content);
     Barrel.LoadContent(this.Content);
     SpikesUp.LoadContent(this.Content);
     SpikesDown.LoadContent(this.Content);
     Mine.LoadContent(this.Content);
     Floppy.LoadContent(this.Content);
     Cola.LoadContent(this.Content);
     KeyRed.LoadContent(this.Content);
     KeyBlue.LoadContent(this.Content);
     Door.LoadContent(this.Content);
     Text.LoadContent(this.Content);
     Background.LoadContent(this.Content);
     Score.LoadContent(this.Content);
     PrimitiveDrawing.LoadContent(this.Content);
 }
Esempio n. 2
0
        public override void Update(GameTime g)
        {
            Ticks += g.ElapsedGameTime.Milliseconds;

            #region Land

            if (!Land)
            {
                _oldLand = false;       //_oldLand is een variabele die zorgt dat er niet constant in de functionaliteit hieronder wordt gegaan!
            }
            else if (!_oldLand)
            {
                //Deel van de "death animation"
                if (Die == true)
                {
                    RectangleActive.X = 160;
                    Death             = true;
                }

                else
                {
                    //Als je Land en je bent niet dood moet de Stilstaan texture gebruikt worden
                    if (_richting == Richting.Rechts)
                    {
                        TextureActive = _picRight;
                    }
                    else
                    {
                        TextureActive = _picLeft;
                    }

                    RectangleActive.X = 0;

                    //Als je aan het springen bent en je land moet de speler terug stilstaan! Jumpheigt moet ook positief zijn anders zijn we nog naar boven aan het springen!
                    if (_jump && _jumpHeight > 0)
                    {
                        _soundLand.Play();
                        RectangleActive = _rectangleStand;
                        _jump           = false;
                    }

                    if (_gravity != 200)  //Dan ben je aan het vallen
                    {
                        _soundLand.Play();
                    }

                    //_soundLand.Play() kan niet constant gespeeld worden want indien je voeten een blok raken zal het dan ook spelen dit niet de bedoeling!

                    //Als je land moet de zwaartekracht gereset worden, zodanig indien je terug valt het terug begint te dalen!
                    _gravity = 200;
                }

                _oldLand = true;
            }
            #endregion

            #region UpdateFunctionality
            if (Die == false)
            {
                if (_reload > 0 && Ticks >= 66)
                {
                    _reload--;                      //Reload timer!
                }
                #region Zwaartekracht
                if (!Land && !_jump)
                {
                    RectangleActive = _rectangleJump;

                    if (_richting == Richting.Rechts)
                    {
                        TextureActive = _picJumpRight;
                    }
                    else
                    {
                        TextureActive = _picJumpLeft;
                    }

                    RectangleActive.X = 80;             //val sprite
                    Positie.Y        += _gravity * (float)g.ElapsedGameTime.TotalSeconds;;
                    _gravity         += 300 * (float)g.ElapsedGameTime.TotalSeconds;
                }
                #endregion

                #region Wandelen
                if ((_left || _right) && (_teller % 2 == 0) && (!_jump && Land))
                {
                    if (Ticks >= 66)
                    {
                        _rectangleWalk.X += 80;
                    }

                    if (_rectangleWalk.X >= 320)
                    {
                        _rectangleWalk.X = 0;
                    }

                    RectangleActive = _rectangleWalk;
                }

                if (_left)
                {
                    //Als de speler botst mag deze niet meer opschuiven in de richting dat hij botst.
                    if (!(BounceHorizontal && BounceHorizontalRichting == Richting.Links))
                    {
                        LocationX -= Convert.ToInt32(200 * g.ElapsedGameTime.TotalSeconds);
                    }

                    if (_jump || !Land)
                    {
                        TextureActive = _picJumpLeft;
                    }
                    else
                    {
                        TextureActive = _picWalkLeft;
                    }
                }

                if (_right)
                {
                    //Als de speler botst mag deze niet meer opschuiven in de richting dat hij botst.
                    if (!(BounceHorizontal && BounceHorizontalRichting == Richting.Rechts))
                    {
                        LocationX += Convert.ToInt32(200 * g.ElapsedGameTime.TotalSeconds);
                    }

                    if (_jump || !Land)
                    {
                        TextureActive = _picJumpRight;
                    }
                    else
                    {
                        TextureActive = _picWalkRight;
                    }
                }

                #endregion

                #region Springen
                if (_jump)
                {
                    Land = false;
                    if (BounceVertical == true)
                    {
                        BounceVertical = false;
                        _jump          = false;
                    }

                    else
                    {
                        if (_jumpHeight == -290)     //1ste keer!
                        {
                            _soundJump.Play();
                        }

                        else if (_jumpHeight > 0)        //Is de Speler aan het vallen?
                        {
                            RectangleActive.X = 80;
                        }

                        Positie.Y   += _jumpHeight * (float)g.ElapsedGameTime.TotalSeconds;
                        _jumpHeight += 300 * (float)g.ElapsedGameTime.TotalSeconds;
                    }
                }
                #endregion

                #region Schieten
                if (_shoot)
                {
                    if (_richting == Richting.Rechts)
                    {
                        _bullet = new BulletPlayer(LocationX + RectangleActive.Width - 20, LocationY + RectangleActive.Height / 2 + 5, Richting.Rechts);      //+5 Omdat geweer niet in het midden van speler zit!
                    }
                    else
                    {
                        _bullet = new BulletPlayer(LocationX + 20, LocationY + RectangleActive.Height / 2 + 5, Richting.Links);
                    }
                    _soundShoot.Play();
                }
                #endregion

                #region GeraaktWorden
                if (Hit && Ticks >= 66)
                {
                    if (_teller == 0)
                    {
                        if (_levens.Count > 0)
                        {
                            _soundHit.Play();
                            _levens.RemoveAt(_levens.Count - 1);
                        }
                    }

                    if (_levens.Count == 0)         //Dood gaan
                    {
                        Console.WriteLine("DEATH");
                        _soundDeath.Play();
                        _jump           = true;
                        LocationY      -= 1;        //ZORGEN DAT ER ZEKER GEEN COLLISION MEER IS MET DE GROND!!!
                        _jumpHeight     = -60;
                        Die             = true;
                        TextureActive   = _picDeath;
                        RectangleActive = _rectangleDie;
                    }

                    else
                    {
                        _teller++;
                    }

                    if (_teller > 25)
                    {
                        _teller = 0;
                        Hit     = false;
                    }
                }
                #endregion

                #region FrameIndependant
                if (Ticks >= 66)
                {
                    Ticks = 0;
                }
                #endregion
            }
            #endregion      //Update

            #region DeathAnimation
            else
            {
                RectangleCollision.Width  = 0;
                RectangleCollision.Height = 0;
                if (_jumpHeight > 0 && Land == false)
                {
                    RectangleActive.X = 80;
                }

                if (!Land)
                {
                    Positie.Y   += _jumpHeight * (float)g.ElapsedGameTime.TotalSeconds;
                    _jumpHeight += 300 * (float)g.ElapsedGameTime.TotalSeconds;
                }
            }
            #endregion

            UpdateCollisionRectangles();
        }