コード例 #1
0
ファイル: Goomba.cs プロジェクト: JohnP42/super-luigi
        public override void move(Level l)
        {
            if (Stomped == -1 && Hurt == -1)
            {
                if (Velocity.X == 0)
                {
                    if (FacingRight)
                        FacingRight = false;
                    else
                        FacingRight = true;
                }

                if (FacingRight)
                {
                    if (Math.Abs(Velocity.X) < Speed)
                        Velocity = new Vector2(Velocity.X + Acc, Velocity.Y);
                }
                else
                {
                    if (Math.Abs(Velocity.X) < Speed)
                        Velocity = new Vector2(Velocity.X - Acc, Velocity.Y);
                }

            }

            base.move(l);
        }
コード例 #2
0
ファイル: Camera.cs プロジェクト: JohnP42/super-luigi
        public void Update(Luigi luigi, Level level)
        {
            center = new Vector2(MathHelper.Clamp(luigi.Body.X + 6, viewport.Width / 4, level.XSize * 24 - viewport.Width / 4),
                MathHelper.Clamp(luigi.Body.Y + 16, level.YSize * -24 + viewport.Height / 4, -viewport.Height / 4));

            transform = Matrix.CreateTranslation(new Vector3(-center.X, -center.Y, 0)) *
                                                Matrix.CreateRotationZ(0) *
                                                Matrix.CreateScale(new Vector3(zoom, zoom, 0)) *
                                                Matrix.CreateTranslation(new Vector3(viewport.Width / 2, viewport.Height / 2, 0));
        }
コード例 #3
0
ファイル: Item.cs プロジェクト: JohnP42/super-luigi
        public virtual void move(Level l)
        {
            if (creating == 0)
            {
                velocity.Y += gravity;
                position.X += (int)velocity.X;
                position.Y += (int)velocity.Y;
                collision(l);
            }
            else
            {
                velocity.Y = -1;

                position.Y += (int)velocity.Y;
            }
        }
コード例 #4
0
ファイル: Luigi.cs プロジェクト: JohnP42/super-luigi
        public void itemCollision(Level level)
        {
            foreach (Item i in level.Items)
            {
                if (body.Intersects(i.Position))
                {
                    if (i is ItemCoin)
                        coins++;

                    if (i is Mushroom && hp < 3)
                        hp++;

                    if (i is Starman)
                    {
                        toTransform = "Star";
                        transform = 120;
                        MediaPlayer.Play(Game1.songs[1]);
                        Game1.luigiSounds[7].Play();
                    }

                    if (i is Fireflower)
                    {
                        toTransform = "Fire";
                        transform = 120;
                        Game1.luigiSounds[7].Play();
                    }

                    i.grabbed(level);
                    break;
                }
            }
        }
コード例 #5
0
ファイル: Luigi.cs プロジェクト: JohnP42/super-luigi
        public void blockCollision(Level level)
        {
            onGround = false;

            foreach (Block b in level.Blocks)
            {
                if(b.Destroyed)
                    continue;

                if (b.Solid)
                {

                    if (body.Intersects(b.Position))
                    {
                        Block final = b;

                        foreach (Block n in level.getAdjacentBlocks(b))
                        {

                            if (Rectangle.Intersect(body, n.Position).Width * Rectangle.Intersect(body, n.Position).Height > Rectangle.Intersect(body, final.Position).Width * Rectangle.Intersect(body, final.Position).Height)
                                final = n;

                        }
                            if (Rectangle.Intersect(body, final.Position).Width >= Rectangle.Intersect(body, final.Position).Height)
                            {

                                if (Rectangle.Intersect(body, final.Position).Top == final.Position.Top)
                                {
                                    body.Y = final.Position.Top - body.Height;
                                    velocity.Y = 0;
                                    onGround = true;
                                }
                                else if (Rectangle.Intersect(body, final.Position).Bottom == final.Position.Bottom)
                                {
                                    body.Y = final.Position.Bottom;
                                    velocity.Y *= -1;

                                    final.onHit(level);

                                    if (level.getItemAboveBlock(final) != null)
                                        level.getItemAboveBlock(final).Velocity = new Vector2(level.getItemAboveBlock(final).Velocity.X, -6);

                                    if (level.getEnemyAboveBlock(final) != null)
                                        level.getEnemyAboveBlock(final).onHit(level);

                                }
                            }
                            else
                            {

                                 if (Rectangle.Intersect(body, final.Position).Left == final.Position.Left)
                                {
                                    if (velocity.X > 0)
                                    {
                                        velocity.X = 0;
                                        body.X = final.Position.Left - body.Width;
                                    }

                                }
                                else if (Rectangle.Intersect(body, final.Position).Right == final.Position.Right)
                                {
                                    if (velocity.X < 0)
                                    {
                                        velocity.X = 0;
                                        body.X = final.Position.Right;
                                    }
                                }

                            }

                            break;

                    }

                    Rectangle temp = b.Position;
                    temp.Y -=1;

                    if (body.Intersects(temp))
                        onGround = true;
                }
            }
        }
コード例 #6
0
ファイル: Luigi.cs プロジェクト: JohnP42/super-luigi
        public void update(Level level)
        {
            if (hurt > 0)
                hurt--;

            if (aura != null)
                aura.update(level, this);

            powerUps();
            if(transform == 0)
                movement(level);
            animation();
            sprites();
            dust.update();
            emptyParticleSystems();
        }
コード例 #7
0
ファイル: Koopa.cs プロジェクト: JohnP42/super-luigi
        public override void collision(Level level)
        {
            if (inShell)
            {
                foreach (Block b in level.Blocks)
                {

                    if (Position.Intersects(b.Position))
                    {
                        Block final = b;

                        foreach (Block n in level.getAdjacentBlocks(b))
                        {

                            if (Rectangle.Intersect(Position, n.Position).Width * Rectangle.Intersect(Position, n.Position).Height > Rectangle.Intersect(Position, final.Position).Width * Rectangle.Intersect(Position, final.Position).Height)
                                final = n;

                        }
                        if (Rectangle.Intersect(Position, final.Position).Width >= Rectangle.Intersect(Position, final.Position).Height)
                        {

                            if (Rectangle.Intersect(Position, final.Position).Top == final.Position.Top)
                            {
                                Position = new Rectangle(Position.X, final.Position.Top - Position.Height, Position.Width, Position.Height);
                                Velocity = new Vector2(Velocity.X, 0);
                            }
                            else if (Rectangle.Intersect(Position, final.Position).Bottom == final.Position.Bottom)
                            {
                                Position = new Rectangle(Position.X, final.Position.Bottom, Position.Width, Position.Height);
                                Velocity = new Vector2(Velocity.X, Velocity.Y * -1); ;
                            }
                        }
                        else
                        {

                            if (Rectangle.Intersect(Position, final.Position).Left == final.Position.Left)
                            {
                                Velocity = new Vector2(-4, Velocity.Y);
                                Position = new Rectangle(final.Position.Left - Position.Width, Position.Y, Position.Width, Position.Height);
                                Game1.otherSounds[1].Play();

                            }
                            else if (Rectangle.Intersect(Position, final.Position).Right == final.Position.Right)
                            {
                                Velocity = new Vector2(4, Velocity.Y);
                                Position = new Rectangle(final.Position.Right, Position.Y, Position.Width, Position.Height);
                                Game1.otherSounds[1].Play();
                            }

                        }

                        break;
                    }
                }
            }
            else
                base.collision(level);
        }
コード例 #8
0
ファイル: Koopa.cs プロジェクト: JohnP42/super-luigi
 public override void onHit(Level l)
 {
     Velocity = new Vector2(0, -5);
     Hurt = 50;
     SndHit.Play();
 }
コード例 #9
0
ファイル: Block.cs プロジェクト: JohnP42/super-luigi
        public virtual void onDestroyed(Level l)
        {
            breakSound.Play();

            if (heldItem is ItemCoin)
                l.ParticleSystems.Add(new Particles.ParticleSystemCoin(Position.X / 24, Position.Y / 24));

            if (HeldItem != null)
                l.Items.Add(heldItem);
        }
コード例 #10
0
ファイル: Block.cs プロジェクト: JohnP42/super-luigi
 public virtual void destroy(Level l)
 {
     destroyed = true;
     onDestroyed(l);
 }
コード例 #11
0
ファイル: Enemy.cs プロジェクト: JohnP42/super-luigi
        public virtual void update(Level l)
        {
            if (hurt > 0)
                hurt--;
            if (hurt == 0)
                alive = false;

            if (stomped > 0)
                stomped--;
            if (stomped == 0)
                alive = false;

            move(l);
            animate();
            sprites();
        }
コード例 #12
0
ファイル: Enemy.cs プロジェクト: JohnP42/super-luigi
 public virtual void onStomp(Level l)
 {
 }
コード例 #13
0
ファイル: Enemy.cs プロジェクト: JohnP42/super-luigi
 public virtual void onHit(Level l)
 {
 }
コード例 #14
0
ファイル: Enemy.cs プロジェクト: JohnP42/super-luigi
        public virtual void collision(Level level)
        {
            foreach (Block b in level.Blocks)
            {
                if (position.Intersects(b.Position))
                {
                    Block final = b;

                    foreach (Block n in level.getAdjacentBlocks(b))
                    {

                        if (Rectangle.Intersect(position, n.Position).Width * Rectangle.Intersect(position, n.Position).Height > Rectangle.Intersect(position, final.Position).Width * Rectangle.Intersect(position, final.Position).Height)
                            final = n;

                    }
                    if (Rectangle.Intersect(position, final.Position).Width >= Rectangle.Intersect(position, final.Position).Height)
                    {

                        if (Rectangle.Intersect(position, final.Position).Top == final.Position.Top)
                        {
                            position.Y = final.Position.Top - position.Height;
                            velocity.Y = 0;
                        }
                        else if (Rectangle.Intersect(position, final.Position).Bottom == final.Position.Bottom)
                        {
                            position.Y = final.Position.Bottom;
                            velocity.Y *= -1;
                        }
                    }
                    else
                    {

                        if (Rectangle.Intersect(position, final.Position).Left == final.Position.Left)
                        {
                            velocity.X = 0;
                            position.X = final.Position.Left - position.Width;

                        }
                        else if (Rectangle.Intersect(position, final.Position).Right == final.Position.Right)
                        {
                            velocity.X = 0;
                            position.X = final.Position.Right;
                        }

                    }

                    break;
                }
            }
        }
コード例 #15
0
ファイル: Item.cs プロジェクト: JohnP42/super-luigi
        public void update(Level l)
        {
            if (creating > 0)
                creating--;

            animate();
            move(l);
        }
コード例 #16
0
ファイル: Block.cs プロジェクト: JohnP42/super-luigi
        public virtual void onHit(Level l)
        {
            if(!breakable)
                offsetY -= 5;
            else
                destroy(l);

            hitSound.Play();
        }
コード例 #17
0
ファイル: Koopa.cs プロジェクト: JohnP42/super-luigi
        public override void move(Level l)
        {
            if (lethal > 0)
                lethal--;

            if (Stomped == -1 && Hurt == -1 && !inShell)
            {
                if (Velocity.X == 0)
                {
                    if (FacingRight)
                        FacingRight = false;
                    else
                        FacingRight = true;
                }

                if (FacingRight)
                {
                    if (Math.Abs(Velocity.X) < Speed)
                        Velocity = new Vector2(Velocity.X + Acc, Velocity.Y);
                }
                else
                {
                    if (Math.Abs(Velocity.X) < Speed)
                        Velocity = new Vector2(Velocity.X - Acc, Velocity.Y);
                }

            }

            if (inShell)
            {

                if (Velocity.X != 0)
                {
                    foreach (Enemy e in l.Enemies)
                    {
                        if (e.Equals(this))
                            continue;

                        if (e.Alive == false || e.Hurt != -1 || e.Stomped != -1)
                            continue;

                        if (Position.Intersects(e.Position))
                        {
                            e.onHit(l);
                            break;
                        }
                    }
                }
            }

            base.move(l);
        }
コード例 #18
0
ファイル: Projectile.cs プロジェクト: JohnP42/super-luigi
        public virtual void collision(Level level)
        {
            foreach (Block b in level.Blocks)
            {
                if (position.Intersects(b.Position))
                {
                    Block final = b;

                    foreach (Block n in level.getAdjacentBlocks(b))
                    {

                        if (Rectangle.Intersect(position, n.Position).Width * Rectangle.Intersect(position, n.Position).Height > Rectangle.Intersect(position, final.Position).Width * Rectangle.Intersect(position, final.Position).Height)
                            final = n;

                    }
                    if (Rectangle.Intersect(position, final.Position).Width >= Rectangle.Intersect(position, final.Position).Height)
                    {

                        if (Rectangle.Intersect(position, final.Position).Top == final.Position.Top)
                        {
                            position.Y = final.Position.Top - position.Height;
                            velocity.Y = -6;
                        }
                        else if (Rectangle.Intersect(position, final.Position).Bottom == final.Position.Bottom)
                        {
                            position.Y = final.Position.Bottom;
                            velocity.Y *= -1;
                        }
                    }
                    else
                    {

                        if (Rectangle.Intersect(position, final.Position).Left == final.Position.Left)
                        {
                            velocity.X = 0;
                            position.X = final.Position.Left - position.Width;
                            destroy(level);
                        }
                        else if (Rectangle.Intersect(position, final.Position).Right == final.Position.Right)
                        {
                            velocity.X = 0;
                            position.X = final.Position.Right;
                            destroy(level);
                        }

                    }

                    break;
                }
            }

            foreach (Enemy e in level.Enemies)
            {
                if (e.Alive == false || e.Hurt != -1 || e.Stomped != -1)
                    continue;

                if (position.Intersects(e.Position))
                {

                    this.destroy(level);
                    e.onHit(level);

                    break;
                }
            }
        }
コード例 #19
0
ファイル: Koopa.cs プロジェクト: JohnP42/super-luigi
 public override void onStomp(Level l)
 {
     if (!inShell)
     {
         Velocity = new Vector2(0, Velocity.Y);
         inShell = true;
         SndStomp.Play();
     }
     else
     {
         if(Velocity.X == 0)
             Velocity = new Vector2(4, Velocity.Y);
         else
             Velocity = new Vector2(0, Velocity.Y);
         SndStomp.Play();
     }
 }
コード例 #20
0
ファイル: Projectile.cs プロジェクト: JohnP42/super-luigi
 public virtual void destroy(Level l)
 {
     alive = false;
     onDestroy(l);
 }
コード例 #21
0
ファイル: Aura.cs プロジェクト: JohnP42/super-luigi
        public void update(Level l, Luigi luigi)
        {
            position = new Vector2(luigi.Body.X - srcRect[imageIndex].Width / 2 + luigi.Body.Width / 2, luigi.Body.Bottom - srcRect[imageIndex].Height + luigi.Body.Height / 6);

            animate();
        }
コード例 #22
0
ファイル: Projectile.cs プロジェクト: JohnP42/super-luigi
 public virtual void move(Level l)
 {
     velocity.Y += gravity;
     position.X += (int)velocity.X;
     position.Y += (int)velocity.Y;
     collision(l);
 }
コード例 #23
0
ファイル: Game1.cs プロジェクト: JohnP42/super-luigi
        /// <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)
        {
            if (level == null)
                level = new LevelTest();
            if (camera == null)
                camera = new Camera(GraphicsDevice.Viewport);
            if (luigi == null)
                luigi = new Luigi(new Vector2(32, -100));
            if (hud == null)
                hud = new HUD();

            if (MediaPlayer.State == MediaState.Stopped)
            {
                MediaPlayer.Play(level.MainSong);
                MediaPlayer.IsRepeating = true;
            }

            k1 = Keyboard.GetState();
            g = GamePad.GetState(PlayerIndex.One);

            if (g.IsConnected)
                luigi.input(g);
            else
                luigi.input(k1);

            luigi.update(level);

            camera.Update(luigi, level);

            level.disposeBlocksandItems();
            level.update(luigi);

            base.Update(gameTime);
        }
コード例 #24
0
ファイル: Projectile.cs プロジェクト: JohnP42/super-luigi
 public virtual void onDestroy(Level l)
 {
 }
コード例 #25
0
ファイル: Luigi.cs プロジェクト: JohnP42/super-luigi
        public void wallJump(Level level)
        {
            if (!onGround && velocity.Y > 0)
            {
                foreach (Block b in level.Blocks)
                {

                    if (b.Destroyed)
                        continue;

                    if (b.Solid)
                    {
                        if(buttons[0])
                        {
                            if (new Rectangle(body.X + 1, body.Y, body.Width, body.Height).Intersects(b.Position))
                            {

                                    onWall = true;

                                    if (buttons[4] && canJump)
                                    {
                                        currentJump = 0;
                                        Game1.luigiSounds[3].Play();
                                        velocity.X -= jumpForce;
                                        velocity.Y = -jumpForce;
                                        onWall = false;
                                        canJump = false;
                                        superJump = .55f;
                                        facingRight = false;
                                    }

                                    return;
                            }
                        }
                        else if (buttons[1])
                        {
                            if (new Rectangle(body.X - 1, body.Y, body.Width, body.Height).Intersects(b.Position))
                            {

                                    onWall = true;

                                    if (buttons[4] && canJump)
                                    {
                                        currentJump = 0;
                                        Game1.luigiSounds[3].Play();
                                        velocity.X += jumpForce;
                                        velocity.Y = -jumpForce;
                                        onWall = false;
                                        canJump = false;
                                        superJump = .55f;
                                        facingRight = true;
                                    }

                                    return;

                            }
                        }
                    }

                }
            }

            onWall = false;
        }
コード例 #26
0
ファイル: Projectile.cs プロジェクト: JohnP42/super-luigi
 public void update(Level l)
 {
     animate();
     move(l);
 }
コード例 #27
0
ファイル: Luigi.cs プロジェクト: JohnP42/super-luigi
        public void enemyCollision(Level level)
        {
            foreach (Enemy e in level.Enemies)
            {
                if (!e.Alive || e.Stomped != -1 || e.Hurt != -1)
                    continue;

                if (body.Intersects(e.Position))
                {
                    if (star == 0)
                    {
                        if ((Rectangle.Intersect(body, e.Position).Width >= Rectangle.Intersect(body, e.Position).Height || velocity.Y > 1) && tripped == 0)
                        {

                            if (Rectangle.Intersect(body, e.Position).Top == e.Position.Top)
                            {
                                velocity.Y = -jumpForce;
                                superJump = .55f;
                                e.onStomp(level);
                            }
                            else if (Rectangle.Intersect(body, e.Position).Bottom == e.Position.Bottom)
                            {
                                if (tripped == 0)
                                {
                                    if (Math.Abs(velocity.X) < maxSpeed + 1)
                                    {
                                        hurt = 20;
                                        velocity = new Vector2(0, 3);
                                        Game1.luigiSounds[4].Play();
                                    }
                                    else
                                    {
                                        tripped = 20;
                                        velocity = new Vector2(velocity.X, -3);
                                        Game1.luigiSounds[5].Play();
                                    }

                                    Game1.otherSounds[1].Play();
                                    hp--;
                                    throwing = false;
                                    if (fireLuigi)
                                    {
                                        fireLuigi = false;
                                        Game1.otherSounds[7].Play();
                                    }
                                }
                                else if (imageIndex == 3)
                                {
                                    e.onHit(level);
                                }
                            }
                        }
                        else
                        {

                            if (Rectangle.Intersect(body, e.Position).Left == e.Position.Left)
                            {
                                if (e is Koopa && ((Koopa)e).InShell && (e.Velocity.X == 0 || ((Koopa)e).Lethal > 0))
                                {
                                    e.Velocity = new Vector2(velocity.X + 2, e.Velocity.Y);
                                    Game1.otherSounds[5].Play();
                                    ((Koopa)e).Lethal = 10;
                                }
                                else
                                {
                                    if (tripped == 0)
                                    {
                                        if (Math.Abs(velocity.X) < maxSpeed + 1)
                                        {
                                            hurt = 20;
                                            velocity = new Vector2(-3, -3);
                                            Game1.luigiSounds[4].Play();
                                        }
                                        else
                                        {
                                            tripped = 20;
                                            velocity = new Vector2(velocity.X, -3);
                                            Game1.luigiSounds[5].Play();
                                        }

                                        Game1.otherSounds[1].Play();
                                        hp--;
                                        throwing = false;
                                        if (fireLuigi)
                                        {
                                            fireLuigi = false;
                                            Game1.otherSounds[7].Play();
                                        }
                                    }
                                    else if (imageIndex == 3)
                                    {
                                        e.onHit(level);
                                    }
                                }

                            }
                            else if (Rectangle.Intersect(body, e.Position).Right == e.Position.Right)
                            {

                                if (e is Koopa && ((Koopa)e).InShell && (e.Velocity.X == 0 || ((Koopa)e).Lethal > 0))
                                {
                                    e.Velocity = new Vector2(velocity.X - 2, e.Velocity.Y);
                                    Game1.otherSounds[5].Play();
                                    ((Koopa)e).Lethal = 10;
                                }
                                else
                                {
                                    if (tripped == 0)
                                    {
                                        if (Math.Abs(velocity.X) < maxSpeed + 1)
                                        {
                                            hurt = 20;
                                            velocity = new Vector2(3, -3);
                                            Game1.luigiSounds[4].Play();
                                        }
                                        else
                                        {
                                            tripped = 20;
                                            velocity = new Vector2(velocity.X, -3);
                                            Game1.luigiSounds[5].Play();
                                        }

                                        Game1.otherSounds[1].Play();
                                        hp--;
                                        throwing = false;
                                        if (fireLuigi)
                                        {
                                            fireLuigi = false;
                                            Game1.otherSounds[7].Play();
                                        }
                                    }
                                    else if (imageIndex == 3)
                                    {
                                        e.onHit(level);
                                    }
                                }
                            }

                        }
                    }
                    else
                    {
                        if ((Rectangle.Intersect(body, e.Position).Width >= Rectangle.Intersect(body, e.Position).Height || velocity.Y > 1) && tripped == 0)
                        {
                            if (Rectangle.Intersect(body, e.Position).Top == e.Position.Top)
                            {
                                velocity.Y = -jumpForce;
                                superJump = .55f;
                                e.onStomp(level);
                            }
                            else
                                e.onHit(level);
                        }
                        else
                            e.onHit(level);
                    }

                    break;

                }

            }
        }
コード例 #28
0
ファイル: Goomba.cs プロジェクト: JohnP42/super-luigi
 public override void onStomp(Level l)
 {
     Velocity = new Vector2(0, Velocity.Y);
     Stomped = 20;
     SndStomp.Play();
 }
コード例 #29
0
ファイル: Luigi.cs プロジェクト: JohnP42/super-luigi
        public void movement(Level level)
        {
            //Gravity
            if (!onGround)
            {
                velocity.Y += gravity - superJump;

                if (!onWall)
                {
                    if (velocity.Y > maxVspeed)
                        velocity.Y = maxVspeed;
                }
                else if (velocity.Y > maxVspeed * .25)
                    velocity.Y -= velocity.Y * .3f;

            }
            else
            {
                if (jumpCount > 0)
                    jumpCount--;

                if (jumpCount == 0)
                {
                    jumpLevel = 0;
                    currentJump = 0;
                }
            }

            if (hurt == 0 && tripped == 0)
            {

                //Duck
                if (buttons[3])
                {
                    if (onGround)
                    {
                        if (!ducking)
                            body.Y += 12;

                        ducking = true;
                        body.Height = 24;
                    }
                }
                else
                {
                    if (ducking)
                        body.Y -= 12;

                    ducking = false;
                    body.Height = 36;
                }

                if (!ducking)
                {
                    //Walk and Run
                    if (buttons[5])
                    {
                        if(!running)
                        {
                            if(fireLuigi && projectiles.Count < 4 && !throwing)
                            {
                                throwing = true;
                            }
                        }

                        running = true;

                    }
                    else
                        running = false;

                    float inAir = 1f;

                    if (!onGround)
                        inAir = .65f;

                    if (!running)
                    {
                        if (buttons[0] && velocity.X < maxSpeed)
                            velocity.X += acc * inAir;

                        if (buttons[1] && velocity.X > -maxSpeed)
                            velocity.X -= acc * inAir;
                    }
                    else
                    {
                        if (badge != "Speed" && star == 0)
                        {
                            if (buttons[0] && velocity.X < maxRunSpeed)
                                velocity.X += runAcc * inAir;

                            if (buttons[1] && velocity.X > -maxRunSpeed)
                                velocity.X -= runAcc * inAir;
                        }
                        else
                        {
                            if (buttons[0] && velocity.X < maxRunSpeed + 4f)
                                velocity.X += runAcc * inAir;

                            if (buttons[1] && velocity.X > -maxRunSpeed - 4f)
                                velocity.X -= runAcc * inAir;
                        }
                    }

                    wallJump(level);

                }

            }
                if (velocity.X != 0 && onGround)
                {
                    if (velocity.X > 0)
                        velocity.X -= friction;
                    else
                        velocity.X += friction;

                    if (Math.Abs(velocity.X) < friction)
                        velocity.X = 0;

                }

                if (velocity.X != 0 && !onGround)
                {
                    if (velocity.X > 0)
                        velocity.X -= air;
                    else
                        velocity.X += air;

                    if (Math.Abs(velocity.X) < air)
                        velocity.X = 0;

                }

                if (Math.Abs(velocity.X) < 4.5f)
                    jumpLevel = 0;

                if (hurt == 0 && tripped == 0)
                {

                    //jump
                    if (buttons[4])
                    {
                        if (onGround && canJump)
                        {
                            canJump = false;
                            velocity.Y = 0;
                            if (jumpLevel == 0)
                            {
                                Game1.luigiSounds[0].Play();
                                velocity.Y -= jumpForce;
                                if (Math.Abs(velocity.X) >= 4.5f)
                                {
                                    superJump = .55f;
                                    jumpCount = 10;
                                    jumpLevel = 1;
                                }
                                else
                                    superJump = .5f;

                                currentJump = 0;
                            }
                            else if (jumpLevel == 1)
                            {
                                Game1.luigiSounds[1].Play();
                                velocity.Y -= jumpForce;
                                if (Math.Abs(velocity.X) >= 4.5f)
                                {
                                    superJump = .58f;
                                    jumpCount = 10;
                                    jumpLevel = 2;
                                }
                                else
                                    superJump = .55f;

                                currentJump = 1;
                            }
                            else if (jumpLevel == 2)
                            {
                                Game1.luigiSounds[2].Play();
                                velocity.Y -= jumpForce;
                                if (Math.Abs(velocity.X) >= 4.5f)
                                {
                                    superJump = .61f;
                                }
                                else
                                    superJump = .58f;

                                jumpLevel = 0;
                                currentJump = 2;
                            }
                        }
                    }
                    else
                        superJump = 0f;
                }

            //final
            body.X += (int)velocity.X;
            body.Y += (int)velocity.Y;

            //Projectiles
            foreach(Projectile p in projectiles)
            {
                p.update(level);
            }

            //Collision
            blockCollision(level);
            itemCollision(level);
            if(hurt == 0)
                enemyCollision(level);
        }
コード例 #30
0
ファイル: Item.cs プロジェクト: JohnP42/super-luigi
 public virtual void grabbed(Level l)
 {
     grabSound.Play();
     obtained = true;
 }