Sayıyı tahmin etme oyunu-C#

[code lang=”csharp”]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms; //https://www.gorselprogramlama.com
namespace Game___Oyun
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

Random r = new Random();
int sayi, skor;

private void oyunuBaşlatToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("Oyun Kuralları = Oyuns süresi 300 saniyedir her yanlış tahminde sürenizden 5 saniye kesilcek bu yüzden çok dikkatli cevap veriniz [[[SEZER YAZILIM]]] ", "Oyun kuralları", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
MessageBox.Show("OYUN BAŞLIYOR", "Başlıyor", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
button1.Enabled = true;
sayi = r.Next(1000);
textBox1.Enabled = true;
timer1.Start();//https://www.gorselprogramlama.com
}
private void button1_Click(object sender, EventArgs e)
{

//https://www.gorselprogramlama.com
int tahmin = int.Parse(textBox1.Text);
if (sayi < tahmin)
{
label2.Text = "Daha küçük bir sayı giriniz";
sayac += 5;
}
else if (sayi > tahmin)
{
label2.Text = "Daha büyük bir sayı giriniz";
sayac += 5;
}
else if (sayi == tahmin)
{
skor = 300 – sayac;
MessageBox.Show("TEBRİKLER KAZANDINIZ SKORUNUZ =  " + skor, "KAZANDINIZ", MessageBoxButtons.OK, MessageBoxIcon.Information);
//https://www.gorselprogramlama.com
}
else
{
MessageBox.Show("kaybettiniz", "kaybettiniz", MessageBoxButtons.OK, MessageBoxIcon.None);
}
textBox1.Clear();
}
int sayac;
private void timer1_Tick(object sender, EventArgs e)
{
sayac++;
if (sayac == 300)
{
timer1.Stop();
MessageBox.Show("Süre Doldu", "uyarı", MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBox.Show("Game Over", "uyarı", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.Close();
}
progressBar1.Value = sayac;
}

}
}

[/code]

Yorumlar 1

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir