odai alhjahjah بتاريخ: 16 ديسمبر 2016 تقديم بلاغ مشاركة بتاريخ: 16 ديسمبر 2016 اريد كود بلغه سي شاررب بحيث يتم تصميم لعبه الاكس او يتم اللعب مع الجهاز بشكل توماتيكي لو تكرمتو باعطائي الكود لاني صممت هذا الكود لكن انا اقوم بعمليه اللعب وحدي فقط وانا اريد الكود بيني وبين الجهاز 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; namespace tic_tak_toe__x_and_o__ { public partial class Form1 : Form { Button[,]bttn=new Button[3,3]; enum gametype { x, o }; gametype currengame = gametype.x; int count = 0; public Form1() { InitializeComponent(); bttn[0, 0] = btn00; bttn[0, 1] = btn01; bttn[0, 2] = btn02; bttn[1, 0] = btn10; bttn[1, 1] = btn11; bttn[1, 2] = btn12; bttn[2, 0] = btn20; bttn[2, 1] = btn21; bttn[2, 2] = btn22; clearall(); } private void clearall() { foreach (Button b in bttn) b.Text=""; count = 0; } private void Form1_Load(object sender, EventArgs e) { } private void buttnplay_Click(object sender, EventArgs e) { Button btn = sender as Button; if (btn.Text != "") return; btn.Text = currengame.ToString(); count = count + 1; if (iswin()) { MessageBox.Show("Carp you've won"); clearall(); return; } if (count == 9) { MessageBox.Show("tie"); clearall(); } switchGame(); } private bool iswin() { for (int r = 0; r <= 2; r++) { int samegame = 0; for (int c = 0; c <= 2; c++) { if (bttn[r, c].Text == currengame.ToString()) samegame = samegame + 1; } if (samegame == 3) { return true; } } for (int c = 0; c <= 2; c++) { int samegame = 0; for (int r = 0; r <= 2; r++) { if (bttn[r, c].Text == currengame.ToString()) samegame = samegame + 1; } if (samegame == 3) { return true; } } if (bttn[0, 0].Text == currengame.ToString() && bttn[1, 1].Text == currengame.ToString() && bttn[2, 2].Text == currengame.ToString()) return true; if (bttn[0, 2].Text == currengame.ToString() && bttn[1, 1].Text == currengame.ToString() && bttn[2, 0].Text == currengame.ToString()) return true; return false; } private void switchGame() { if (currengame == gametype.x) currengame = gametype.o; else currengame = gametype.x; } private void button8_Click(object sender, EventArgs e) { } } } اقتباس رابط هذا التعليق شارك المزيد من خيارات المشاركة
eslam elbyaly بتاريخ: 17 ديسمبر 2016 تقديم بلاغ مشاركة بتاريخ: 17 ديسمبر 2016 المنتدى خاص باوراكل اقتباس رابط هذا التعليق شارك المزيد من خيارات المشاركة
Recommended Posts
انضم إلى المناقشة
يمكنك المشاركة الآن والتسجيل لاحقاً. إذا كان لديك حساب, سجل دخولك الآن لتقوم بالمشاركة من خلال حسابك.