Exemplo n.º 1
0
        void Form1_Load(object sender, EventArgs e)
        {
            off = new Bitmap(this.ClientSize.Width, this.ClientSize.Height);
            CActorFrog pnn = new CActorFrog();

            pnn.X     = this.ClientSize.Width / 2 - 150;
            pnn.Y     = this.ClientSize.Height / 2 - 80;
            pnn.angle = 0;
            pnn.im    = new Bitmap("frog.png");
            Frog.Add(pnn);


            image = Frog[0].im;

            /* XS = this.ClientSize.Width / 2 - 100;
             * YS = this.ClientSize.Height / 2 - 50;*/
            /////////////////////////////////////////////////Frog Creation/////////////////////////////

            CActorLine pnn1 = new CActorLine();

            pnn1.XS = this.ClientSize.Width / 2 - 50;
            pnn1.YS = this.ClientSize.Height / 2;
            pnn1.XE = this.ClientSize.Width / 2 - 50;
            pnn1.YE = (this.ClientSize.Height / 2) + 200;
            LBall.Add(pnn1);

            CActorBall pnn2 = new CActorBall();

            pnn2.xC  = this.ClientSize.Width / 2 - 50;
            pnn2.yC  = this.ClientSize.Height / 2;
            pnn2.dir = 0;
            int N = RR.Next(0, 4);

            if (N == 0)
            {
                pnn2.Clr = 1;
                pnn2.im  = new Bitmap("b1.png");
                pnn2.im.MakeTransparent(pnn2.im.GetPixel(0, 0));
            }
            if (N == 1)
            {
                pnn2.Clr = 2;
                pnn2.im  = new Bitmap("b2.png");
                pnn2.im.MakeTransparent(pnn2.im.GetPixel(0, 0));
            }
            if (N == 2)
            {
                pnn2.Clr = 3;
                pnn2.im  = new Bitmap("b3.png");
                pnn2.im.MakeTransparent(pnn2.im.GetPixel(0, 0));
            }
            if (N == 3)
            {
                pnn2.im = new Bitmap("b4.png");
                pnn2.im.MakeTransparent(pnn2.im.GetPixel(0, 0));
                pnn2.Clr = 4;
            }
            B.Add(pnn2);
        }
Exemplo n.º 2
0
        void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.Enter:
                while (move1 <= 1)
                {
                    PointF     Point1 = Curve.CalcCurvePointAtTime(move1);
                    CActorLine pnn    = new CActorLine();
                    pnn.XS = Point1.X;
                    pnn.YS = Point1.Y;
                    move1 += 0.01f;
                    Point1 = Curve.CalcCurvePointAtTime(move1);
                    pnn.XE = Point1.X;
                    pnn.YE = Point1.Y;

                    pnn.dx    = pnn.XE - pnn.XS;
                    pnn.dy    = pnn.YE - pnn.YS;
                    pnn.m     = pnn.dy / pnn.dx;
                    pnn.inv_m = pnn.dx / pnn.dy;
                    Line.Add(pnn);
                }
                FlagB = 1;
                FlagL = 1;
                break;

            case Keys.Space:
                FlagL          = 0;
                LBall[0].dx    = LBall[0].XE - LBall[0].XS;
                LBall[0].dy    = LBall[0].YE - LBall[0].YS;
                LBall[0].m     = LBall[0].dy / LBall[0].dx;
                LBall[0].inv_m = LBall[0].dx / LBall[0].dy;

                CActorBall pnn2 = new CActorBall();
                pnn2.xC  = LBall[0].XS;
                pnn2.yC  = LBall[0].YS;
                pnn2.dir = 0;
                int N = RR.Next(0, 4);
                if (N == 0)
                {
                    pnn2.Clr = 1;
                    pnn2.im  = new Bitmap("b1.png");
                    pnn2.im.MakeTransparent(pnn2.im.GetPixel(0, 0));
                }
                if (N == 1)
                {
                    pnn2.Clr = 2;
                    pnn2.im  = new Bitmap("b2.png");
                    pnn2.im.MakeTransparent(pnn2.im.GetPixel(0, 0));
                }
                if (N == 2)
                {
                    pnn2.Clr = 3;
                    pnn2.im  = new Bitmap("b3.png");
                    pnn2.im.MakeTransparent(pnn2.im.GetPixel(0, 0));
                }
                if (N == 3)
                {
                    pnn2.im = new Bitmap("b4.png");
                    pnn2.im.MakeTransparent(pnn2.im.GetPixel(0, 0));
                    pnn2.Clr = 4;
                }
                B.Add(pnn2);
                B[0].dir = 1;
                break;
            }
        }