This site requires JavaScript, please enable it in your browser!
Greenfoot back
nccb
nccb wrote ...

2012/1/14

High Scores!

1
2
nccb nccb

2012/1/14

#
It's been requested several times before that we support some sort of persistent storage for scenarios on the Greenfoot website. This could be used for high-score tables, or "save games" (remembering which level you'd reached in a game) or other uses. I'm glad to say that this functionality will be added to the next Greenfoot release, 2.2.0, which is coming soon (that probably means in about a month!). Prior to the release, you can help us test this functionality and iron out bugs. I've uploaded a scenario that uses the new system to have global high-scores. As long as you are signed in to your Greenfoot website account (i.e. your profile picture is visible top-right) when you load the page, and are not behind a proxy or over-zealous firewall, you should be able to play the game and set a high score, which will be remembered thereafter. Please let me know if you see anything wrong (e.g. score not saved, or the ranking of the high-scores is wrong). Once Greenfoot 2.2.0 is out, I'll upload the source for the scenario and you can copy the scores aspect, but there's no point for now because it wouldn't work in Greenfoot 2.1.2 anyway.
dangjavageek dangjavageek

2012/1/14

#
Looks fine - it would be interesting to figure out what can be stored / persistent, i.e., integers or objects and so on. Thanks! Best regards, -- DanG
nccb nccb

2012/1/14

#
At the moment, it's one score int, 10 general-purpose ints, and 5 strings of up to 50 characters per user, per scenario. The numbers were picked completely arbitrarily! General object storage (a la persistence frameworks) is too complex, hence using simple near-primitive data-types.
DonaldDuck DonaldDuck

2012/1/14

#
I haven't checked your scenario out yet, but will we be able to then access the scores saved by users and sort them into a high-score ranking table? Great implementation, thanks a ton!
darkmist255 darkmist255

2012/1/14

#
Niiiice! I'll be eager to see the API to go with this (assuming there is one) :D!
Builderboy2005 Builderboy2005

2012/1/15

#
Sounds awesome! I mirror DonaldDuck's question, will scenarios be restricted to accessing the data of the current user? Or will scenarios be able to sort through all users that have set score data for the scenario?
nccb nccb

2012/1/15

#
You will have read/write access to the current user's data, and read-only access to all users, although for speed it's best if the scenario tries to avoid accessing too many of them. In my scoreboard example, you only access up to about 16. As well as the actual data for the user (score + ints + strings), you can get their username and their avatar as a 50x50 image. The API is potentially subject to change before release, but at the moment there is a getTop(int amount) method that returns a list of up to that many users, from the top score downwards (that's what's on the left-hand side of the scoreboard) and a getNearby(int amount) method that gets the nearby users in terms of score (that's what's on the right-hand side: this will become more obvious once you get more users setting scores). There is also a simple storage mechanism that works in the Greenfoot IDE, to allow you to test your code before uploading. Again it might change a bit, but at the moment you can just enter an arbitrary username and then you act as if you were that user, so you can become several different users and see what happens as each.
Builderboy2005 Builderboy2005

2012/1/15

#
That sounds amazing! All the functionality a programmer could ever want! Can't wait for the next release!
Duta Duta

2012/1/15

#
Builderboy2005 wrote...
That sounds amazing! All the functionality a programmer could ever want! Can't wait for the next release!
This! :D
DonaldDuck DonaldDuck

2012/1/16

#
Any chance you release a 'beta' version to me so I can 'test' it? ;)
Duta Duta

2012/1/16

#
DonaldDuck wrote...
Any chance you release a 'beta' version to me so I can 'test' it? ;)
I was wanting to ask this, I figured I'd be shot down if I did though :L
DonaldDuck DonaldDuck

2012/1/27

#
One last question, Will the scores be updated in real-time? So if User 1 updates a score while User 2 is in the application, will User 2 be able to read that score? Or will they have to refresh the page before the information comes through?
kiarocks kiarocks

2012/1/28

#
A question: will you be able to make surveys with this? ex. somebody does the survey and then can look at the result and then the person with a password(like the owner) can download the data?
nccb nccb

2012/1/30

#
In answer to the last two questions: there is no caching (although maybe there should be), so each call to the API will fetch the latest score data. This means that the scores are updated as fast as you want. However, I'm hoping that scenario writers will be responsible about this: if you ask for their latest scores frequently (e.g. each act() frame), you will be hammering the Internet connection of the person playing your scenario. I may implement server-side throttling to help try to avoid this. And yes, you will be able to do surveys. When a scenario is running, it has read/write access to the data for the current user, and read access to the data for all other users, so everyone could see the survey results (if the scenario writer wanted), but you can only record the response for the current user, so seems like it should work. Again, though: fetching the data for all users is potentially bandwidth-consuming, so it will be good to minimise the number of times you make that call.
DonaldDuck DonaldDuck

2012/1/31

#
I have an idea to implement a multi-player game then... Assign each player an individual integer when the run the scenario and attach their name to that integer. This way, the players can connect to each others saved data and communicate back and forth for non-instant games like connect four (which I will try to implement)
There are more replies on the next page.
1
2