week4

In this week's class, we learned how to use for(). And I feel much more explicit about boolean expression and related terms.  


The worksheet inspired my assignment; I am trying to make a Gobang(Five In a Row) game. So here is my thinking process:

1. build a checkerboard with a black stroke and yellow background.

2. set up a boolean expression that an ellipse would appear at the checkerboard's cross if my mouse clicked.

3. set another boolean expression to let one click make the ellipse white and the next black. 


The hardest part is keeping the piece in the checkboard and changing color in a regular pattern by using Boolean expression. But in the process of making this game, I think there are more problems than I thought.


1. To let the piece stay.

After using the boolean expression with the mouse is pressed, my piece only appears when I press the mouse, and it won't stay. So I am thinking of using function mouse pressed, or mouse clicked; I still don't know the difference, but both of them don't work(I can't even make my piece stay). Then I think about the "gosht" problem I met at my second assignment, I put the background below the setup, and I draw I wrote for() with only these lines but not rect. But I still have the problem now that the line still draws over my piece. I am wondering if I did it in the right way.


2. Change the color

So at first, I am thinking of having two if() statements, one to let it draw white pice and the other one to draw black. I thought It would be called by the order. But it actually can only call the last one. 





So I looked up the turn on and turn off red rect we did in last week's worksheet. I make two var to control it, and it works. But the problem is that the color of the piece actually depends on how long I pressed the mouse. 

I also kind of don't know how to solve this problem, so what I did is set up the framerate to 2, so that's better for me to control the change. 

Also at the beginning, I set. the mouseX click right at the cross, because I am afraid the x and y in for() will cause confusion, but I kind of just makes the ellipse smaller( also used the x,y in for()), and add more space to the range. So the game operation feels easier. 



 









 







 

Comments

Popular posts from this blog

Week3

ICM Week 2