Coder Social home page Coder Social logo

tictactoe's Introduction

❌⭕ TicTacToe ⭕❌

📝 Content

The following repository contains an implementation of the Tic-Tac-Toe game in Java, utilizing the Swing and AWT libraries. The game is created within a single class called KolkoKrzyzyk, which implements the ActionListener interface.

🧩 Component Initialization:

  • The game uses JFrame as the main window, as well as JPanel for the title and buttons.
  • Informational text is displayed using JLabel.
  • The game buttons are represented by a JButton array of size 9, corresponding to a 3x3 grid in Tic-Tac-Toe.

🔧 Constructor:

The KolkoKrzyzyk constructor configures the main game window, setting properties like size, background color, and layout of elements. Buttons are initialized, configured, and added to the button panel. The firstTurn() method is called to randomly choose which player starts.

✋ Event Handling:

The actionPerformed() method defines the game logic after a button is pressed. It checks which player's turn it is, updates the state of the button, and switches turns.

🎲 Game Logic:

The check() method verifies the winning conditions for both players. In the event of a player's victory, the relevant buttons are highlighted, and the game ends.

🎖️ Victory:

The xWins() and oWins() methods are invoked when one of the players wins. They change the color of the winning buttons and display a victory message.

🎮 How run the game

📁 Downloading the repository

  1. Install Git on your computer (if you haven't already).
  2. Open the terminal (Git Bash for Windows, standard terminal for macOS/Linux).
  3. Type in the terminal: https://github.com/WiolaWysopal/TicTacToe.git.

🕹️ Running the game

  1. Launch your IDE (e.g., IntelliJ IDEA, Visual Studio Code).
  2. Open or import the downloaded game repository.
  3. Ensure you have Java installed and configured in the IDE.
  4. Find the main game file (e.g., Main) in the project.
  5. Run project using Run option (or similar).

🏆 Sample gameplay

Sample gameplay

tictactoe's People

Contributors

wiolawysopal avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.