Now i have a general question about the frameCount command.
As it is also stated in the reference,
frameCount itself is not a command!
Instead, it is a
Processing built-in variable!!!
Processing automatically increases that variable by 1 just before calling function
draw().
In short,
frameCount = how many times
draw() was called.
Be aware that draw() is "tentatively" called
frameRate() / second.
That is, whether
draw() is finished fast enough!
frameRate(fps) with
fps = 2, means
draw() may be called 2 times for each second!
Consequently,
frameCount increases by 2 after each second.
Now for the other questions...:
final static byte stateWait = 2;
What do you achieve by making them static?:
Barely nothing!!! It's just a habit of mine.
Also,
Processing is not very fond of
static variables either!
Static is more useful for pure
Java programming. Which I know very little myself!
In a
class context,
static is the opposite of an instanced field variable.
The real shining star here is the
final declaration.
It tells the
Java compiler that a variable won't change its stored value later ever!
Thus
Java compiler can optimize and even inline that variable wherever it's used within the program!
Static can also increase the chance for an inlining too!
byte gameState = statePick;
wouldn't you assign gamestate the permanent value 0
with this line?
Why do you
do that?:
gameState itself isn't declared
final, so its stored value can change normally!
short score;
I cannot find score in the language reference. What function does it have?:
Here I just declare variable
score as data-type
short. It's for storing how many times the player matched a color w/ the right color name word when he/she/it clicks.
if (frameCount == frameFinish)
How can this even be possible? dont you always add
gameState = statePick;
+4 (frameWait) to the frameCount?:
Although we can hack system variable
frameCount to an arbitrary value ourselves, the normal behavior is letting
Processing increasing that 1 by 1 each time it calls back function
draw()!
frameFinish is set ("current"
frameCount +
frameWait) into the future.
So that after the 2 indices are random-picked and displayed,
the player has some "
frameWait"
draw() calls to react and press a mouse button!
It also serves to wait some frames to display the result, either correct or wrong image!
Whew! I guess I'm done w/ your doubts for now.
But don't hold back to ask more!
Happy programming!!!