Thread: variable auto resets itself?

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    118

    variable auto resets itself?

    hiya guys sorry if this seems trivial but ive tried all i can.

    im making a tile based game/engine and have a free roaming sprite (which i will turn into a tile at a later time)

    the problem is that i have 4 status's up,down,left,right for my sprite and want to animate it.

    Code:
    void Dot::show()
    {    if((xVel==0)&&(yVel>=0))
    {
    	statu = &down;
    	//frame++;
    	//apply_surface( box.x - camera.x, box.y - camera.y, dot, screen,&clipup[frame] );
    }
    else if ((xVel==0)&&(yVel<=0))
    {
    		statu = &up;
    		//frame++;
    		 
    }
    else if ((xVel<=0)&&(yVel==0))
    {
    		statu = &left;
    		//frame++;
    		  
    }
    else if ((xVel>=0)&&(yVel==0))
    {
    		statu = &right;
    		//frame++;
    		
    }
    
    //else {frame=0;}
    //if(frame>=3)
      // {frame=0;}
    
    if(*statu==up)
    {
    	apply_surface( box.x - camera.x, box.y - camera.y, dot, screen,&clipup[frame] );
    }
    else if(*statu==down)
    {
    	apply_surface( box.x - camera.x, box.y - camera.y, dot, screen,&clipdown[frame] );
    }
    else if(*statu==left)
    {
    	apply_surface( box.x - camera.x, box.y - camera.y, dot, screen,&clipleft[frame] );
    }
    else if(*statu==right)
    {
    	apply_surface( box.x - camera.x, box.y - camera.y, dot, screen,&clipright[frame] );
    }
       
    }
    theres some code i set the status (statu i evan changed the name incase that was the problem) so that it can use which ever set of animations it needs but after it has moved once it resets to facing down.

    at first i didnt have pointers at all but i thought that could be the problem but it didnt sovle it any help would be much appreciated thanks in advance

    edit:i have tried to debug it to see where in my code it resets but it says:: There is no source code available for the current location.::
    any ideas why i get that message?

    edit:edit: ok ive solved the reseting problem i was checking for>= and <= needed just > or <
    but i still get the debugger problem any ideas?
    Last edited by thestien; 08-14-2008 at 06:19 PM.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by thestien View Post
    edit:i have tried to debug it to see where in my code it resets but it says:: There is no source code available for the current location.::
    any ideas why i get that message?
    Have you set the source paths in your debugger?

    Particularly if you run the code from a directory that is different from the one you compile it to, you may need to change some settings.

    What debugger (gdb, WinDbg, Visual Studio, etc?), on what system (e.g. Linux, Windows?)

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3

    Join Date
    May 2005
    Posts
    1,042
    but i still get the debugger problem any ideas?
    Can you post the 'debugger' problems in more detail please? You outta be able to get this working in no time.
    I'm not immature, I'm refined in the opposite direction.

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    edit:i have tried to debug it to see where in my code it resets but it says:: There is no source code available for the current location.::
    any ideas why i get that message?
    You are compiling with debugging information enabled, right? (With GCC that would probably be the "-g" flag.)
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A very long list of questions... maybe to long...
    By Ravens'sWrath in forum C Programming
    Replies: 16
    Last Post: 05-16-2007, 05:36 AM
  2. variable being reset
    By FoodDude in forum C++ Programming
    Replies: 1
    Last Post: 09-15-2005, 12:30 PM
  3. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM
  4. Need help
    By awkeller in forum C Programming
    Replies: 2
    Last Post: 12-09-2001, 03:02 PM
  5. Variable Allocation in a simple operating system
    By awkeller in forum C Programming
    Replies: 1
    Last Post: 12-08-2001, 02:26 PM