Thread: simple vector scrolling..

  1. #1
    Registered User
    Join Date
    Nov 2003

    simple vector scrolling..

    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:

    void Stats::update_next()
      cursor = (cursor+1)%len;
    void Stats::update_prev()
    if(cursor <= 0)
      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++)
    	return temp2;
    where len = players.size() and cursor is initialized to 0 (on its first run).

    thanks in advace : ]

  2. #2
    Registered User
    Join Date
    Nov 2003
    n/m, figured it out ;D

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. creating very simple text editor using c
    By if13121 in forum C Programming
    Replies: 9
    Last Post: 10-19-2010, 05:26 PM
  2. Simple message encryption
    By Vicious in forum C++ Programming
    Replies: 10
    Last Post: 11-07-2004, 11:48 PM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. Simple simple program
    By Ryback in forum C++ Programming
    Replies: 10
    Last Post: 09-09-2004, 05:48 AM
  5. Need help with simple DAQ program
    By canada-paul in forum C++ Programming
    Replies: 12
    Last Post: 03-15-2002, 08:52 AM