C#'da Gitar Oyunu

GİTAR OYUNU HAKKINDA BİLGİ
Gitar oyunu benim son zamanlarda derslerden bulduğum boş zaman içinde C# Windows Application’da yaptığım bir oyundur. Boş zamanda can sıkıntısı için yapılan projeler bile programcıyı geliştirir, o yüzden bir projeye başlamaktan asla çekinmeyin. En fazla projeniz yarım kalır ve asla bir projenin size ne kadar bilgi ve tecrübe katacağını önceden bilemezsiniz.
Gitar oyunu tek kişilk oynanan bir oyundur, oyunu Guitar Hero adlı oyundan esinlenerek programladım. Notalar sıra sıra geliyor, sizde dopru notalara doğru zamanda basmaya çalışarak skor elde ediyorsunuz. Oyunda aynı zamanda Score Board’da bulunuyor.
Oyunu oynamadan önce herhangi bir şarkı atmanız gerekecek. Attığınız şarkının ismi 1 olmalı ve uzantısı wav olmalıdır. Çünkü oyun sadece 1 isminde bir şarkıyı çalmak için programlanmıştır.

GİTAR OYUNUN’DAN BAZI RESİMLER


GİTAR OYUNU’NUN KODLARI
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;
using System.Media;
using System.IO;
namespace Gitar_Oyunu
{
public partial class Form1 : Form
{
SoundPlayer nota1 = new SoundPlayer();
SoundPlayer dat = new SoundPlayer();
int skor;
int cikis;
int zaman;
int baslangic;
public Form1()
{
InitializeComponent();
}

public void timer1_Tick(object sender, EventArgs e)
{
textBox2.Focus();
//pictureBox13.Top = pictureBox13.Top + 1;
int a = sayiuret();

if (a == 1)
{
timer2.Enabled = true;
}
if (a == 2)
{
timer3.Enabled = true;
}
if (a == 3)
{
timer4.Enabled = true;
}
if (a == 4)
{
timer5.Enabled = true;
}
if (a == 5)
{
timer6.Enabled = true;
}
if (a == 6)
{
timer7.Enabled = true;
}

}
private int sayiuret()
{
Random rnd = new Random();
int sayi = rnd.Next(1, 10);
return sayi;
}

private void timer2_Tick(object sender, EventArgs e)
{
pictureBox13.Top = pictureBox13.Top + 4;
}

private void timer3_Tick(object sender, EventArgs e)
{
pictureBox14.Top = pictureBox14.Top + 4;
}

private void timer4_Tick(object sender, EventArgs e)
{
pictureBox15.Top = pictureBox15.Top + 4;
}

private void timer5_Tick(object sender, EventArgs e)
{
pictureBox16.Top = pictureBox16.Top + 4;
}

private void timer6_Tick(object sender, EventArgs e)
{
pictureBox17.Top = pictureBox17.Top + 4;
}

private void timer7_Tick(object sender, EventArgs e)
{
pictureBox18.Top = pictureBox18.Top + 4;
}

public void textBox2_KeyPress(object sender, KeyPressEventArgs e)
{
Char temizle = char.Parse(“u”);

if (e.KeyChar == temizle)
{
textBox2.Text = “”;
}
}

private void textBox2_TextChanged(object sender, EventArgs e)
{
if (textBox2.Text == “u”)
{
textBox2.Text = “”;
}
}

public void timer8_Tick(object sender, EventArgs e)
{
if (textBox2.Text != “1” && pictureBox13.Top > 500 && pictureBox13.Top < 550 ||
textBox2.Text != “2” && pictureBox14.Top > 500 && pictureBox14.Top < 550 ||
textBox2.Text != “3” && pictureBox15.Top > 500 && pictureBox15.Top < 550 ||
textBox2.Text != “4” && pictureBox16.Top > 500 && pictureBox16.Top < 550 ||
textBox2.Text != “5” && pictureBox17.Top > 500 && pictureBox17.Top < 550 ||
textBox2.Text != “6” && pictureBox18.Top > 500 && pictureBox18.Top < 550)
{
label1.Text = Convert.ToString(skor);
skor = skor – 123;
}

#region yenileme
{
if (pictureBox13.Top > 700)
{
pictureBox13.Top = 12;
timer2.Enabled = false;
textBox2.Focus();
}
if (pictureBox14.Top > 700)
{
pictureBox14.Top = 12;
timer3.Enabled = false;
textBox2.Focus();
}
if (pictureBox15.Top > 700)
{
pictureBox15.Top = 12;
timer4.Enabled = false;
textBox2.Focus();
}
if (pictureBox16.Top > 700)
{
pictureBox16.Top = 12;
timer5.Enabled = false;
textBox2.Focus();
}
if (pictureBox17.Top > 700)
{
pictureBox17.Top = 12;
timer6.Enabled = false;
textBox2.Focus();
}
if (pictureBox18.Top > 700)
{
pictureBox18.Top = 12;
timer7.Enabled = false;
textBox2.Focus();
}
if (textBox2.TextLength > 1)
{
textBox2.Clear();
}
}
#endregion
}

private void timer9_Tick(object sender, EventArgs e)
{
if (textBox2.Text == “1” && pictureBox13.Top > 500 && pictureBox13.Top < 550 ||
textBox2.Text == “2” && pictureBox14.Top > 500 && pictureBox14.Top < 550 ||
textBox2.Text == “3” && pictureBox15.Top > 500 && pictureBox15.Top < 550 ||
textBox2.Text == “4” && pictureBox16.Top > 500 && pictureBox16.Top < 550 ||
textBox2.Text == “5” && pictureBox17.Top > 500 && pictureBox17.Top < 550 ||
textBox2.Text == “6” && pictureBox18.Top > 500 && pictureBox18.Top < 550)
{
label1.Text = Convert.ToString(skor);
skor = skor + 123;
}
}

private void timer10_Tick(object sender, EventArgs e)
{
Random deneme = new Random();
int deneme1 = deneme.Next(1, 4);

if (skor < -500 && deneme1 == 1)
{
timer10.Enabled = false;
timer11.Enabled = true;
MessageBox.Show(“Loser”);
}
if (skor < -500 && deneme1 == 2)
{
timer10.Enabled = false;
timer11.Enabled = true;
MessageBox.Show(“Bad”);
}
if (skor < -500 && deneme1 == 3)
{
timer10.Enabled = false;
timer11.Enabled = true;
MessageBox.Show(“Lame”);
}
label4.Text = Convert.ToString(zaman);
if (skor > 1500 && zaman >= 412)
{
timer10.Enabled = false;
timer11.Enabled = true;
MessageBox.Show(“Congratulations, You Got ” + skor);
FileStream save = new FileStream(@”save.text”, FileMode.Append, FileAccess.Write);
StreamWriter yazi = new StreamWriter(save);
yazi.WriteLine(label6.Text + ” ” + label1.Text);
yazi.Close();
this.Close();

}
if (skor < 1500 && zaman >= 412)
{
timer10.Enabled = false;
timer11.Enabled = true;
MessageBox.Show(“You Suck, You Got ” + skor);
}
}

private void timer11_Tick(object sender, EventArgs e)
{
label3.Text = Convert.ToString(cikis);
cikis++;
if (cikis == 1)
{
timer1.Enabled = false;
nota1.Stop();
}
}

private void zamant_Tick(object sender, EventArgs e)
{
label4.Text = Convert.ToString(zaman);
zaman++;
}

private void button2_Click(object sender, EventArgs e)
{
timer1.Interval = 2500;
timer12.Enabled = true;
label5.Visible = true;
button2.Visible = false;
button3.Visible = false;
button4.Visible = false;
button5.Visible = false;
timer12.Enabled = true;
label5.Visible = true;
}

private void button3_Click(object sender, EventArgs e)
{
timer1.Interval = 1500;
timer12.Enabled = true;
label5.Visible = true;
button2.Visible = false;
button3.Visible = false;
button4.Visible = false;
button5.Visible = false;
timer12.Enabled = true;
label5.Visible = true;
}

private void button4_Click(object sender, EventArgs e)
{
timer1.Interval = 1000;
timer12.Enabled = true;
label5.Visible = true;
button2.Visible = false;
button3.Visible = false;
button4.Visible = false;
button5.Visible = false;
timer12.Enabled = true;
label5.Visible = true;
}

private void button5_Click(object sender, EventArgs e)
{
timer1.Interval = 750;
timer12.Enabled = true;
label5.Visible = true;
button2.Visible = false;
button3.Visible = false;
button4.Visible = false;
button5.Visible = false;
timer12.Enabled = true;
label5.Visible = true;
}

private void timer12_Tick(object sender, EventArgs e)
{
label5.Text = Convert.ToString(baslangic);
baslangic = baslangic + 1;
if (label5.Text == “4”)
{
pictureBox1.Visible = true;
pictureBox2.Visible = true;
pictureBox3.Visible = true;
pictureBox4.Visible = true;
pictureBox5.Visible = true;
pictureBox6.Visible = true;
pictureBox7.Visible = true;
pictureBox8.Visible = true;
pictureBox9.Visible = true;
pictureBox10.Visible = true;
pictureBox11.Visible = true;
pictureBox12.Visible = true;
pictureBox13.Visible = true;
pictureBox14.Visible = true;
pictureBox15.Visible = true;
pictureBox16.Visible = true;
pictureBox17.Visible = true;
pictureBox18.Visible = true;
timer1.Enabled = true;
label5.Visible = false;
label1.Visible = true;
label2.Visible = true;
zamant.Enabled = true;
label6.Visible = true;
nota1.SoundLocation = “1.wav”;
nota1.Play();
label7.Visible = true;
}
}

private void button1_Click(object sender, EventArgs e)
{
button2.Visible = true;
button3.Visible = true;
button4.Visible = true;
button5.Visible = true;
button1.Visible = false;
textBox1.Visible = false;
label6.Text = textBox1.Text;
pictureBox19.Visible = false;
button7.Visible = false;
button8.Visible = false;
listBox1.Visible = false;
}

private void textBox1_TextChanged(object sender, EventArgs e)
{
if (textBox1.TextLength > 3)
{
button1.Enabled = true;
}
else
{
button1.Enabled = false;
}
}

private void button7_Click(object sender, EventArgs e)
{
textBox1.Visible = false;
button1.Visible = false;
listBox1.Visible = true;
button7.Visible = false;
button8.Visible = true;
FileStream save = new FileStream(@”save.text”, FileMode.Open, FileAccess.Read);
StreamReader scor = new StreamReader (save);
string scores = scor.ReadToEnd();
string[] scr = scores.Split(Convert.ToChar(13));

foreach (string veri in scr)
{
listBox1.Items.Add(veri);
}
scor.Close();
}

private void button8_Click(object sender, EventArgs e)
{
listBox1.Visible = false;
button7.Visible = true;
button8.Visible = false;
listBox1.Items.Clear();
textBox1.Visible = true;
button1.Visible = true;
}

}
}

C#'da Hapishane İşi


OYUN HAKKINDA BİLGİLER
Hapishane işi okul işinin devamıdır. Okul İşi’nde karakterimiz hapishaneye düşer, ve 2. oyun yani Hapishane İşi’nin başlamasına sebep olur. Bu projede kullandığım kodlar Okul İşi’ndeki kodlara göre çok daha karmaşıktır, Oyunda 2D görüntü vardır ve oyun toplam 12 formdan oluşur.

OYUNUN KONUSU
Kahramanımız Ruhi sınav sorularını çalarken yakalandığı için hapishaneye düşer, oyunda size düşen görev onu hapishaneden çıkartmaktır. Hapishanede acımasız gardiyanlar, psikopat mahkumlar ve bir sürü zor koşullar vardır.
Oyundaki temel kurallarda çok önemlidir. Her gün yapılan yoklamayı bir gün bile kaçırmamanız gerek, eğer kaçırırsanız gardiyanlar tarafından dövülüp, tek kişilik hücrelere atılırsınız.

C#'da Okul İşi

OYUN HAKKINDA BİLGİLER
Okul işi projesi benim C#’da yeni yeni bişeyler öğrendiğim zamanlarda başlamıştır.
Oyununda karmaşık bir kod mantığı yoktur, sadcece butonlar, textboxlar, labellar, timerlarla oyun yapılmıştır, oyun toplam 17 formdan oluşur.
C#’da yeni yeni bişeyler öğrenmeye başlıyorsanız böyle bir projeye başlamanızı öneririm. Projeniz bitmese bile projeyi programlarken öğreneceğiniz çok şey olucaktır.

OYUNUN KONUSU
Ruhi yani oyundaki kahramanimiz Gazi universitesinde Makine Muh.
okumakta olan 1. sinif ogrencisidir.Ama okuldaki durumu iyice kotuye
sarmistir, devamsizligi 20 uzerinden 19 gundur, okula 1 gun mazeretsiz
gidememesi halinde sinifta kalicaktir.Okulun buyuk sinavina sadece
1 hafta kalmistir, sinava hazirlanamadigi icin arkadasi Ali’yle birlikte
sinav sorularini calma operasyonuna katilicaktir ki bunu sizin yardiminiz
olmadan basaramaz, sinifta kalma durumunda yani devamsizligin 20 olma
durumunda oyun biticektir.