Thread: a point in the right direction

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    59

    a point in the right direction

    Hi all,

    I am making a basic football managment game and i am struggling to store values in the league table, heres what i have so far.

    its not the whole program just the part where i need to add up values.

    Code:
    if (team1 > team2)        // if team 1 wins
    {
    
    wont1++; 
    gfort1[1] = + team1;  
    ggainst1[1] = + team2;
    pointst1 = + 3;
    }
    
    if (team2 > team1)         // if team 2 wins
    {
    wont2++;
    gfort2[1] = + team2;
    ggainst2[1] = + team1;
    pointst2 = + 3;
    }
    
    if (team1 == team2)            // if a draw
    {
    gfort1[1] + team1;
    ggainst1[1] + team2;
    gfort2[1] + team2;
    ggainst2[1] + team1;
    pointst1 = + 1;
    pointst2 = + 1;
    }
    The variables team 1 & 2 are random numbers.

    This might be absolute crap, but what i want to do is everytime team 1 or 2 wins i want to add 3 to their points or 1 point if they draw.

    Also gfor1 & 2 need to store values for goals scored
    And ggainst1 & 2 need to store values for goals against

    Cheers guys

    [code][/code]tagged by Salem

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    First, change pointst1 = + 3; to pointst1 += 3; (and all others that does the same).

    Second, gfort1[1] + team1; calculates the sum, but doesn't do anything with it. If you want to add team1 to gfort[1], then change + to +=.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    boontune80
    Guest
    Thanks for that mate..


    Just got one more problem


    i have 6 variables that store points

    i need to sort them by number order highest at the top
    lowest at the bottem......

    any ideas?

  4. #4
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Use the search function at the top of the page and look for "bubblesort"
    It's a sorting algorithm if you're wondering.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Point in the right direction
    By peanutym in forum C++ Programming
    Replies: 3
    Last Post: 07-07-2008, 08:49 PM
  2. Point me in the right direction
    By vampje in forum C++ Programming
    Replies: 0
    Last Post: 06-07-2006, 03:52 AM
  3. Array of pointers to point objects
    By totalfreeloader in forum C++ Programming
    Replies: 6
    Last Post: 11-27-2003, 09:26 AM
  4. trouble with overloaded operator
    By kkurz in forum C++ Programming
    Replies: 2
    Last Post: 10-31-2003, 12:59 PM
  5. fixed point / floating point
    By confuted in forum Game Programming
    Replies: 4
    Last Post: 08-13-2002, 01:25 PM