1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Variables that change themselves over time

Discussion in 'C++' started by CODINGMASTER, Aug 22, 2007.

  1. CODINGMASTER

    CODINGMASTER New Member

    Joined:
    Aug 20, 2007
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    How to?

    For example, I want to make a pong game and I want the balls x value to increase over time. I have tried xvar=xvar+1; but that makes it remain static...

    Okay problem solved
     
  2. NewsBot

    NewsBot New Member

    Joined:
    Dec 2, 2008
    Messages:
    1,267
    Likes Received:
    1
    Trophy Points:
    0
    What do you mean by remain static? They change as you increase them by 1.
     
  3. CODINGMASTER

    CODINGMASTER New Member

    Joined:
    Aug 20, 2007
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Well I want them to change every frame/step. What happens is they change at program start and just stop.
     
  4. NewsBot

    NewsBot New Member

    Joined:
    Dec 2, 2008
    Messages:
    1,267
    Likes Received:
    1
    Trophy Points:
    0
    But when you make it xvar=xvar+1; it should change.
     
  5. bluedragon

    bluedragon New Member

    Joined:
    Sep 17, 2007
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    If u r using too many functions and most of them are using xvar then just make xvar as a static and global variable
    otherwise just declare it as static in main

    Then

    Try the same code
    it will work


    Static means that u are instructing the variable to retain its value
     

Share This Page