Example #1
0
        internal static void BonusMovements()
        {
            Bonus lostBonus = null;

            foreach (Bonus bonus in Resources.levelOneBonuses)
            {
                if (Math.Abs(bonus.bonus.Left - Mario.mario.Left) <= 18 * x)
                {
                    if (bonus.left)
                    {
                        bonus.bonus.Left -= 4;
                    }
                    if (bonus.right)
                    {
                        bonus.bonus.Left += 4;
                    }
                }
                else
                {
                    bonus.Disappear();
                    lostBonus = bonus;
                }

                bonus.bonus.Top -= bonus.force;
                bonus.force     -= 1;
                if (bonus.force < -Mario.jumpspeed)
                {
                    bonus.force = -Mario.jumpspeed;
                }
            }

            if (lostBonus != null)
            {
                Resources.levelOneBonuses.Remove(lostBonus);
            }
        }
Example #2
0
        internal static void BonusCollisions()
        {
            Bonus collectedBonus = null;

            foreach (Bonus bonus in Resources.levelOneBonuses)
            {
                foreach (Control c in form.Controls)
                {
                    if (c is PictureBox && c.Tag == "block" && Math.Abs((c as PictureBox).Left - Mario.mario.Left) <= 20 * x)
                    {
                        if (bonus.bonus.Bounds.IntersectsWith(c.Bounds))
                        {
                            if (BottomCollision(bonus.bonus, c as PictureBox))
                            {
                                bonus.bonus.Top = c.Top - x;
                                if (bonus.bonus.Name == "star")
                                {
                                    bonus.force = Mario.jumpspeed;
                                }
                                else
                                {
                                    bonus.force = 0;
                                }
                            }

                            if (TopCollision(bonus.bonus, c as PictureBox))
                            {
                                bonus.bonus.Top = c.Bottom;
                                bonus.force     = 0;
                            }

                            if (RightCollision(bonus.bonus, c as PictureBox))
                            {
                                bonus.right      = false;
                                bonus.bonus.Left = c.Left - x;
                                bonus.left       = true;
                            }

                            if (LeftCollision(bonus.bonus, c as PictureBox))
                            {
                                bonus.left       = false;
                                bonus.bonus.Left = c.Right;
                                bonus.right      = true;
                            }
                        }
                    }
                }
                if (Mario.mario.Bounds.IntersectsWith(bonus.bonus.Bounds))
                {
                    switch (bonus.bonus.Name)
                    {
                    case "mushroom":
                    {
                        Mario.upgrade    = 1;
                        Mario.mario.Size = new Size(x, 2 * x);
                        Mario.mario.Top -= x;
                        break;
                    }

                    case "flower":
                    {
                        Mario.upgrade++;
                        if (Mario.upgrade == 1)
                        {
                            Mario.mario.Size = new Size(x, 2 * x);
                            Mario.mario.Top -= x;
                        }
                        else
                        {
                            Mario.upgrade = 2;
                            if (Mario.invincible)
                            {
                                Mario.mario.BackColor = Color.FromArgb(150, Color.White);
                            }
                            else
                            {
                                Mario.mario.BackColor = Color.White;
                            }
                        }
                        break;
                    }

                    case "star":
                    {
                        if (!Mario.invincible)
                        {
                            Mario.invincible      = true;
                            Mario.mario.BackColor = Color.FromArgb(150, Mario.mario.BackColor);
                        }
                        Mario.invincibleTime = 500;
                        break;
                    }

                    case "oneUp":
                    {
                        break;
                    }
                    }
                    bonus.Disappear();
                    collectedBonus = bonus;
                }
            }

            if (collectedBonus != null)
            {
                Resources.levelOneBonuses.Remove(collectedBonus);
            }
        }