Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Game

Game

Scheduled Pinned Locked Moved C#
csharpgame-devtutorial
4 Posts 4 Posters 23 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Homam Obedo
    wrote on last edited by
    #1

    Hi I need to make a game using window form in c# just an example thx.

    J OriginalGriffO C 3 Replies Last reply
    0
    • H Homam Obedo

      Hi I need to make a game using window form in c# just an example thx.

      J Offline
      J Offline
      jeron1
      wrote on last edited by
      #2

      https://medium.com/@irinaandreea/tictactoe-windows-forms-app-in-c-35707fe8b515[^]

      "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle

      1 Reply Last reply
      0
      • H Homam Obedo

        Hi I need to make a game using window form in c# just an example thx.

        OriginalGriffO Offline
        OriginalGriffO Offline
        OriginalGriff
        wrote on last edited by
        #3

        While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you. So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in! Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did. Just saying "I wanna write a game" doesn't help anyone! If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

        1 Reply Last reply
        0
        • H Homam Obedo

          Hi I need to make a game using window form in c# just an example thx.

          C Offline
          C Offline
          charles henington
          wrote on last edited by
          #4

          bool playing = true;
          public Form1()
          {
          InitializeComponent();
          }
          private Button[] Cells => new Button[]
          {
          //top row
          button1,
          button2,
          button3,
          //middle row
          button4,
          button5,
          button6,
          //bottom row
          button7,
          button8,
          button9
          };
          private bool IsBoardFull
          {
          get
          {
          bool result = true;
          foreach (Button btn in Cells)
          {
          if (btn.Enabled) { result = false; break; }
          }
          return result;
          }
          }
          //This tells our CheckForWinner if their is a winner
          private bool IsThreeInRow
          {
          get
          {
          //rows
          if (Cells[0].Text == "X" && Cells[1].Text == "X" && Cells[2].Text == "X" ||
          Cells[0].Text == "O" && Cells[1].Text == "O" && Cells[2].Text == "O" ||
          Cells[3].Text == "X" && Cells[4].Text == "X" && Cells[5].Text == "X" ||
          Cells[3].Text == "O" && Cells[4].Text == "O" && Cells[5].Text == "O" ||
          Cells[6].Text == "X" && Cells[7].Text == "X" && Cells[8].Text == "X" ||
          Cells[6].Text == "O" && Cells[7].Text == "O" && Cells[8].Text == "O" ||
          //columns
          Cells[0].Text == "X" && Cells[3].Text == "X" && Cells[6].Text == "X" ||
          Cells[0].Text == "O" && Cells[3].Text == "O" && Cells[6].Text == "O" ||
          Cells[1].Text == "X" && Cells[4].Text == "X" && Cells[7].Text == "X" ||
          Cells[1].Text == "O" && Cells[4].Text == "O" && Cells[7].Text == "O" ||
          Cells[2].Text == "X" && Cells[5].Text == "X" && Cells[8].Text == "X" ||
          Cells[2].Text == "O" && Cells[5].Text == "O" && Cells[8].Text == "O" ||
          //Diagional
          Cells[0].Text == "X" && Cells[4].Text == "X" && Cells[8].Text == "X" ||
          Cells[0].Text == "O" && Cells[4].Text == "O" && Cells[8].Text == "O" ||
          Cells[2].Text == "X" && Cells[4].Text == "X" && Cells[6].Text == "X" ||
          Cells[2].Text == "O" && Cells[4].Text == "O" && Cells[6].Text == "O")
          return true;
          return false;

          }
          

          }

          //This is for the computer play. It just returns all
          //the possible plays that are currently available. It
          //chooses one of these at random, better computer play
          //logic should be thought out.
          private IEnumerable PossibleMoves()
          {
          return Cells.Where((button) => button.Enabled);
          }
          private void CheckForWinner()
          {
          string draw = "Sorry, it was a draw.";
          string playAgain = "Another Game?";
          string sorry = "Sorry, you los

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups