So, as a project for funzies, I decided to make a basic game where you run around the screen and get into fights when you encounter skeletons. However, I'm nowhere near the fighting parts yet.
So far, the main character only appears when he moves (no idle animation), erases rocks he passes over, and can escape the grid he's on. Here is the code for his motion. The commented out section makes pictures of the character standing pop up in places of the screen faaaar away from his location.

void movePlayer()
   {
   
      tempX = x;
      tempY = y;
   /*   if(!keypressed()) 
     {
       if(direction==1)
    {draw_sprite( buffer, standBack,y * 20, x * 20);}
    if(direction==3)
    {draw_sprite( buffer, standfront,y * 20, x * 20);}
    if(direction==2)
    {draw_sprite( buffer, standright,y * 20, x * 20);}
    if(direction==4)
    {draw_sprite( buffer, standleft,y * 20, x * 20);}
    }
   */  
      if ( (key[KEY_UP] && !key[KEY_LEFT])&& (key[KEY_UP] && !key[KEY_RIGHT]) && map[y--][x] == 3 &&objMap[y--][x]!=101)
      {
         objMap[y--][x] = 100;
         draw_sprite( buffer, runup, x * 20, y *20);              
         direction=1;
      
      }    
           
      if ( (key[KEY_DOWN]  && !key[KEY_LEFT])&& (key[KEY_DOWN] && !key[KEY_RIGHT]) && map[y ++][x] == 3 )
      {   
                
         objMap[y++][x] = 100;
         draw_sprite( buffer, rundown, x * 20, (y) *20);              
         direction=1;
      
      }                  
   
    
                
      if ( (key[KEY_RIGHT] && !key[KEY_LEFT])&& map[y][x ++] == 3)
      {
      
         objMap[y][x ++] = 100;
         draw_sprite( buffer, runright, x * 20, y * 20);
         direction=2;
           
      }
      if ( key[KEY_LEFT] && map[y][x - 1] == 3)
      {            
         objMap[y][x--] = 100;
         draw_sprite( buffer, runleft, (x) * 20, y * 20);
         direction=4;
      
      }

I had the same, but in DirectX. In DirectX I can't seem to get the image scaled that it matches the RECT it uses.
First try to get a bigger RECT, increase it if its too small and decrease when too big. (I don't know IF one uses RECT's with Allegro since I don't know Allegro).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.