We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello folks,
I am taking a computer science class this semester and for our final assignment we are asked to build a game. Within the grading rubric it asks that we keep a high score. I have successfully done this, however the high score changes back to zero when the program is shut off, then run again. Is there a method to permanently store a high score into a variable such that it will conserve the value after the program is shut down?
Thanks for your time !
Answers
saveStrings() ?
A quick look up or reading and writing to .txt files with processing showed me this page. If your saving a highscore then save the number there. Look at this page https://www.processing.org/tutorials/data/ and scroll a little down. Hope this helps.
yeah or you want to write
name, score, date, time
in a file
when there are 5 or 20 persons in the list, write this
(or you have only one number without a name?)
you can join name, score, date, time by adding + them, e.g. with #
list[i] = name + "#" + score + "#" + dateMy + "#" + timeMy;
dateMy and timeMy must be defined before
dateMy = year()+month()+day() ; // use nf(x, 2);
;-)
@Chrisir: manually adding a delimiter can of course work, but what happens when someone decides to use # in their name?
There are more robust alternatives to saveStrings which I would hope avoid this issue - e.g. saveXML, saveJSONArray and maybe saveTable...
oh, that's right!