Sorry i appreciate all the help. Being that this is my 4th day i am still not 100% on how that code you just wrote is for the buttons? im going to maybe watch more videos on the arrays and classes and see if i can figure out starting fresh. your example you sent me already looks better than what i have haha. im not even sure how to get from that example to being able to switch states to get to like a question screen from that grid.I need to do more research.
now i want show you the difference between many arrays
and one array containing elements of a class
where the elements not only are the memory of the ( mixed type ) variables ( record structure )
also can have integrated methods. ( like its own draw / over / …)
to make the understanding easier i not changed the functionality between
arrays .vs. array of class
so more easy for you to compare.
later in the discussion we talked about your game need a state structure
( from where you can call above developed screens with the buttons… )
it is a little bit more complicated as you know already
as to states add have
questions and
answers…( WIN / LOSE /TYPO )
so i put that into a extra little framework
( as it not contains all button and array code it is primitive but easy to read. )
while in your code all texts for questions and answers
or "hard coded "
and you have understood it might be better to have it in arrays,
actually a total different way would be much better,
separate the game code from the data!
so question and answers texts / also the right answer info …
can be stored in a file
( i choose a .csv file you can even work in spreadsheet / excel and upload )
and that can load to a table object what works different but even better as a array.
this combines already the the state system with the
assets/qa.csv
file
and is a playable game already besides not have the good buttons
the reason for using a extra code file should be re usability.
so you have a function /
or a class ( for what it is the the pure reason they exist: to be re used )
you want use from several projects you could
download and upload that as a extra file.js.
But to get that running need to declare it in the index.html
( or your browser would not know that he must download it )
omg sorry i didnt see that last night I didn’t scroll up… Then when it was time to respond to you I was blocked to only sending 12 messages a day because I just signed up for the forum… How does the state function work so I can use the examples you made and incorporate them into mine with different States
Yea that seems like it’s gonna be the smoothest transition to just start fresh. So when I’m in draw() if I choose state 0 or 1 the other state will not display anything at all correct? So in draw have if (state = 0) and then the board coding? And then if( state = 2) draw the questions and so on?
Main thing is to make a proper data structure: a grid / 2D array to hold the fields so you can for-loop over them
the if else structure should also be in mousePressed so don’t have overlapping buttons but mouse is checked only against the buttons of that screen /state
The mousepressed functions just need to basically let state = to whatever screen I want and I can use mouse over to make specific buttons to do specific tasks gotcha? Still I’m gonna need either 60+ States for each of the questions and answers in round 1 that’s slot of States
Not the bottoms but the questions and answers I need separate states for all of those don’t I?? If there is 30 questions in round 1 don’t I need 30 states for that
Yea that makes sense but if I’m putting 30 questions in the round 1 of the game if you click a button on the main board it should go to a screen with the question. And then with another button press reveal the answer on another screen… So if I have 30 questions and answers that will be one state each… That’s alot of States. Or it can reveal the answer on the question screen I don’t care but that’s still 30 + States.