Search the Community
Showing results for tags 'araba'.
-
Arkadaşlar duyduguma göre bilgisayara yüklenen bir proğram ile araç tramer kaydı sorgulanabiliniyormuş. Gerçekten böyle bir proğram varmı varsa nasıl bulurum telefon mesajına 4 tl gibi bir ücret ödemek istemiyorum. Her arabada 4 tl biraz masraflı oluyor. Bilgisi olan arkadaşlardan yardımlarını istiyorum.
-
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