ساخت بازی جورچین در سی شارپ
جهت دانلود ویدیوی آموزشی با کیفیت Full HD روی لینک زیر کلیک کنید .
حجم فایل : 109 مگابایت
مدت زمان : 35:52
در آپارات نیز می توانید به فایل های بالا با کیفیت HD دسترسی داشته باشید.
آموزش قدم به قدم
برای ساخت بازی جورچین باید 9 عدد باتن را درون فرم قرار دهیم و یکی از آنها را پنهان کنیم و سپس با کلیک بر هر باتن ، آن باتن به فضای خالی پرش کند .
این بازی به این صورت است که اگر باتن 9 خالی باشد و روی باتن 8 کلیک کردیم ، باتن 8 به خانه ی 9 پرش کند و خانه ی 8 خالی شود .


در حقیقت 9 باتن وجود دارد . برای اینکه بتوانیم این بازی جورچین را انجام دهیم باید یکی از باتن ها را مخفی کنیم که در این برنامه به دلخواه برنامه نویس باتن 9 مخفی شده است.
خطوط آبی در تصویر زیر تعاریف کتابخانه ای می باشد .
خطوط سبز رویدادهای کلیک مربوط به هر دکمه است .
خطوط زرد رویداد بارگذاری فرم می باشد که در آن تعریف کرده ام وقتی برنامه اجرا می شود باتن 9 را مخفی و متن آن را تهی قرار بده .
خطوط صورتی هم مربوط به رویداد مخفی کردن هر باتن در شرایط تعریف شده اش می باشد عملا برای مخفی کردن رویدادها ما یک تابع ساختیم و اسم آن را به صورت دلخواه visible گذاشتیم . و در پایان هر رویداد کلیک از visible استفاده نمودیم . تا پس از انجام مراحل ، تابع ویزیبل شروع به کار کند و هر دکمه ای که مقدار متن آن برابر تهی می باشد مخفی نماید .
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (button2.Text=="")
{
button2.Text = button1.Text;
button1.Text = "";
}
if (button4.Text == "")
{
button4.Text = button1.Text;
button1.Text = "";
}
visible();
}
private void button2_Click(object sender, EventArgs e)
{
if (button1.Text=="")
{
button1.Text = button2.Text;
button2.Text = "";
}
if (button3.Text == "" )
{
button3.Text = button2.Text;
button2.Text = "";
}
if (button5.Text=="")
{
button5.Text = button2.Text;
button2.Text = "";
}
visible();
}
private void button3_Click(object sender, EventArgs e)
{
if (button2.Text == "")
{
button2.Text = button3.Text;
button3.Text = "";
}
if (button6.Text == "")
{
button6.Text = button3.Text;
button3.Text = "";
}
visible();
}
private void button4_Click(object sender, EventArgs e)
{
if (button1.Text == "")
{
button1.Text = button4.Text;
button4.Text = "";
}
if (button5.Text=="")
{
button5.Text = button4.Text;
button4.Text = "";
}
if (button7.Text=="")
{
button7.Text = button4.Text;
button4.Text = "";
}
visible();
}
private void button5_Click(object sender, EventArgs e)
{
if (button2.Text == "")
{
button2.Text = button5.Text;
button5.Text = "";
}
if (button4.Text=="")
{
button4.Text = button5.Text;
button5.Text = "";
}
if (button6.Text =="" )
{
button6.Text = button5.Text;
button5.Text = "";
}
if (button8.Text == "")
{
button8.Text = button5.Text;
button5.Text = "";
}
visible();
}
private void button6_Click(object sender, EventArgs e)
{
if (button3.Text == "")
{
button3.Text = button6.Text;
button6.Text = "";
}
if (button5.Text == "")
{
button5.Text = button6.Text;
button6.Text = "";
}
if (button9.Text == "")
{
button9.Text = button6.Text;
button6.Text = "";
}
visible();
}
private void button7_Click(object sender, EventArgs e)
{
if (button4.Text == "")
{
button4.Text = button7.Text;
button7.Text = "";
}
if (button8.Text == "")
{
button8.Text = button7.Text;
button7.Text = "";
}
visible();
}
private void button8_Click(object sender, EventArgs e)
{
if (button5.Text == "")
{
button5.Text = button8.Text;
button8.Text = "";
}
if (button7.Text == "")
{
button7.Text = button8.Text;
button8.Text = "";
}
if (button9.Text == "")
{
button9.Text = button8.Text;
button8.Text = "";
button9.Visible = true;
button8.Visible = false;
}
visible();
}
private void button9_Click(object sender, EventArgs e)
{
if (button6.Text == "")
{
button6.Text = button9.Text;
button9.Text = "";
}
if (button8.Text == "")
{
button8.Text = button9.Text;
button9.Text = "";
}
visible();
}
private void Form1_Load(object sender, EventArgs e)
{
button9.Text = "";
button9.Visible = false;
}
private void visible()
{
if (button1.Text=="")
{
button1.Visible = false;
}
else
{
button1.Visible = true;
}
if (button2.Text == "")
{
button2.Visible = false;
}
else
{
button2.Visible = true;
}
if (button3.Text == "")
{
button3.Visible = false;
}
else
{
button3.Visible = true;
}
if (button4.Text == "")
{
button4.Visible = false;
}
else
{
button4.Visible = true;
}
if (button5.Text == "")
{
button5.Visible = false;
}
else
{
button5.Visible = true;
}
if (button6.Text == "")
{
button6.Visible = false;
}
else
{
button6.Visible = true;
}
if (button7.Text == "")
{
button7.Visible = false;
}
else
{
button7.Visible = true;
}
if (button8.Text == "")
{
button8.Visible = false;
}
else
{
button8.Visible = true;
}
if (button9.Text == "")
{
button9.Visible = false;
}
else
{
button9.Visible = true;
}
}
}
}
