예제 #1
0
        public Form1()
        {
            InitializeComponent();

            Form f = this.FindForm();

            f.Controls.Remove(this);

            MainScreen ms = new MainScreen();

            f.Controls.Add(ms);
        }
예제 #2
0
        private void gameTimer_Tick(object sender, EventArgs e)
        {
            #region Isaac Movement
            currentX = isaac.x;
            currentY = isaac.y;

            for (int i = 0; i < 4; i++)
            {
                if (arrow[i] == true)
                {
                    isaac.direction = i;
                    isaac.move(isaac);

                    if (isaac.x + isaac.size > this.Width || isaac.x < 0 || isaac.y + isaac.size > this.Height ||
                        isaac.y < 0)
                    {
                        isaac.x = currentX;
                        isaac.y = currentY;
                    }
                }
            }
            #endregion

            #region Phoenix Movement
            //foreach loop that looks at each monster in phoenix
            foreach (Monster monster in phoenix)
            {
                if (isaac.collision(isaac, monster))
                {
                    gameTimer.Stop();

                    Form f = this.FindForm();
                    f.Controls.Remove(this);

                    MainScreen ms = new MainScreen();
                    f.Controls.Add(ms);
                }
                else
                {
                    //if isaac is more to the right, monster moves right
                    if (isaac.x - monster.x > 0)
                    {
                        monster.direction = 2;
                        monster.move(monster);
                    }
                    //if isaac is more to the left, monster moves left
                    else if (isaac.x - monster.x < 0)
                    {
                        monster.direction = 1;
                        monster.move(monster);
                    }
                    //if isaac is more up, monster moves up
                    if (isaac.y - monster.y > 0)
                    {
                        monster.direction = 0;
                        monster.move(monster);
                    }
                    //if isaac is more down, monster moves down
                    else if (isaac.y - monster.y < 0)
                    {
                        monster.direction = 3;
                        monster.move(monster);
                    }
                }
            }
            #endregion

            #region Bullet Movement
            if (spaceDown == true)
            {
                Bullet fireBall = new Bullet(isaac.x + (isaac.size / 2), isaac.y + (isaac.size / 2), 10, 9,
                                             isaac.direction, fireBullet);
                flame.Add(fireBall);
            }

            //foreach loop that looks at each bullet in flame
            foreach (Bullet fireball in flame)
            {
                fireball.move(fireball);

                if (fireball.x > this.Width || fireball.x < 0 || fireball.y > this.Height || fireball.y < 0)
                {
                    flame.Remove(fireball);
                    break;
                }
            }

            foreach (Monster monster in phoenix)
            {
                foreach (Bullet fireball in flame)
                {
                    if (monster.collision(monster, fireball))
                    {
                        phoenix.Remove(monster);
                        flame.Remove(fireball);
                        score++;
                        break;
                    }
                }
            }
            #endregion

            labelScore.Text = Convert.ToString(score);

            Refresh();
        }