Ejemplo n.º 1
0
 private void Form_game_Load(object sender, EventArgs e)
 {
     this.BackColor = System.Drawing.Color.Black;
     this.player1   = new Tank(imageList1);
     this.Controls.Add(player1);
 }
Ejemplo n.º 2
0
        public void Down(Tank tnk)
        {
            x = x > 20 ? x : 20;
            x = x < 1200 ? x : 1200;
            y = y > 10 ? y : 10;
            y = y < 770 ? y : 770;


            if (x + r * 2 > kutuX && x < kutuX + 35 + r * 2 && y + r * 2 > kutuY - 30 && y < kutuY + 30 + r * 2 && kutuAcik)
            {
                if (x > kutuX)
                {
                    x++;
                }
                if (x < kutuX)
                {
                    x--;
                }
                if (y > kutuY)
                {
                    y++;
                }
                if (y < kutuY)
                {
                    y--;
                }
            }
            else if (x + r * 2 > 550 && x < 670 + r * 2 && y + r * 2 > 325 && y < 445 + r * 2 && cerceveSoru == false)
            {
                if (x > 550)
                {
                    x++;
                }
                if (x < 670)
                {
                    x--;
                }
                if (y > 325)
                {
                    y++;
                }
                if (y < 445)
                {
                    y--;
                }
            }

            else if (x + r * 2 > tnk.x && x < tnk.x + r * 2 && y + r * 2 > tnk.y && y < tnk.y + r * 2)
            {
                if (x > tnk.x)
                {
                    x++;
                }
                if (x < tnk.x)
                {
                    x--;
                }
                if (y > tnk.y)
                {
                    y++;
                }
                if (y < tnk.y)
                {
                    y--;
                }
            }
            else
            {
                x -= (float)((Resim.FrameTime * 300) * Math.Sin(rotation * Math.PI / 180));
                y += (float)((Resim.FrameTime * 300) * Math.Cos(rotation * Math.PI / 180));
            }
        }
Ejemplo n.º 3
0
        public void MermiCiz(Tank tank1, Tank tank2)
        {
            ozellikDonus += 20 * Resim.FrameTime;


            if (ozellikBuyuklukSoru == true)
            {
                if (ozellikBuyukluk > 150)
                {
                    ozellikBuyuklukSoru = false;
                }
                else
                {
                    ozellikBuyuklukSoru = true;
                    ozellikBuyukluk    += 20 * Resim.FrameTime;
                    sayacOrtala++;
                    if (sayacOrtala == 2)
                    {
                        ortala     += 20 * Resim.FrameTime;
                        sayacOrtala = 0;
                    }
                }
            }
            if (ozellikBuyuklukSoru == false)
            {
                if (ozellikBuyukluk < 100)
                {
                    ozellikBuyuklukSoru = true;
                }
                else
                {
                    ozellikBuyuklukSoru = false;
                    ozellikBuyukluk    -= 20 * Resim.FrameTime;
                    sayacOrtala++;
                    if (sayacOrtala == 2)
                    {
                        ortala     -= 20 * Resim.FrameTime;
                        sayacOrtala = 0;
                    }
                }
            }
            if (mermiZaman > 8.0f && (!tank1.oyunBitti && !tank2.oyunBitti))
            {
                Resim.Ciz(mermi, mermix - ortala, mermiy - ortala, ozellikBuyukluk, ozellikBuyukluk, ozellikDonus);

                if (mermiy + 35 > tank1.y && mermiy + 35 < tank1.y + 70 && mermix + 35 > tank1.x && mermix + 35 < tank1.x + 35 * 2)
                {
                    SFMLSes.Ses.SesCal(mermiSes);
                    mermiZaman = 0;
                    if (tank1.mermiHakki <= 0)
                    {
                        tank1.mermiHakki = 30;
                    }
                    else
                    {
                        tank1.mermiHakki += 30;
                    }
                }
                if (mermiy + 35 > tank2.y && mermiy + 35 < tank2.y + 70 && mermix + 35 > tank2.x && mermix + 35 < tank2.x + 35 * 2)
                {
                    SFMLSes.Ses.SesCal(mermiSes);
                    mermiZaman = 0;
                    if (tank2.mermiHakki <= 0)
                    {
                        tank2.mermiHakki = 30;
                    }
                    else
                    {
                        tank2.mermiHakki += 30;
                    }
                }
            }
            else
            {
                do
                {
                    mermix = r.Next(50, 1180);
                    mermiy = r.Next(10, 760);
                } while (mermix + 35 * 2 > 550 && mermix < 670 + 35 * 2 && mermiy + 35 * 2 > 325 && mermiy < 445 + 35 * 2);
            }
            mermiZaman += Resim.FrameTime;
        }
Ejemplo n.º 4
0
        static void Main()
        {
            Resim.Yeni(1280, 960, "Ferhat SEZER", false);
            int bg = Resim.Ekle("img\\bigbg.png");


            Resim.SetFPSLimit(60);

            Tank     tank1      = new Tank(35, 400, 400);
            Tank     tank2      = new Tank(35, 800, 400);
            Mermiler tank1Mermi = new Mermiler();
            Mermiler tank2Mermi = new Mermiler();
            Ozellik  ozellik    = new Ozellik();

            while (Resim.Acik())
            {
                Resim.Baslat();
                Resim.Ciz(bg, 0, 0, 1280, 960);



                if (Resim.KeyPressed(SFML.Window.Keyboard.Key.D))
                {
                    tank1.Right();
                }
                if (Resim.KeyPressed(SFML.Window.Keyboard.Key.A))
                {
                    tank1.Left();
                }
                if (Resim.KeyPressed(SFML.Window.Keyboard.Key.W))
                {
                    if (!tank1.oyunBitti && !tank2.oyunBitti)
                    {
                        tank1.Display(Resim.FrameTime);
                        tank1.Up(tank2);
                    }
                }

                if (Resim.KeyPressed(SFML.Window.Keyboard.Key.S))
                {
                    if (!tank1.oyunBitti && !tank2.oyunBitti)
                    {
                        tank1.Display(Resim.FrameTime);
                        tank1.Down(tank2);
                    }
                }

                if (Resim.KeyPressed(SFML.Window.Keyboard.Key.Right))
                {
                    tank2.Right();
                }
                if (Resim.KeyPressed(SFML.Window.Keyboard.Key.Left))
                {
                    tank2.Left();
                }
                if (Resim.KeyPressed(SFML.Window.Keyboard.Key.Up))
                {
                    if (!tank2.oyunBitti && !tank1.oyunBitti)
                    {
                        tank2.Display(Resim.FrameTime);
                        tank2.Up(tank1);
                    }
                }
                if (Resim.KeyPressed(SFML.Window.Keyboard.Key.Down))
                {
                    if (!tank2.oyunBitti && !tank1.oyunBitti)
                    {
                        tank2.Display(Resim.FrameTime);
                        tank2.Down(tank1);
                    }
                }

                if (Resim.KeyPressed(SFML.Window.Keyboard.Key.RControl))
                {
                    if (!tank2.oyunBitti && !tank1.oyunBitti)
                    {
                        tank2Mermi.MermiEkle(new Mermi(tank2), Resim.FrameTime, tank2);
                    }
                }
                if (Resim.KeyPressed(SFML.Window.Keyboard.Key.F))
                {
                    if (!tank2.oyunBitti && !tank1.oyunBitti)
                    {
                        tank1Mermi.MermiEkle(new Mermi(tank1), Resim.FrameTime, tank1);
                    }
                }
                tank1Mermi.MermiHakkiYaz("Kirmizi TANK", 20, 40, tank1);
                tank2Mermi.MermiHakkiYaz("Mavi TANK", 960, 40, tank2);



                tank1.Ciz(20, 850, 1);
                tank2.Ciz(750, 850, 2);
                ozellik.CanCiz(tank1, tank2);
                ozellik.MermiCiz(tank1, tank2);
                ozellik.OzelGucCerceve(tank1, tank2);
                ozellik.OzelGucCiz(tank1, tank2);
                ozellik.KutuCiz(tank1, tank2);
                ozellik.OzelGucKontrol(tank1, tank2);

                tank1Mermi.MermileriCiz(tank2, tank1, tank1);
                tank2Mermi.MermileriCiz(tank1, tank2, tank1);
                tank1.KalkanCiz();
                tank2.KalkanCiz();
                ozellik.TekrarOyna(tank1, tank2);

                Resim.Bitir();
            }
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            var t3list      = new List <Tank>();
            var panteraList = new List <Tank>();
            int liveT34     = 0;
            int liveP       = 0;

            for (int i = 0; i < 3; i++)
            {
                t3list.Add(new Tank("t34 - " + i));
                panteraList.Add(new Tank("Pantera - " + i));
                liveT34 += t3list[i].health;
                liveP   += panteraList[i].health;
            }
            Console.WriteLine("T34 = " + Tank.Life(t3list) + "   Pantera " + Tank.Life(panteraList));


            while ((liveT34 > 0 || liveT34 > 0) && (t3list.Count > 0 || panteraList.Count > 0))
            {
                for (var i = 0; i < t3list.Count; i++)
                {
                    Tank T34 = t3list[i];

                    for (var j = 0; j < panteraList.Count; j++)
                    {
                        Tank TankPanter = panteraList[j];

                        var a = t3list[i] * panteraList[j];

                        Tank.print(T34, TankPanter);


                        liveT34 -= TankPanter.loss;
                        liveP   -= T34.loss;

                        if (TankPanter.health <= 0)
                        {
                            TankPanter.IsDead(panteraList);
                        }

                        if (T34.health <= 0)
                        {
                            T34.IsDead(t3list);
                        }
                        for (int i1 = 0; i1 < t3list.Count; i1++)
                        {
                            Console.WriteLine($"T34 {i1} = " + t3list[i1].health);
                        }
                        for (int i2 = 0; i2 < panteraList.Count; i2++)
                        {
                            Console.WriteLine($" Pantera {i2} = " + panteraList[i2].health);
                        }



                        Console.WriteLine("T34 = " + Tank.Life(t3list) + "   Pantera " + Tank.Life(panteraList));
                    }
                }
            }
            if (Tank.Life(t3list) > Tank.Life(panteraList))
            {
                Console.WriteLine("Winner Command T-34");
            }
            else
            {
                Console.WriteLine("Winner Command Pantera");
            }
        }