Jump to content

Chess Game in C++ and SFML [WIP]

Nineshadow

So, today I've decided to try to do something graphical with C++. The language itself doesn't have support for anything like that, so I would have to resort to libraries. The first one that came to my mind was SFML, and this is my first contact with it. But what would I do with it? A game, of course, and chess seemed like a pretty easy example to implement.

 

Here we go :

37ZFFnV.png

 

The graphical side is pretty much done.

 

Mouse user input works. I just need to give a graphical response to the user input , such as the piece they select, and where they can move it .

 

I still have a lot of game logic to implement though. I wanted to get used to SFML first, and I gotta say : it's awesome :D. It makes a lot of sense to me, but I've used Unity extensively before, I'm accustomed to game programming logic and I'm quite a good programmer so those might have had something to do with it.

 

I will keep updating this post as the game develops. I'm currently at around 250 lines of code.

 

Working features :

  • Graphical interface
  • User input
  • Moving a piece to another position , legal or illegal
  • Take a piece with a piece
  • Checks for checkmate

To be implemented :

  • Graphical response to user input , highlighting legal moves
  • Check for illegal moves
  • Some other stuff
  • ??? any other ideas ???

i5 4670k @ 4.2GHz (Coolermaster Hyper 212 Evo); ASrock Z87 EXTREME4; 8GB Kingston HyperX Beast DDR3 RAM @ 2133MHz; Asus DirectCU GTX 560; Super Flower Golden King 550 Platinum PSU;1TB Seagate Barracuda;Corsair 200r case. 

Link to comment
Share on other sites

Link to post
Share on other sites

I play chess on my TI-83+ Graphing Calculator in school

Insert   Dank   Signature   Here.

Link to comment
Share on other sites

Link to post
Share on other sites

AI opponent.

Oh, right!

i5 4670k @ 4.2GHz (Coolermaster Hyper 212 Evo); ASrock Z87 EXTREME4; 8GB Kingston HyperX Beast DDR3 RAM @ 2133MHz; Asus DirectCU GTX 560; Super Flower Golden King 550 Platinum PSU;1TB Seagate Barracuda;Corsair 200r case. 

Link to comment
Share on other sites

Link to post
Share on other sites

Remote opponent LAN/WAN.

Oh , I've thought about that. I want to implement it.

i5 4670k @ 4.2GHz (Coolermaster Hyper 212 Evo); ASrock Z87 EXTREME4; 8GB Kingston HyperX Beast DDR3 RAM @ 2133MHz; Asus DirectCU GTX 560; Super Flower Golden King 550 Platinum PSU;1TB Seagate Barracuda;Corsair 200r case. 

Link to comment
Share on other sites

Link to post
Share on other sites

A tutorial system; introduce a beginner to chess - this can extend/crossover with work on AI, graphical hinting & game logic.

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
Share on other sites

Link to post
Share on other sites

Small update :

I've changed a lot of how the game logic used to work. Now it's more object-oriented, and I have quite a good template to work forward on setting up new rules for movement. I managed to get the game to mainly register only legal moves.

 

Now I need to implement the check game mechanic and checkmate.

 

I'm currently at 800 lines though.

i5 4670k @ 4.2GHz (Coolermaster Hyper 212 Evo); ASrock Z87 EXTREME4; 8GB Kingston HyperX Beast DDR3 RAM @ 2133MHz; Asus DirectCU GTX 560; Super Flower Golden King 550 Platinum PSU;1TB Seagate Barracuda;Corsair 200r case. 

Link to comment
Share on other sites

Link to post
Share on other sites

Nice job, if you need help just mention/quote me, I've used SFML a lot.

Link to comment
Share on other sites

Link to post
Share on other sites

Nice job, if you need help just mention/quote me, I've used SFML a lot.

I'm kinda done with the SFML part honestly. I just need to finish the game logic.

Only thing I could maybe add is a main menu, but I'll figure out how to make one myself. :D

i5 4670k @ 4.2GHz (Coolermaster Hyper 212 Evo); ASrock Z87 EXTREME4; 8GB Kingston HyperX Beast DDR3 RAM @ 2133MHz; Asus DirectCU GTX 560; Super Flower Golden King 550 Platinum PSU;1TB Seagate Barracuda;Corsair 200r case. 

Link to comment
Share on other sites

Link to post
Share on other sites

Cool im learning openlGL/SDL2/GLSL and C++ right now and im planning to do the same game but in 3D.Altough unity would be easy for that task, i want to learn better how stuff works in the background etc, and all calculations will help me better understand trigonometry and linear algebra and C++ in general.

Link to comment
Share on other sites

Link to post
Share on other sites

Cool im learning openlGL/SDL2/GLSL and C++ right now and im planning to do the same game but in 3D.Altough unity would be easy for that task, i want to learn better how stuff works in the background etc, and all calculations will help me better understand trigonometry and linear algebra and C++ in general.

Have fun! :D

Link to comment
Share on other sites

Link to post
Share on other sites

I'm kinda done with the SFML part honestly. I just need to finish the game logic.

Only thing I could maybe add is a main menu, but I'll figure out how to make one myself. :D

Nice to know, if you want to go beyond the complexity of a chess game I'd suggest you to implement an ECS (if you didn't already) it will make your project a lot more clean and easier to maintain.

Link to comment
Share on other sites

Link to post
Share on other sites

Maybe add a chess timer into the game. Looks really cool and I've wanted to get into making graphical games with c++ for a while :)

Link to comment
Share on other sites

Link to post
Share on other sites

  • 2 weeks later...

Here's the game in its current state for those who might want it.

http://www.mediafire.com/download/8sg9fzrfc9zlyuc/c.7z

Can you play it?

@as96

 

It's not done yet.

I still need to add check and checkmate and probably some other less common chess rules.

i5 4670k @ 4.2GHz (Coolermaster Hyper 212 Evo); ASrock Z87 EXTREME4; 8GB Kingston HyperX Beast DDR3 RAM @ 2133MHz; Asus DirectCU GTX 560; Super Flower Golden King 550 Platinum PSU;1TB Seagate Barracuda;Corsair 200r case. 

Link to comment
Share on other sites

Link to post
Share on other sites

Sure, I'll play it tomorrow :)

I was asking if it was working D:

I'm pretty sure I forgot to include some dlls.

i5 4670k @ 4.2GHz (Coolermaster Hyper 212 Evo); ASrock Z87 EXTREME4; 8GB Kingston HyperX Beast DDR3 RAM @ 2133MHz; Asus DirectCU GTX 560; Super Flower Golden King 550 Platinum PSU;1TB Seagate Barracuda;Corsair 200r case. 

Link to comment
Share on other sites

Link to post
Share on other sites

I was asking if it was working D:

I'm pretty sure I forgot to include some dlls.

Oh ok I'm on my macbook right now, wait a couple of minutes I need to turn on my pc.

Link to comment
Share on other sites

Link to post
Share on other sites

Oh ok I'm on my macbook right now, wait a couple of minutes I need to turn on my pc.

Ok, this should work now :

http://www.mediafire.com/download/8sg9fzrfc9zlyuc/c.7z

 

I tried it on my desktop and it works.

But wow, damn. It produces coil whine on my GPU , xD.

i5 4670k @ 4.2GHz (Coolermaster Hyper 212 Evo); ASrock Z87 EXTREME4; 8GB Kingston HyperX Beast DDR3 RAM @ 2133MHz; Asus DirectCU GTX 560; Super Flower Golden King 550 Platinum PSU;1TB Seagate Barracuda;Corsair 200r case. 

Link to comment
Share on other sites

Link to post
Share on other sites

 

and libstdc++-6.dll

 

both of those errors popped up twice

Try with the new link.

i5 4670k @ 4.2GHz (Coolermaster Hyper 212 Evo); ASrock Z87 EXTREME4; 8GB Kingston HyperX Beast DDR3 RAM @ 2133MHz; Asus DirectCU GTX 560; Super Flower Golden King 550 Platinum PSU;1TB Seagate Barracuda;Corsair 200r case. 

Link to comment
Share on other sites

Link to post
Share on other sites

Ok so the game looks fine but you really need to implement some kind of AI or multiplayer.

Link to comment
Share on other sites

Link to post
Share on other sites

It ran without errors , but testing it revealed that I couldn't perform the Castling move.

 

https://en.wikipedia.org/wiki/Castling

Yes, I know. You can't do En Passant either, nor promote pawns.

i5 4670k @ 4.2GHz (Coolermaster Hyper 212 Evo); ASrock Z87 EXTREME4; 8GB Kingston HyperX Beast DDR3 RAM @ 2133MHz; Asus DirectCU GTX 560; Super Flower Golden King 550 Platinum PSU;1TB Seagate Barracuda;Corsair 200r case. 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×