We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hey, I'm new here. I use java inside Processing. So I'm trying to create a high score board with just the numbers not the name of the people. So far I've tried moving all them down to where the score should be, but all the scores under the one I want to change turn into high, the high score. I was thinking of making a second array and just switching, but I'm hoping there an easier way. I been trying to use it with spacebar instead of going through the whole game. Basically I'm wondering how to fix it, so it drops the other scores to the lower if its not the lowest then writes mine where I want it to be.
here my code:
void update(){
if (high > score[4].total){ check = 1;}
if (high > score[3].total){ check = 2;}
if (high > score[2].total){ check = 3;}
if (high > score[1].total){ check = 4;}
if (high > score[0].total){ check = 5;}
if (check == 1){
score[4].total = high;
}
if (check == 2){
score[4].total = score[3].total;
score[3].total = high;
}
if (check == 3){
score[4].total = score[3].total;
score[3].total = score[2].total;
score[2].total = high;
}
if (check == 4){
score[4].total = score[3].total;
score[3].total = score[2].total;
score[2].total = score[1].total;
score[1].total = high;
}
if (check == 5){
score[4].total = score[3].total;
score[3].total = score[2].total;
score[2].total = score[1].total;
score[1].total = score[0].total;
score[0].total = high;
}
}
this is before
this is after
what I wanted was:
score: 50 score: 50 score: 75 score: 100 score 123 /// this the new score
Answers
What type is high? Score []?
high is a float i used to store how many points the players has gotten.
And what type is score[]?
an array to me it's easier to manipulate to what I want.
Yes, it's an array, I can see that. But an array of what? It appears to have a member called total. What type is that? (This looks a lot like you are using references and assigning all the references to one object so that when you change one they all change)
But you seem reluctant to supply the necessary details.
its an array of scores each score item has its own total, float. The way I thought it would turn out is way different then the way it turned out. I tried to change each Score,class, total to the one its needs to be. I don't get why it loops.
a runnable example would be good, not just a snippet.
i've done this. and it works fine:
ty, it took a little reorganizing to get it where I want to be but now it works thanks you hundreds.