Exemple #1
0
 /// <summary>
 /// animates the enemy by switching the texture of the sprite
 /// </summary>
 /// <param name="gTime"></param>
 protected void Animate(GameTime gTime)
 {
     if (gTime.Total.Milliseconds % 1000 < 500)
         sprite.Texture = textur;
     else
         sprite.Texture = textur2;
 }
Exemple #2
0
 /// <summary>
 /// calls the move Methode
 /// </summary>
 public override void Update(GameTime gTime)
 {
     movementSpeed = baseMovementSpeed * gTime.Ellapsed.Milliseconds;
     MovingDirection = Program.Player.Position - sprite.Position;
     Move();
     if (isMoving)
         Animate(gTime);
 }
Exemple #3
0
        /// <summary>
        /// initialize Player and Enemies, by calling the constructors
        /// </summary>
        public static void Initialize()
        {
            gTime = new GameTime();
            BackgroundMusic = new Sound(new SoundBuffer("Sound/asia_1.ogg"));
            BackgroundMusic.Loop = true;
            BackgroundMusic.Volume = 30;
            BackgroundMusic.Play();

            JumpSound = new Sound(new SoundBuffer("Sound/jumpSound.wav"));
            JumpSound.Volume = 100;

            map = new Map(new System.Drawing.Bitmap("Pictures/Map.bmp"));
            Player = new Player(new Vector2f(map.TileSize + 30,map.TileSize + 30));
            enemy1 = new Enemy("Pictures/EnemyGreen.png", new Vector2f(800, 100), "Pictures/EnemyGreenMove.png");
            enemy2 = new Enemy("Pictures/EnemyRed.png", new Vector2f(100, 600), "Pictures/EnemyGreenMove.png");
        }
Exemple #4
0
        /// <summary>
        /// Calls the Move methode
        /// </summary>
        public override void Update(GameTime gTime)
        {
            float div = sprite.Position.Y - maxheight;

            touchedGround = !Program.map.CheckDownWards(this);

            if(!isJumping && Program.map.CheckDownWards(this))
            {
                sprite.Position += new Vector2f(0, (div+1f)/300);
            }
            if (isJumping)
            {
                sprite.Position -= new Vector2f(0, (div + 1f) / 300);
                if (Math.Abs(div) < 1f)
                {
                    isJumping = false;
                }
            }

            movementSpeed = baseMovementSpeed * gTime.Ellapsed.Milliseconds;
            KeyboardInput();
            Move();
        }
Exemple #5
0
 /// <summary>
 /// abstract Methode, must be implemented by all subclasses which are not abstract
 /// <para>shall Update this instance by calling all needed Methods</para>
 /// </summary>
 public abstract void Update(GameTime gTime);
Exemple #6
0
 /// <summary>
 /// Calls the Move methode
 /// </summary>
 public override void Update(GameTime gTime)
 {
     movementSpeed = baseMovementSpeed * gTime.Ellapsed.Milliseconds;
     KeyboardInput();
     Move();
 }