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

2021/10/12

Saving 2 high scores seperately at a time

1
2
3
Roshan123 Roshan123

2021/10/12

#
Let us assume that thier r 2 variables i.e. x and y They both are the high scores of the different games respectively I want x and y to be saved seperately but i tried hard and yet now i don't know how will i do it
danpost danpost

2021/10/12

#
What have you tried? (giving this will clarify and add context to your issue)
Roshan123 Roshan123

2021/10/12

#
I would share the scenario's source code but the thing is that i don't know wether admins of greenfoot give copyright strike or not for which i m much aware of. Their r 2 different games in one scenario. If u press 1 u will play the green project else if u press 2 u will be playing foot project. green project saves ur high score in form of x and shows ur high score in scoreboard class and foot project saves ur highscore in form of y and shows in scoreboard1 class. The problem i m facing is that, both x and y are not saved seperately. If x is 3 and y is 4 then both the scoreboard will show 4. Green scenario belongs to me and foot scenario isn't mine. Note that green and foot are both examples. Thier is no scenario called foot in this site
danpost danpost

2021/10/12

#
Are you using UserInfo?
Roshan123 Roshan123

2021/10/12

#
danpost wrote...
Are you using UserInfo?
Yes
danpost danpost

2021/10/12

#
Roshan123 wrote...
Yes
UserInfo can only save 1 high score. You could use the first 2 of 10 int fields to hold the high scores for game 1 (green) and game 2 (foot); but those values are not use in the algorithms for sorting and displaying high scores. You could write your own algorithm, but believe me when I say, it will definitely cause a lagging when used. You would have to access ALL users data and compile the list by comparing the specific values.
Roshan123 Roshan123

2021/10/12

#
danpost wrote...
it will definitely cause a lagging when used.
Ok¡¡¡ Thanks!!!
Roshan123 Roshan123

2021/10/13

#
If i m not wrong u tried setInt() /setString() to save user's data and compare with a lot of user's data and this was the reason why it cause a lot many lagging in ur private messaging. M i correct or u tried a different method? Is it possible that i can atleast show them thier rank in foot project and rank, score and names in green project. Will it also lag? (Little bit of lag is ok but not for every fps or more than what is needed)
danpost danpost

2021/10/13

#
Roshan123 wrote...
If i m not wrong u tried setInt() /setString() to save user's data and compare with a lot of user's data and this was the reason why it cause a lot many lagging in ur private messaging. M i correct or u tried a different method?
My lagging is due to accessing EVERY user's information, which had to be done to see if someone tried to contact the current user.
Is it possible that i can atleast show them thier rank in foot project and rank, score and names in green project. Will it also lag? (Little bit of lag is ok but not for every fps or more than what is needed)
You can show whatever you want; but, if you are to show even rank for 2 different games, you will need to access EVERY user's information.
Roshan123 Roshan123

2021/10/13

#
//global
int newValue;
//gameOver() method
if(UserInfo.isStorageAvailabel()) 
{
UserInfo m = UserInfo.getMyInfo() ;
if(m! =null)
{
m.setInt(1, newValue) ;
m. store() ;
}
}
public int Score() 
{
return newValue1;
}
In scoreBoard class //act method MyWorld w= (MyWorld) getWorld() ; //inside for loop In every score board class its written something like this drawString(Integer.toString(playerData.getScore()), x, y+18, Scorecolor,14) ; But i wrote something like this only to show score and not the highscore since it was not possible for me but i don't know why it gives me nullPointer exception drawString(Integer.toString(w.Score()), x, y+18, Scorecolor,14) ;
danpost danpost

2021/10/13

#
Try this: Remove from act method
MyWorld w = (MyWorld) getWorld();
Add global:
MyWorld w;
Add method:
protected void addedToWorld(World world)
{
    w = (MyWorld)world;
}
Roshan123 Roshan123

2021/10/14

#
danpost wrote...
Try this: Remove from act method
MyWorld w = (MyWorld) getWorld();
Add global:
MyWorld w;
Add method:
protected void addedToWorld(World world)
{
    w = (MyWorld)world;
}
It still gives me nullPointerException
danpost danpost

2021/10/14

#
Roshan123 wrote...
It still gives me nullPointerException
Please show (copy/paste) exact error output and class where error occurred.
Roshan123 Roshan123

2021/10/14

#
Link Click "neon fight" Ohhh i forgot..... The password is rsb
danpost danpost

2021/10/14

#
In Scoreboard1 class, move line 18 to after line 13 (cut/paste).
There are more replies on the next page.
1
2
3