Checkers board and pieces, GUI completed

By
Advertisement

The update is that I have finally completed my GUI that is I have finally made a checkers board and also made the sprites. I have also started handling mouse events.





How did I do all of this?

Well, don't worry, it was very easy to do this stuff. Since I am using Python as the programming language, and pyglet as the gaming library, all the syntax was very easy to understand. I am using pycharm as the IDE, so it saves time.

1) I made a window screen of a size of my choice which only showed black screen.

2) Then, I proceeded to make load squares for making a chess board. Using two images and some logic with for loops, I was able to display the checkers board.

3) Then, I loaded the sprites for the game which were two pieces that are black and white. Then, I defined the position of the sprites and finally I was able to display the sprites. 

4) But, there was one problem, my code was very unorganised and alot of repeated work needed to be done. So I changed my code so now it using Object Oriented programming.

5) First I made separate files of square, board, sprites and main but they were unhelpful. So now, I have just made one file having a class of checkers and that does all the stuff through its functions. 

6) The sad part is that I am still working on the logic of valid movement of pieces and conquering pieces but the good part is that I have learned the syntax of mouse controlled event so as soon as the logic is made, it will be easily implemented. 

7) One interesting thing I have found out is bitboarding and that seems a good way forward. Basically, you make a matrix storing all the board squares, in our case, we are just using red squares, so they are 32. Then, we save the value 0,1 or 2 in place of that square, 0 represents empty, 1 represents white, 2 represents black. 



0 comments:

Post a Comment