GithubHelp home page GithubHelp logo

steponask / chess-sfml Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 2.1 MB

♜ Chess GUI Clone made in C++ SFML graphics library ♜

License: GNU General Public License v3.0

C++ 100.00%
chess-cpp chess-gui cpp gui-application sfml-game sfml-graphics-library chess-sfml

chess-sfml's Introduction

♖ Chess GUI

  • Chess GUI (Graphical User Interface) game made in SFML C++ Library

Chess game

📖 Description

  • Play chess!
  • Graphical user interface
  • Show possible moves when clicked on a specific piece
  • Play against AI (feature coming)

Usage

  • Left click to choose your piece
    • Now you can see all the possible moves!
  • Choose where you want to move
    • Checkmate the other side! ♚♔

Getting Started

⬇️ Installation

If you have CMake installed:

Open your Command Prompt or Terminal

For a single-configuration generator (typically the case on Linux and macOS):

  • cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
    cmake --build build

For a multi-configuration generator (typically the case on Windows):

  •  cmake -S . -B build
     cmake --build build --config Release

Compiling it yourself with SFML:

  1. Clone this repository
git clone https://github.com/SteponasK/Chess-SFML.git
  1. Configure your project, using online guide or a youtube video.

  2. Compile all the files using Visual Studio or the IDE of your choice.

🏗️ Built With

  • SFML - Software Development Library
  • C++ Programming Language

👑 Authors

  • Author - Steponas K

License

  • This project is licensed under the GNU General Public License. See the LICENSE file for more information.

chess-sfml's People

Contributors

steponask avatar

Watchers

 avatar

chess-sfml's Issues

Make a main menu screen, end menu screen.

Main menu:

  • Choose style of the board/pieces.
  • Change volume of the music.
  • Add resolution changer.

End menu:

  • Showing how many moves it took.
  • You won/lost/drew by stalemate/checkmate/etc.
  • Do you want to play again

Chess logic plan

Need to implement logic for king being in check, dangerous moves, which would put king in check, and legal moves to defend him.
Current plan:

Idea 1:

  • Continously loop over every piece's legal moves and store them in each piece's legal_moves vector .
  • If any of the pieces legal_move vector has Kings coordinates (x, y) in it, then the King is check.
  • If king is in check, he has to move to some other square, or be defended by some other piece, i would loop over all the pieces legal moves and remove these squares from Kings legal_moves.
  • If i want to move other piece, and king is in check, i would simulate its every legal move(and that every move would check if the king is in check - if it is, then that move is not legal).

Improvements:

Store position of both the kings.
If king moves, update it's position.
Create isKingInCheck() function
iterate through all the opponents pieces:
for each piece, check if it can attack the king(compare piece legal moves, with king pos)

Create detectDangerousMoves(color) function:

Pseudocode:

      vector dangerous_moves
      
for ( piece in all_pieces):
	get piece legal moves:
		for (move in legalMoves):
			 new tempBoard = current_Board
                           tempBoard play move: move
			if isKingInCheck(color, tempBoard):
				dangerous_moves.pushback(move)
         return dangerous_moves.

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.