week 6 presentation


 I made a gobang game in P5. I actually did this assignment back to the class about for() loop. I used for()loop to create the checkerboard and pieces, but back then, I had many bugs like my checkerboard always draw over my pieces and hard to make every click.

After learning about class and array, the demo that clicked to create multiple bubbles we did in class inspired me to remake a more practical and useable gobang game.


In general, I create a class for the piece and use the array to call the piece multiple times. And also used boolean expression to make the pieces are one white one black happened in order.  




I make the mouse press function. In lines 45-47, this is where I create a new piece by pressing the mouse. In line 23-24 I gives the coordinate of the x,y and my pieces also are located by this x,y.  In line 26, I provide an if statement for my click; only in an area, the click can show up the piece on the checkerboard.

Start from line 28, the boolean expression controls the piece's color and is very much like a switch. To change the color, I add a number for color in Class Qizi. So in the boolean expression, I only need to change the number between 0 and 255.   










Comments

Popular posts from this blog

Week3

week4

Week 1 Blog