Game issues for christmas

hi @Mike,

please not get confused when you get hammered from two sides,
but @Chrisir and me work IN SHIFT ( i am from thailand )

also he try to help about the STATE / SCREEN thinking
( and why a screen = 1 is better as a screenone = true )

while i try a crash course about

  • variables
  • functions ( methods )
  • arrays
  • class
  • array of class

YES we are on the CLASS level now
go back to my above post and reread

Need help with game issues for christmas ,

1 Like

I’m lost… Should I be redoing the whole game or try to incorporate the States?

actually NO ( to both ) but that is up to you.

-a- you can study my 3 button code version to get a idea,
( but possibly for your next project )

-b- you should build up the STATE structure in a own little learn project first,
but already structured for all the operational logic of your project,
while the screen shown could be two simple rectangles ( or already buttons ).

-c- if you copy later in your original screen pages

or my “array function” or “array class function” pages
depends on if you understand them.

I don’t really… Not yet anyway haha

1 Like

no problem,
so you work on


and show/link it please, so we can follow you
remember that you need to “know”
not only the STATE / SCREEN to show ( from draw )
also what the question was and what the answer was!
( for develop show that on the STATE screen )

ok i think i finally got it working with my original code. my problem was when i was setting the mousepressed function to go from any of the answer screens back to the board i was having the board buttons working on the answer screen. It seems that because i was setting the board to true in the same function i was trying to change the answer screen to off it was allowing the board buttons to be active during that mouse press. I changed over to adding in states starting with 0 for the title screen, 1 for the board, 2 for round 2, 4 for questions, and 5 for answers. Now when i’m doing the mouse pressed to i have added i’m mouseover so that the answer screen has only one rectangle location that allows it to go back to the board. once i’m done with all the question screens and answer screens ill post the code again. At least now there is a light at the end of the tunnel and it seems i’m going to get this done haha. I’m gonna start learning more about arrays and classes after this so my code doesn’t have to be 4000+ lines haha


Well done and congratulations!

I think you can keep your version and work with it.

But let me explain what I would do the next time you start a big project like this please.

At the moment you have a lot of lines that are very similar where you check the cells of the grid.

Also you have positions in the text statements where you show the cells and where you check the mouse position against it. These are redundant position information.

When writing a program you would make a data structure (array of class/objects) to have the information in one place.

Then you don’t need a lot of similar lines with if but can for loop over the array to access all cells in the grid.

I and kll tried to demonstrate a bit of that in my post.


yea it seems i got comfortable with a few functions and ran with that haha but im gonna learn more and get better.
although i still have a problem, the same problem. i fixed almost everything else:
so whether your in round 1 or round 2 and you go to click the category 3 800 point question it is still clicking some answer button it shouldn’t. how do i watch the console to see what is happening?
its only that one button on both round 1 and 2. i checked the mousePressed for both of the rounds and all the questions and they are all the same so i dont know what the issue is.

I got a suspicion here

I’m not sure which lines we are talking about

Let’s say

  if (mouseX > 300 && mouseX < 380 && mouseY > 460 && mouseY < 540 && (state == 1)) {
    state = 4;
    q28 = true;

OK, just an idea.

Let’s say you want to have only one reaction per mouse click and not two:

Go to the if-clause for “category 3 800 point question”

  if (mouseX > 300 && mouseX < 380 && mouseY > 460 && mouseY < 540 && (state == 1)) {
    state = 4;
    q28 = true;
    return;  // <------ ENTER THIS line here 

Thank you.

So what is adding return doing? And I’ll add it when I get home and see what it does?

my theory is that : you change state in this if clause.

Therefore when we reach the other
if clause state is already changed and therefore
the 2nd condition is also true.

(our idea was that state would stop the 2nd if from executing but this won’t work now (it’s because how your code is, never mind))

The return command immediately leaves the whole mousePressed function the hard way, so the 2nd if-clause can’t be reached. It will be reached next time you click the mouse though.

1 Like

OMG!!! it works hahaha. I definitely need to clean up so much of this code but it is all functioning without any glitches. Thank you guys for taking the time to deal with my vast amounts of noob haha. I cant wait to start a second project and learn how to have an array with player names and maybe a point system that actuallly keeps track of points for each person.

1 Like

Actually, how are you planning this exactly?

You mentioned skype.

So you are planning to run this on your computer and the others are just having skype without seeing it on the computer? Or do they see it on the computer? Because I am not sure if you can run it and everybody sees your screen. You would be the only one to enter stuff in this scenario. You would enter by mouse. You would be the game master then.

There are ways to program multiplayer games in processing but that’s over my head.

yea this time around im just gonna be the master and do everything, but next program i was thinking of making something where i can send them the link and they can play on their own by entering there name and playing locally not multiplayer.

but how can they see your screen?

Or can skype just show them your screen?

skype has a screen share option.
so does discord

1 Like

In my opinion you could rewrite your mousePressed like this:

function mousePressed() {

  if (state==0) {
  else if (state==1) {
  else if (state==2) {
  else if (state==3) {
  else if (state==4) {
  else if (state==5) {
  } else {
    // error
    println ("Error"); 

Then make those functions and put what you have in mousePressed now inside those functions (the stuff for state 0 in the appropriate function mousePressedForState0() and so on).

Then your code is better readable since it’s in nice modules.

Same goes for function draw() by the way


yea that looks much cleaner.

1 Like

want try about modules? still want to follow?
reread above,
i gave you already
-1- a button function
-2- a array of buttons
-3- a array of class button

now add:
-4- a modular program structure for this game
-5- the question/answers/goodanswer/ thing is to be considered as DATA
not as text inside a CODE,
so in a extra 31 line CSV file read as table object,
what sure can compete with arrays once you dig into its handling.

yea i saved your examples so i can fool around with them and rewrite them on my own. i have been looking up how to modularize my program using some file.js and referencing it as a source in index.html. ill get there it just may take a while to figure all of this out, but hey my sloppy program works hahaha