yeah i was wondering if you could help me with a simple algorithm im missing.
I have some player scores I want to show in a game, and i have them stored in a vector. What i want to do is show 10 scores at a time on screen, then have a "next line" and "prev line" button to scroll through the scores.
a basic idea ive been thinking about is make a 10-element vector and store the elements i want to display from the bigger vector onto that one. this is what i got so far:
Code:
void Stats::update_next()
{
cursor = (cursor+1)%len;
}
void Stats::update_prev()
{
if(cursor <= 0)
return;
else
cursor = (cursor-1)% len;
}
vector<Player> Stats::current_stats(const vector<Player>& players)
{
vector<Player> temp2(10);
for (int i=0; i<temp2.size(); i++)
temp2[i].push_back(players[(cursor+i)%len]);
return temp2;
}
where len = players.size() and cursor is initialized to 0 (on its first run).
thanks in advace : ]