Exemple #1
0
        void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            int j = -1;
            int i;

            switch (e.KeyCode)
            {
            case Keys.Left:
                if (HalaG == 0)
                {
                    if (Pause == 0)
                    {
                        for (i = 0; i < LMaze.Count; i++)
                        {
                            if (LMaze[i].X <= LShalby[0].X)
                            {
                                if ((LShalby[0].X + LShalby[0].im[0].Width - 3 >= LMaze[i].X &&
                                     LShalby[0].X <= (LMaze[i].X + LMaze[i].W) &&
                                     LShalby[0].Y >= LMaze[i].Y &&
                                     LShalby[0].Y <= (LMaze[i].Y + LMaze[i].H)))
                                {
                                    j = i;
                                    break;
                                }
                            }
                        }
                        if (j == -1)
                        {
                            LShalby[0].X -= 5;
                        }
                        LShalby[0].iFrame = 1;
                    }
                }
                break;

            case Keys.Right:
                if (HalaG == 0)
                {
                    if (Pause == 0)
                    {
                        for (i = 0; i < LMaze.Count; i++)
                        {
                            if (LMaze[i].X >= LShalby[0].X)
                            {
                                if ((LShalby[0].X + LShalby[0].im[0].Width + 3 >= LMaze[i].X &&
                                     LShalby[0].X <= (LMaze[i].X + LMaze[i].W) &&
                                     LShalby[0].Y >= LMaze[i].Y &&
                                     LShalby[0].Y <= (LMaze[i].Y + LMaze[i].H)))
                                {
                                    j = i;
                                    break;
                                }
                            }
                        }
                        if (j == -1)
                        {
                            LShalby[0].X += 5;
                        }
                        LShalby[0].iFrame = 0;
                    }
                }
                break;

            case Keys.Up:
                if (HalaG == 0)
                {
                    if (Pause == 0)
                    {
                        for (i = 0; i < LMaze.Count; i++)
                        {
                            if (LMaze[i].Y <= LShalby[0].Y)
                            {
                                if (LShalby[0].X >= LMaze[i].X &&
                                    LShalby[0].X <= (LMaze[i].X + LMaze[i].W) &&
                                    LShalby[0].Y >= LMaze[i].Y &&
                                    LShalby[0].Y <= (LMaze[i].Y + LMaze[i].H))
                                {
                                    //LShalby[0].Y -= 5;
                                    j = i;
                                    break;
                                }
                            }
                        }
                        if (j == -1)
                        {
                            LShalby[0].Y -= 5;
                        }

                        //LShalby[0].iFrame = 2;
                    }
                }
                break;

            case Keys.Down:
                if (HalaG == 0)
                {
                    if (Pause == 0)
                    {
                        for (i = 0; i < LMaze.Count; i++)
                        {
                            if (LMaze[i].Y >= LShalby[0].Y)
                            {
                                if (LShalby[0].X >= LMaze[i].X &&
                                    LShalby[0].X <= (LMaze[i].X + LMaze[i].W) &&
                                    LShalby[0].Y + LShalby[0].im[0].Height >= LMaze[i].Y &&
                                    LShalby[0].Y + LShalby[0].im[0].Height <= (LMaze[i].Y + LMaze[i].H))
                                {
                                    //LShalby[0].Y += 5;
                                    j = i;
                                    break;
                                }
                            }
                        }
                        if (j == -1)
                        {
                            LShalby[0].Y += 5;
                        }
                        //LShalby[0].iFrame = 2;
                    }
                }
                break;

            case Keys.Space:
                if (HalaG == 1)
                {
                    t.Start();
                    FlagBoo = 0;
                    HalaG   = 0;
                    LHalaG.Remove(LHalaG[0]);
                    LShalby[0].X      = 10;
                    LShalby[0].Y      = this.ClientSize.Height / 2 - 50;
                    LBoo2[0].iFrame   = 0;
                    LShalby[0].iFrame = 0;
                    CActorBoo1 pnn3 = new CActorBoo1();
                    pnn3.X  = this.ClientSize.Width - 80;
                    pnn3.Y  = 58;
                    pnn3.im = new Bitmap("boo 1.png");
                    pnn3.im.MakeTransparent(pnn3.im.GetPixel(0, 0));
                    LBoo1.Add(pnn3);
                    HalaGW = 0;
                }
                break;
            }
        }
Exemple #2
0
        void Form1_Load(object sender, EventArgs e)
        {
            off = new Bitmap(this.ClientSize.Width, this.ClientSize.Height);
            int        i;
            CActorMaze pnn = new CActorMaze();

            pnn.X = 100;
            pnn.Y = 50;
            pnn.W = this.ClientSize.Width - 2;
            pnn.H = 5;
            LMaze.Add(pnn);
            pnn   = new CActorMaze();
            pnn.X = 100;
            pnn.Y = this.ClientSize.Height - 50;
            pnn.W = this.ClientSize.Width - 2;
            pnn.H = 5;
            LMaze.Add(pnn);
            pnn   = new CActorMaze();
            pnn.X = this.ClientSize.Width - 7;
            pnn.Y = 50;
            pnn.W = 5;
            pnn.H = this.ClientSize.Height - 95;
            LMaze.Add(pnn);
            pnn   = new CActorMaze();
            pnn.X = 100;
            pnn.Y = 50;
            pnn.W = 5;
            pnn.H = (this.ClientSize.Height / 2) - 130;
            LMaze.Add(pnn);
            pnn   = new CActorMaze();
            pnn.X = 0;
            pnn.Y = (this.ClientSize.Height / 2) - 85;
            pnn.W = 100;
            pnn.H = 5;
            LMaze.Add(pnn);
            pnn   = new CActorMaze();
            pnn.X = 100;
            pnn.Y = (this.ClientSize.Height / 2) + 75;
            pnn.W = 5;
            pnn.H = (this.ClientSize.Height) / 2 - 120;
            LMaze.Add(pnn);
            pnn   = new CActorMaze();
            pnn.X = 0;
            pnn.Y = (this.ClientSize.Height / 2) + 75;
            pnn.W = 100;
            pnn.H = 5;
            LMaze.Add(pnn);
            pnn   = new CActorMaze();
            pnn.X = this.ClientSize.Width / 2;
            pnn.Y = 50;
            pnn.W = 30;
            pnn.H = 100;
            LMaze.Add(pnn);
            pnn   = new CActorMaze();
            pnn.X = this.ClientSize.Width / 4;
            pnn.Y = this.ClientSize.Height - 150;
            pnn.W = 30;
            pnn.H = 100;
            LMaze.Add(pnn);
            pnn   = new CActorMaze();
            pnn.X = ((this.ClientSize.Width / 4) * 3) - 30;
            pnn.Y = this.ClientSize.Height - 150;
            pnn.W = 30;
            pnn.H = 100;
            LMaze.Add(pnn);
            pnn   = new CActorMaze();
            pnn.X = this.ClientSize.Width / 2 - 130;
            pnn.Y = this.ClientSize.Height / 2 - 80;
            pnn.W = 280;
            pnn.H = 180;
            LMaze.Add(pnn);
            pnn   = new CActorMaze();
            pnn.X = this.ClientSize.Width / 2 - 125;
            pnn.Y = this.ClientSize.Height / 2 - 75;
            pnn.W = 270;
            pnn.H = 170;
            LMaze.Add(pnn);

            pnn   = new CActorMaze();
            pnn.X = 250;
            pnn.Y = 200;
            pnn.W = 30;
            pnn.H = 200;
            LMaze.Add(pnn);
            pnn   = new CActorMaze();
            pnn.X = 280;
            pnn.Y = 280;
            pnn.W = 70;
            pnn.H = 30;
            LMaze.Add(pnn);
            pnn   = new CActorMaze();
            pnn.X = this.ClientSize.Width / 2 - 200;
            pnn.Y = 150;
            pnn.W = 30;
            pnn.H = 100;
            LMaze.Add(pnn);
            pnn   = new CActorMaze();
            pnn.X = 413;
            pnn.Y = 150;
            pnn.W = 70;
            pnn.H = 30;
            LMaze.Add(pnn);
            pnn   = new CActorMaze();
            pnn.X = 900;
            pnn.Y = 170;
            pnn.W = 160;
            pnn.H = 100;
            LMaze.Add(pnn);
            pnn   = new CActorMaze();
            pnn.X = 1200;
            pnn.Y = 160;
            pnn.W = 159;
            pnn.H = 30;
            LMaze.Add(pnn);
            pnn   = new CActorMaze();
            pnn.X = 1200;
            pnn.Y = 300;
            pnn.W = 30;
            pnn.H = 90;
            LMaze.Add(pnn);

            pnn   = new CActorMaze();
            pnn.X = 553;
            pnn.Y = 470;
            pnn.W = 280;
            pnn.H = 30;
            LMaze.Add(pnn);
            pnn   = new CActorMaze();
            pnn.X = 670;
            pnn.Y = 500;
            pnn.W = 30;
            pnn.H = 50;
            LMaze.Add(pnn);
            ////////////////////////////////////////////////////Maze Creation//////////////////////////////////
            CActorShalby pnn1 = new CActorShalby();

            pnn1.X  = 10;
            pnn1.Y  = this.ClientSize.Height / 2 - 50;
            pnn1.im = new List <Bitmap>();
            for (i = 0; i < 2; i++)
            {
                Bitmap bb = new Bitmap("Shalby " + (i + 1) + ".png");
                pnn1.im.Add(bb);
            }
            pnn1.iFrame = 0;
            LShalby.Add(pnn1);
            ////////////////////////////////////////Shalby creation////////////////////////////////////
            CActorDoor pnn2 = new CActorDoor();

            pnn2.X  = this.ClientSize.Width - 105;
            pnn2.Y  = this.ClientSize.Height - 210;
            pnn2.im = new Bitmap("door.bmp");
            pnn2.im.MakeTransparent(pnn2.im.GetPixel(0, 0));
            LDoor.Add(pnn2);
            ///////////////////////////////////////Door Creation////////////////////////////////////
            CActorBoo1 pnn3 = new CActorBoo1();

            pnn3.X  = this.ClientSize.Width - 80;
            pnn3.Y  = 58;
            pnn3.im = new Bitmap("boo 1.png");
            pnn3.im.MakeTransparent(pnn3.im.GetPixel(0, 0));
            LBoo1.Add(pnn3);
            /////////////////////////////////////Boo 1 creation/////////////////////////////////////////
            CActorSe7lya pnn4 = new CActorSe7lya();

            pnn4.X  = 110;
            pnn4.Y  = 53;
            pnn4.im = new List <Bitmap>();
            for (i = 0; i < 2; i++)
            {
                Bitmap bb = new Bitmap("Se7lya " + (i + 1) + ".png");
                pnn4.im.Add(bb);
            }
            pnn4.iFrame = 0;
            pnn4.dx     = 1;
            pnn4.dy     = 0;
            LSe7lya.Add(pnn4);
            //////////////////////////////////Se7lya Creation///////////////////////////////////////
            CActor3nkbot pnn5 = new CActor3nkbot();

            pnn5.X  = 820;
            pnn5.Y  = this.ClientSize.Height / 2 - 50;
            pnn5.im = new List <Bitmap>();
            for (i = 0; i < 2; i++)
            {
                Bitmap bb = new Bitmap("3ankbot " + (i + 1) + ".png");
                pnn5.im.Add(bb);
            }
            pnn5.iFrame = 0;
            pnn5.dx     = 1;
            pnn5.dy     = 0;
            L3nkbot.Add(pnn5);
            ///////////////////////////////////////////3ankbot Creation///////////////////////////////////////
            CActorBoo2 pnn6 = new CActorBoo2();

            pnn6.X  = 30;
            pnn6.Y  = 150;
            pnn6.im = new List <Bitmap>();
            for (i = 1; i < 3; i++)
            {
                Bitmap bb = new Bitmap("boo " + (i + 1) + ".png");
                pnn6.im.Add(bb);
            }
            pnn6.iFrame = 0;
            LBoo2.Add(pnn6);
            /////////////////////////////////////////////////////boo 2 creation//////////////////////////////////////

            CActorEnergyTank pnn7;
            int tmpx = 550;

            for (i = 0; i < 3; i++)
            {
                pnn7    = new CActorEnergyTank();
                pnn7.X  = tmpx;
                pnn7.Y  = 160;
                pnn7.im = new Bitmap("Energy Tank.png");
                LEnergy.Add(pnn7);
                tmpx += 80;
            }
            tmpx = 380;
            for (i = 0; i < 5; i++)
            {
                pnn7    = new CActorEnergyTank();
                pnn7.X  = tmpx;
                pnn7.Y  = 550;
                pnn7.im = new Bitmap("Energy Tank.png");
                LEnergy.Add(pnn7);
                tmpx += 120;
            }
            pnn7    = new CActorEnergyTank();
            pnn7.X  = 265;
            pnn7.Y  = 285;
            pnn7.im = new Bitmap("Energy Tank.png");
            LEnergy.Add(pnn7);
            pnn7    = new CActorEnergyTank();
            pnn7.X  = 200;
            pnn7.Y  = 550;
            pnn7.im = new Bitmap("Energy Tank.png");
            LEnergy.Add(pnn7);
            pnn7    = new CActorEnergyTank();
            pnn7.X  = 250;
            pnn7.Y  = 550;
            pnn7.im = new Bitmap("Energy Tank.png");
            LEnergy.Add(pnn7);
            pnn7    = new CActorEnergyTank();
            pnn7.X  = 265;
            pnn7.Y  = 285;
            pnn7.im = new Bitmap("Energy Tank.png");
            LEnergy.Add(pnn7);

            pnn7    = new CActorEnergyTank();
            pnn7.X  = this.ClientSize.Width - 120;
            pnn7.Y  = 210;
            pnn7.im = new Bitmap("Energy Tank.png");
            LEnergy.Add(pnn7);
            pnn7    = new CActorEnergyTank();
            pnn7.X  = this.ClientSize.Width - 120;
            pnn7.Y  = 340;
            pnn7.im = new Bitmap("Energy Tank.png");
            LEnergy.Add(pnn7);
            ////////////////////////////////////////////////////////Energy Tank creation////////////////////////////////
            N = RR.Next(4);
            CActorLogo pnn8 = new CActorLogo();

            if (N == 0)
            {
                pnn8.X  = 285;
                pnn8.Y  = 210;
                pnn8.im = new Bitmap("Logo.png");
                pnn8.im.MakeTransparent(pnn8.im.GetPixel(0, 0));
                LLogo.Add(pnn8);
            }
            if (N == 1)
            {
                pnn8.X  = 230;
                pnn8.Y  = this.ClientSize.Height / 2 + 50;
                pnn8.im = new Bitmap("Logo.png");
                pnn8.im.MakeTransparent(pnn8.im.GetPixel(0, 0));
                LLogo.Add(pnn8);
            }
            if (N == 2)
            {
                pnn8.X  = 730;
                pnn8.Y  = 60;
                pnn8.im = new Bitmap("Logo.png");
                pnn8.im.MakeTransparent(pnn8.im.GetPixel(0, 0));
                LLogo.Add(pnn8);
            }
            if (N == 3)
            {
                pnn8.X  = 1190;
                pnn8.Y  = 580;
                pnn8.im = new Bitmap("Logo.png");
                pnn8.im.MakeTransparent(pnn8.im.GetPixel(0, 0));
                LLogo.Add(pnn8);
            }
            //////////////////////////////////////////////////////////////Logo Creation//////////////////////////////////
            CActorPause pnn9 = new CActorPause();

            pnn9.X  = 35;
            pnn9.Y  = 75;
            pnn9.im = new List <Bitmap>();
            for (i = 0; i < 2; i++)
            {
                Bitmap bb = new Bitmap("pause " + (i + 1) + ".png");
                pnn9.im.Add(bb);
            }
            pnn9.iFrame = 0;
            LPause.Add(pnn9);
            ////////////////////////////////////////////////////////////Pause////////////////////////////////
            CActorG pnn10 = new CActorG();

            pnn10.X  = 700;
            pnn10.Y  = 53;
            pnn10.im = new List <Bitmap>();
            for (i = 0; i < 2; i++)
            {
                Bitmap bb = new Bitmap("G" + (i + 1) + ".png");
                pnn10.im.Add(bb);
            }
            pnn10.iFrame = 0;
            pnn10.dx     = 1;
            LG.Add(pnn10);
        }