Jump to content

Search the Community

Showing results for tags 'hareket'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • TnC Genel
    • Reklam-Bağış-Sponsorluk
    • Duyurular
  • Modifiye Edilmiş İşletim Sistemleri
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows Diğer
    • Windows Xp
    • Diğer İşletim Sistemleri
    • MultiBoot Sistemler
    • Linux Distributions
  • Bilgisayar Dünyası Genel
    • Her Zaman Gerekliler
    • Yazılım
    • Donanım
    • Sosyal Medya - Anında Mesajlaşma
    • Yararlı Linkler
  • TnC PROGRAM-APPZ
    • TNC-TR Çalışmaları
    • Program-Appz
    • Program-Appz - Ebook İstek
    • AIO
    • Portable Programlar
    • Türkçe Yamalar
    • Katılımsız - Unattended
  • Programlama
    • AutoIT
    • AutoPlay Media Studio
    • C#
  • Webmaster
    • Webmaster Sorunları & Çözüm Yolları
    • Hosting & Domain
  • TnC Multimedya
    • Multimedya Istek
    • Kendi Müziğiniz
  • TnC Oyun - Games
    • Oyun-Games
    • Oyun İstek
  • Cep Telefonu - Mobile
    • GSM Bilgi Paylaşımı
    • GSM Multimedya
    • iPhone / iPod
    • Android
    • Diğer GSM Program & Oyun
  • TnC Diğer
    • Teknoloji Haberleri
    • Alım-Satım
    • Kültür-Sanat
    • Sohbet-Chat
    • Çöp Kutusu
    • Anketler
  • Haberler Deneme
  • Olta Balıkçıları Kulübü's Herkes Ekipmanını Paylaşsın
  • Haritacılar's Konular
  • PUBG Oyuncuları's Konular
  • Satranç - Chess's Konular

Calendars

  • Community Calendar
  • Satranç - Chess's Takvim Etkinlikleri

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Facebook


Skype


Twitter


Google+


Steam



Found 1 result

  1. KintaRo

    C# Araba Oyunu

    Merhaba arkadaşlar. http://www.tnctr.com/topic/280916-c-nesnenin-hareket-ettidhini-goerebilmek bu konuyu gördükten sonra bir örnekte ben yapıp nasıl olacağını denemek istedim :) - Ortadan otoyol çizgileri geçiyor - sağ ve soldan random nesneler geçiyor - araba sağa ve sola hareket edebiliyor. bodoslama dalınca bu kadar oldu. Zaman bulursam gelen nesnelerden kaçma ve puan toplama gibi özellikler eklemek isterim. Belki sizin fikirlerinizle dğeiştirebilir ya da hataları görebilirim. Kodlar: [spoiler] using System; using System.Drawing; using System.Threading; using System.Windows.Forms; namespace c_racing { public partial class Form1 : Form { #region VARS int start = 3; // başlangıç sayacı bool basladi = false; // yarış başlangıç kontrolü string yon = null; // sağ sol kontrolü bool donusBitti = true; // sağa veya sola dönüşün bitiş kontrolü #endregion #region FORM EVENTS public Form1() { CheckForIllegalCrossThreadCalls = false; InitializeComponent(); } private void Form1_KeyUp(object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.Right: yon = "sag"; try { bgWorkerDonus.RunWorkerAsync(); } catch { } break; case Keys.Left: yon = "sol"; try { bgWorkerDonus.RunWorkerAsync(); } catch { } break; } } #endregion #region FUNCS // sağa dönüş private void Sag() { if (basladi & donusBitti) { donusBitti = false; picAraba.Image = c_racing.Properties.Resources.araba_donus_sag; for (int i = 0; i < 170; i++) { picAraba.Location = new Point(i, picAraba.Location.Y); Thread.Sleep(5); } picAraba.Image = c_racing.Properties.Resources.araba; donusBitti = true; } } // sola dönüş private void Sol() { if (basladi & donusBitti) { donusBitti = false; picAraba.Image = c_racing.Properties.Resources.araba_donus_sol; for (int i = 0; i < 170; i++) { picAraba.Location = new Point(170 - i, picAraba.Location.Y); Thread.Sleep(5); } picAraba.Image = c_racing.Properties.Resources.araba; donusBitti = true; } } // sağa ve sola döndürme private void Dondur() { if (yon == "sag") { if (picAraba.Location.X < 2) Sag(); } else { if (picAraba.Location.X > 168) Sol(); } } // otoyol çizgileri private void CizgiOlustur(string isim, int locY, EventHandler handle) { PictureBox pic = new PictureBox(); pic.Name = isim; pic.Width = 13; pic.Height = 110; pic.Location = new Point(145, locY); pic.Image = c_racing.Properties.Resources.cizgi; this.Controls.Add(pic); pic.BringToFront(); pic.LocationChanged += handle; } // sağ ve solda çıkacak nesneler private void NesneGonder() { const int sleep = 20; Random rnd = new Random(); int r = rnd.Next(1, 4); if (r == 1) { picCali.Visible = true; picCali.BringToFront(); picCali.Location = new Point(4, 10); while (picCali.Location.Y < 480) { picCali.Location = new Point(picCali.Location.X, picCali.Location.Y + 10); Thread.Sleep(sleep); } picCali.Visible = false; } else if (r == 2) { picTabela.Visible = true; picTabela.BringToFront(); picTabela.Location = new Point(4, 10); while (picTabela.Location.Y < 480) { picTabela.Location = new Point(picTabela.Location.X, picTabela.Location.Y + 10); Thread.Sleep(sleep); } picTabela.Visible = false; } else if (r == 3) { picCali.Visible = true; picCali.BringToFront(); picCali.Location = new Point(340, 10); while (picCali.Location.Y < 480) { picCali.Location = new Point(picCali.Location.X, picCali.Location.Y + 10); Thread.Sleep(sleep); } picCali.Visible = false; } else if (r == 4) { picTabela.Visible = true; picTabela.BringToFront(); picTabela.Location = new Point(340, 10); while (picTabela.Location.Y < 480) { picTabela.Location = new Point(picTabela.Location.X, picTabela.Location.Y + 10); Thread.Sleep(sleep); } } picTabela.Visible = false; } #endregion #region BUTTON EVENTS // geri sayımı başlat private void btnBaslat_Click(object sender, EventArgs e) { btnDurdur.Enabled = true; btnBaslat.Enabled = false; tmrStart.Start(); } // oyunu durdur be kontrolleri sıfırla private void btnDurdur_Click(object sender, EventArgs e) { start = 3; this.Controls.Find("pic1", true)[0].Dispose(); this.Controls.Find("pic2", true)[0].Dispose(); this.Controls.Find("pic3", true)[0].Dispose(); this.Controls.Find("pic4", true)[0].Dispose(); picAraba.Visible = false; lblBaslik.Visible = true; btnBaslat.Enabled = true; btnDurdur.Enabled = false; tmrCizgi.Stop(); } #endregion #region EVENTHANDLER // otoyol çizgileri başa sarmak için eventhandler private void pic_LocationChanged(object sender, EventArgs e) { PictureBox a = (PictureBox)sender; { if (a.Location.Y > 480) a.Location = new Point(a.Location.X, -110); } } #endregion #region TIMERLAR // otoyol çizgilerini göster private void tmrCizgi_Tick(object sender, EventArgs e) { for (int i = 0; i < this.Controls.Count; i++) { if (this.Controls[i].Name == "pic1") { PictureBox control1 = this.Controls[i] as PictureBox; control1.Location = new Point(178, control1.Location.Y + 10); break; } } for (int i = 0; i < this.Controls.Count; i++) { if (this.Controls[i].Name == "pic2") { PictureBox control2 = this.Controls[i] as PictureBox; control2.Location = new Point(178, control2.Location.Y + 10); break; } } for (int i = 0; i < this.Controls.Count; i++) { if (this.Controls[i].Name == "pic3") { PictureBox control3 = this.Controls[i] as PictureBox; control3.Location = new Point(178, control3.Location.Y + 10); break; } } for (int i = 0; i < this.Controls.Count; i++) { if (this.Controls[i].Name == "pic4") { PictureBox control4 = this.Controls[i] as PictureBox; control4.Location = new Point(178, control4.Location.Y + 10); break; } } } // oyunu başlat private void tmrStart_Tick(object sender, EventArgs e) { lblSayac.Text = start.ToString(); lblSayac.Visible = true; start--; if (start < 0) { CizgiOlustur("pic1", -50, pic_LocationChanged); CizgiOlustur("pic2", 100, pic_LocationChanged); CizgiOlustur("pic3", 250, pic_LocationChanged); CizgiOlustur("pic4", 400, pic_LocationChanged); basladi = true; picAraba.BringToFront(); picAraba.Visible = true; btnDurdur.Enabled = true; btnBaslat.Enabled = false; tmrCizgi.Interval = 10; tmrCizgi.Start(); //tmrNesne.Start(); tmrNesneHareket.Start(); lblBaslik.Visible = false; lblSayac.Visible = false; tmrStart.Stop(); } } // nesneler için bg workeri zamanla private void tmrNesneHareket_Tick(object sender, EventArgs e) { try { bgWorkerNesne.RunWorkerAsync(); } catch { } } #endregion #region BG WORKER // sağa ve sola dönüş için bg worker private void bgWorkerDonus_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { Dondur(); } // sağdan ve soldan çıkacak nesneler için bg worker private void bgWorkerNesne_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { NesneGonder(); } #endregion } } [/spoiler] Proje: https://yadi.sk/d/Jua8R1hWg7Juu
×
×
  • Create New...