   Collision Detection! SDL
  Ok, I'm gonna post the whole program. I'm using CodeBlocks cause for some reason I can't get this code to work in VS2008.I'm trying to make a megaman X game and it was comming along fine. I had X walking correctly and then I decided to work on the collision detection, so I could start my jump functions and the like....but I've changed the program like 20 times (seriously) and nothing works.I've tried to follow my code flow and figure out where the problem is, and I think the problem is in my draw() function or in my fall() function. Please, if you have time, look at this code and tell me what I should be doing, or just give me a hint, I've figured out all my other problems on my own lately, but this is starting to piss me off :D.As for the problem: When the program starts, X is positioned at the top of the screen, and I have set the lastInput variable to IDLE_RIGHT. I want to make sure that when the program starts, if there is nothing underneath X (ground) then the many if statements I've set up will decipher what should be done. What happens is X is rendered with many of the WRONG frames and he falls at a decent rate, but then, just as he touches the ground he stops for JUST a moment and then keeps falling. I've about pulled my dreads out over this. If you have TIME, please help me. You'll get credit when my game is done :DHere's the code. If you want the images to use to check what I'm talking about, go DL the sprite sheet from Sprites Inc. I used the MMX 5 sprites. I reversed the sprite sheet instead of writing code to flip the images...I'm lazy...No actually I couldn't get that part to work either, but I'm determined to figure that out on my own.Note: Ignore some of the commented stuff cause I've changed the program so many times that stuff is probably not what I should say. My net is off at my house so I had to post this somewhere else, and I don't have much time. Once again, thanks for the help, and anyone who sees code and wants to use some of it, go ahead, once the game is done, I'm putting all the code up so people can learn from my code(mistakes XD)#include <string>#include "SDL/SDL.h"#include "SDL/SDL_image.h"#include "SDL/SDL_ttf.h"#include "SDL/SDL_mixer.h"#include <cstdlib>SDL_Rect x_teleport_ani[ 16 ];SDL_Rect x_idle_ani[ 5 ];SDL_Rect x_walk_ani[ 64 ];  // OptimizedSDL_Rect reverse_x_walk_ani[ 64 ]; // OptimizedSDL_Rect reverse_x_idle_ani[ 5 ];SDL_Rect reverse_x_dash_ani[ 16 ];SDL_Rect x_dash_ani[ 16 ];SDL_Rect x_jump_ani[ 6 ];SDL_Rect x_fall_ani[ 2 ];SDL_Rect reverse_x_jump_ani[ 11 ];SDL_Rect reverse_x_fall_ani[ 1 ];SDL_Rect x_charge_one_ani[ 4 ];SDL_Rect x_shot_ani[ 16 ];SDL_Rect ground;// Constantsconst int SCREEN_WIDTH = 800;const int SCREEN_HEIGHT = 600;const int SCREEN_BPP = 32;const int FRAMES_PER_SECOND = 60;SDL_Surface *screen = NULL;SDL_Surface *background = NULL;SDL_Surface *no_armor_x = NULL;SDL_Surface *reverse_no_armor_x = NULL;SDL_Surface *charge_ani_one = NULL;SDL_Event event;SDL_Joystick *joystick = NULL;TTF_Font *font = NULL;SDL_Color textColor = {255, 255, 255};class Timer{    private:    //The clock time when the timer started    int startTicks;    //The ticks stored when the timer was paused    int pausedTicks;    //The timer status    bool paused;    bool started;    public:    //Initializes variables    Timer();    //The various clock actions    void start();    void stop();    void pause();    void unpause();    //Gets the timer's time    int get_ticks();    //Checks the status of the timer    bool is_started();    bool is_paused();};Timer::Timer(){    //Initialize the variables    startTicks = 0;    pausedTicks = 0;    paused = false;    started = false;}void Timer::start(){    //Start the timer    started = true;    //Unpause the timer    paused = false;    //Get the current clock time    startTicks = SDL_GetTicks();}void Timer::stop(){    //Stop the timer    started = false;    //Unpause the timer    paused = false;}int Timer::get_ticks(){    //If the timer is running    if( started == true )    {   //If the timer is paused   if( paused == true )   {  //Return the number of ticks when the timer was paused  return pausedTicks;   }   else   {  //Return the current time minus the start time  return SDL_GetTicks() - startTicks;   }    }    //If the timer isn't running    return 0;}void Timer::pause(){    //If the timer is running and isn't already paused    if( ( started == true ) && ( paused == false ) )    {   //Pause the timer   paused = true;   //Calculate the paused ticks   pausedTicks = SDL_GetTicks() - startTicks;    }}void Timer::unpause(){    //If the timer is paused    if( paused == true )    {   //Unpause the timer   paused = false;   //Reset the starting ticks   startTicks = SDL_GetTicks() - pausedTicks;   //Reset the paused ticks   pausedTicks = 0;    }}bool Timer::is_started(){    return started;}bool Timer::is_paused(){    return paused;}void apply_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination, SDL_Rect* clip = NULL ){    //Make a temporary rectangle to hold the offsets    SDL_Rect offset;    //Give the offsets to the rectangle    offset.x = x;    offset.y = y;    //Blit the surface    SDL_BlitSurface( source, clip, destination, &offset );}bool checkContactCollision(SDL_Rect* A, SDL_Rect B){    // The sides of the rectangles    int leftA, leftB;    int rightA, rightB;    int topA, topB;    int bottomA, bottomB;    // Calculate sides of A    leftA = A->x;    rightA = A->x + A->w;    topA = A->y;    bottomA = A->y + A->h;    // Calculate sides of B    leftB = B.x;    rightB = B.x + B.w;    topB = B.y;    bottomB = B.y + B.h;    // If any of the sides from A are outside of B    if(bottomA < topB)    {   return false;    }    if(rightA < leftB)    {   return false;    }    if(leftA > rightB)    {   return false;    }    if(bottomA == topB)    {   return true;    }}bool checkHitCollision(SDL_Rect A, SDL_Rect B){    // The sides of the rectangles    int leftA, leftB;    int rightA, rightB;    int topA, topB;    int bottomA, bottomB;    // Calculate sides of A    leftA = A.x;    rightA = A.x + A.w;    topA = A.y;    bottomA = A.y + A.h;    // Calculate sides of B    leftB = B.x;    rightB = B.x + B.w;    topB = B.y;    bottomB = B.y + B.h;    // If any of the sides from A are outside of B    if(bottomA <= topB)    {   return false;    }    if(topA >= bottomB)    {   return false;    }    if(rightA <= leftB)    {   return false;    }    if(leftA >= rightB)    {   return false;    }    // If none of the sides from  A are outside B    return true;}/********************************************************************************************************************************************************************************************** MMX CLASS ************************************************************************************************************************************************************************************************/class MMX{    private:    //The offset    int offSet;    int v_offSet;    //Its rate of movement    int velocity;    int v_velocity;    //Its current frame    int frame;    typedef enum statusVar { IDLE_RIGHT, IDLE_LEFT, DASH_RIGHT, DASH_LEFT, WALK_LEFT, WALK_RIGHT, JUMP_RIGHT, JUMP_LEFT, NEUTRAL, NORMAL_SHOT, CHARGE_ONE, FALLING_RIGHT, FALLING_LEFT, CHECKFALLING };    //Its animation status    statusVar lastInput;    public:    //Initializes the variables    MMX();    //Handles input    void handle_events();    //Moves the character    void move();    // Draws the character    void draw();    // Testing these functions    void idle(); // Works    void walkLeft();  // Works    void walkRight(); // Works    void fall();};MMX::MMX(){    //Initialize movement variables    offSet = 0;    v_offSet = 0;    velocity = 0;    v_velocity = 0;    //Initialize animation variables    frame = 0;    lastInput = MMX::IDLE_RIGHT;};void MMX::move(){    offSet += velocity;    v_offSet += v_velocity;    //Keep the stick figure in bounds    if( ( offSet < 0 ) || ( offSet + x_walk_ani[ frame ].w > SCREEN_WIDTH ) )    {   offSet -= velocity;    }    if(checkContactCollision(&x_idle_ani[frame], ground) && (velocity >= 0 || velocity <= 0) && lastInput == MMX::IDLE_RIGHT)    {   x_idle_ani[frame].y = ground.y;    }    if(checkContactCollision(&reverse_x_idle_ani[frame], ground) && (velocity >= 0 || velocity <= 0) && lastInput == MMX::IDLE_LEFT)    {   reverse_x_idle_ani[frame].y = ground.y;    }    if(checkContactCollision(&x_walk_ani[frame], ground) && (velocity >= 0 || velocity <= 0) && lastInput == MMX::WALK_RIGHT)    {   x_walk_ani[frame].y = ground.y;    }    if(checkContactCollision(&reverse_x_walk_ani[frame], ground) && (velocity >= 0 || velocity <= 0) && lastInput == MMX::WALK_LEFT)    {   reverse_x_walk_ani[frame].y = ground.y;    }};void MMX::draw(){    if(velocity == 0 && (checkContactCollision(&x_idle_ani[frame], ground) || checkContactCollision(&reverse_x_idle_ani[frame], ground)))//&& (lastInput == MMX::IDLE_LEFT || lastInput == MMX::IDLE_RIGHT))    {   idle();    }    if(velocity < 0 && (checkContactCollision(&reverse_x_walk_ani[frame], ground)))    {   walkLeft();    }    if(velocity > 0 && (checkContactCollision(&x_walk_ani[frame], ground)))    {   walkRight();    }};void MMX::fall(){    if((lastInput == MMX::IDLE_RIGHT || lastInput == MMX::WALK_RIGHT || lastInput == MMX::DASH_RIGHT || lastInput == MMX::JUMP_RIGHT) && !checkContactCollision(&x_fall_ani[0], ground))    {   lastInput = MMX::FALLING_RIGHT;   v_velocity++;   if(v_velocity >= 5)   {  v_velocity --;   }   apply_surface(offSet, v_offSet, no_armor_x, screen, &x_fall_ani[0]);   if(checkContactCollision(&x_fall_ani[1], ground))   {  idle();   }    }    if((lastInput == MMX::IDLE_LEFT || lastInput == MMX::WALK_LEFT || lastInput == MMX::DASH_LEFT || lastInput == MMX::JUMP_LEFT) && !checkContactCollision(&reverse_x_fall_ani[0], ground))    {   lastInput = MMX::FALLING_LEFT;   v_velocity++;   if(v_velocity >= 5)   {  v_velocity --;   }   apply_surface(offSet, v_offSet, reverse_no_armor_x, screen, &reverse_x_fall_ani[0]);   if(checkContactCollision(&reverse_x_fall_ani[0], ground))   {  idle();   }    }};void MMX::idle(){    if(checkContactCollision(&x_idle_ani[frame], ground) && lastInput == MMX::WALK_RIGHT || lastInput == MMX::IDLE_RIGHT || lastInput == FALLING_RIGHT)    {   lastInput = MMX::IDLE_RIGHT;   frame = 0;   apply_surface( offSet, v_offSet , no_armor_x, screen, &x_idle_ani[ frame ] );    }    else if(checkContactCollision(&reverse_x_idle_ani[frame], ground) && lastInput == MMX::WALK_LEFT || lastInput == MMX::IDLE_LEFT)    {   lastInput = MMX::IDLE_LEFT;   frame = 0;   apply_surface( offSet, v_offSet, reverse_no_armor_x, screen, &reverse_x_idle_ani[ frame ] );    }};void MMX::walkLeft(){    lastInput = WALK_LEFT;    if(velocity == 0)    {   idle();    }    frame++;    apply_surface( offSet, v_offSet , reverse_no_armor_x, screen, &reverse_x_walk_ani[ frame ] );    if(frame >= 63)    {   frame = 9;    }};void MMX::walkRight(){    lastInput = WALK_RIGHT;    if(velocity == 0)    {   idle();    }    frame++;    apply_surface( offSet, v_offSet , no_armor_x, screen, &x_walk_ani[ frame ] );    if(frame >= 63)    {   frame = 9;    }};/*************************************************** **************** HANDLE EVENTS ******************** ***************************************************/void MMX::handle_events(){    if(event.type == SDL_JOYAXISMOTION)    {  if(event.jaxis.which == 0)  { if(event.jaxis.axis == 0) {if(event.jaxis.value <= 8000 && event.jaxis.value >= -8000){    velocity = 0;}if(event.jaxis.value > 8000){   velocity = 5;}if(event.jaxis.value < -8000){    velocity = -5;} }  }    }    /*if(event.jbutton.button)    {   if(event.type == SDL_JOYBUTTONDOWN)   {  // Handle Joystick Button Presses  if ( event.jbutton.button == 3 )  { if( lastInput == WALK_RIGHT) {status = DASH_RIGHT; } else if(lastInput == WALK_LEFT) {status = DASH_LEFT; }  }  if(event.jbutton.button == 0)  { status = NORMAL_SHOT;  }  if(event.jbutton.button == 2)  { status = JUMP_RIGHT;  }   }   if(event.type == SDL_JOYBUTTONUP)   {  if ( event.jbutton.button == 3 ) // Dash  { status = NEUTRAL;  }  if(event.jbutton.button == 2) // Jump  { status = CHECKFALLING;  }   }    }*/};/***************************************************************************** ************************* MMX CLASS END ************************************* *****************************************************************************/MMX X;using namespace std;SDL_Surface *load_image( string filename ){    SDL_Surface* loadedImage = NULL;    SDL_Surface* optimizedImage = NULL;    loadedImage = IMG_Load( filename.c_str() );    if(loadedImage != NULL)    {   //Map the color   optimizedImage = SDL_DisplayFormat( loadedImage );   SDL_FreeSurface( loadedImage );   if( optimizedImage != NULL )   {  Uint32 colorkey = SDL_MapRGB(optimizedImage->format, 255, 0, 228);  //Set all pixels  of color R 255, G 0, B 228 to be transparent  SDL_SetColorKey( optimizedImage, SDL_SRCCOLORKEY, colorkey);   }   // Return the optimized image   return optimizedImage;    }}bool init(){    //Initialize all SDL subsystems    if( SDL_Init( SDL_INIT_EVERYTHING ) == -1 )   {  return false;   }    //Set up the screen    screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE );    //If there was an error in setting up the screen    if( screen == NULL )   {  printf("Error message: %s\n", IMG_GetError());  SDL_Delay(2000);  return false;   }    // Initialize TTF_Font    if(TTF_Init() == -1)    {   return false;    }/*    if(Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 2, 4096) == -1)    {   return false;    }*/    //Check if there's any joysticks    // Seed random    srand(SDL_GetTicks());    if( SDL_NumJoysticks() < 1 )    {   return false;    }    //Open the joystick    joystick = SDL_JoystickOpen( 0 );    SDL_JoystickNumButtons(joystick);    //If there's a problem opening the joystick    if( joystick == NULL )    {   return false;    }    //Set the window caption    SDL_WM_SetCaption( "Megaman X: The Human War", NULL );    //If everything initialized fine    return true;}bool load_files(){    //Load the image    background = load_image("background.png");    //If there was an error in loading...    if(background == NULL )    {  printf("Error message: %s\n", IMG_GetError());  SDL_Delay(2000);  return false;    }    charge_ani_one = load_image("charge_sheet.png");    font = TTF_OpenFont("arialbd.ttf", 72);    if(font == NULL)    {   return false;    }    /*    music = Mix_LoadMUS("To Zanarkand.mp3");    if(music == NULL)    {   printf("Music Problem: %s\n", IMG_GetError());   return false;    }   */    no_armor_x = load_image("no_armor_x_sheet.png");    if( no_armor_x == NULL )    {  printf("Error message: %s\n", IMG_GetError());  SDL_Delay(2000);  return false;    }    reverse_no_armor_x = load_image("reverse_no_armor_x_sheet.png");    if( reverse_no_armor_x == NULL )    {   printf("Error message: %s\n", IMG_GetError());   return false;    }    //If it worked    return true;}void setClips(){   // Shot Animations    x_shot_ani[ 0 ].x = 130;    x_shot_ani[ 0 ].y = 442;    x_shot_ani[ 0 ].w = 75;    x_shot_ani[ 0 ].h = 65;    x_shot_ani[ 1 ].x = 130;    x_shot_ani[ 1 ].y = 442;    x_shot_ani[ 1 ].w = 75;    x_shot_ani[ 1 ].h = 65;    x_shot_ani[ 2 ].x = 215;    x_shot_ani[ 2 ].y = 442;    x_shot_ani[ 2 ].w = 75;    x_shot_ani[ 2 ].h = 65;    x_shot_ani[ 3 ].x = 215;    x_shot_ani[ 3 ].y = 442;    x_shot_ani[ 3 ].w = 75;    x_shot_ani[ 3 ].h = 65;    x_shot_ani[ 4 ].x = 300;    x_shot_ani[ 4 ].y = 442;    x_shot_ani[ 4 ].w = 75;    x_shot_ani[ 4 ].h = 65;    x_shot_ani[ 5 ].x = 300;    x_shot_ani[ 5 ].y = 442;    x_shot_ani[ 5 ].w = 75;    x_shot_ani[ 5 ].h = 65;    x_shot_ani[ 6 ].x = 388;    x_shot_ani[ 6 ].y = 442;    x_shot_ani[ 6 ].w = 75;    x_shot_ani[ 6 ].h = 65;    x_shot_ani[ 7 ].x = 388;    x_shot_ani[ 7 ].y = 442;    x_shot_ani[ 7 ].w = 75;    x_shot_ani[ 7 ].h = 65;    x_shot_ani[ 8 ].x = 475;    x_shot_ani[ 8 ].y = 442;    x_shot_ani[ 8 ].w = 79;    x_shot_ani[ 8 ].h = 66;    x_shot_ani[ 9 ].x = 475;    x_shot_ani[ 9 ].y = 442;    x_shot_ani[ 9 ].w = 79;    x_shot_ani[ 9 ].h = 66;    x_shot_ani[ 10 ].x = 564;    x_shot_ani[ 10 ].y = 442;    x_shot_ani[ 10 ].w = 62;    x_shot_ani[ 10 ].h = 66;    x_shot_ani[ 11 ].x = 564;    x_shot_ani[ 11 ].y = 442;    x_shot_ani[ 11 ].w = 62;    x_shot_ani[ 11 ].h = 66;    x_shot_ani[ 12 ].x = 634;    x_shot_ani[ 12 ].y = 442;    x_shot_ani[ 12 ].w = 59;    x_shot_ani[ 12 ].h = 66;    x_shot_ani[ 13 ].x = 634;    x_shot_ani[ 13 ].y = 442;    x_shot_ani[ 13 ].w = 59;    x_shot_ani[ 13 ].h = 66;    x_shot_ani[ 14 ].x = 700;    x_shot_ani[ 14 ].y = 442;    x_shot_ani[ 14 ].w = 53;    x_shot_ani[ 14 ].h = 67;    x_shot_ani[ 15 ].x = 700;    x_shot_ani[ 15 ].y = 442;    x_shot_ani[ 15 ].w = 53;    x_shot_ani[ 15 ].h = 67;    // Charge Animations    x_charge_one_ani[ 0 ].x = 7;    x_charge_one_ani[ 0 ].y = 18;    x_charge_one_ani[ 0 ].w = 59;    x_charge_one_ani[ 0 ].h = 67;    x_charge_one_ani[ 1 ].x = 75;    x_charge_one_ani[ 1 ].y = 13;    x_charge_one_ani[ 1 ].w = 66;    x_charge_one_ani[ 1 ].h = 74;    x_charge_one_ani[ 2 ].x = 148;    x_charge_one_ani[ 2 ].y = 6;    x_charge_one_ani[ 2 ].w = 66;    x_charge_one_ani[ 2 ].h = 74;    x_charge_one_ani[ 3 ].x = 223;    x_charge_one_ani[ 3 ].y = 4;    x_charge_one_ani[ 3 ].w = 61;    x_charge_one_ani[ 3 ].h = 73;    // X Teleport    x_teleport_ani[ 0 ].x = 127;    x_teleport_ani[ 0 ].y = 18;    x_teleport_ani[ 0 ].w = 10;    x_teleport_ani[ 0 ].h = 121;    x_teleport_ani[ 1 ].x = 148;    x_teleport_ani[ 1 ].y = 42;    x_teleport_ani[ 1 ].w = 33;    x_teleport_ani[ 1 ].h = 97;    x_teleport_ani[ 2 ].x = 186;    x_teleport_ani[ 2 ].y = 89;    x_teleport_ani[ 2 ].w = 61;    x_teleport_ani[ 2 ].h = 49;    x_teleport_ani[ 3 ].x = 256;    x_teleport_ani[ 3 ].y = 74;    x_teleport_ani[ 3 ].w = 91;    x_teleport_ani[ 3 ].h = 79;    x_teleport_ani[ 4 ].x = 357;    x_teleport_ani[ 4 ].y = 68;    x_teleport_ani[ 4 ].w = 97;    x_teleport_ani[ 4 ].h = 91;    x_teleport_ani[ 5 ].x = 465;    x_teleport_ani[ 5 ].y = 65;    x_teleport_ani[ 5 ].w = 97;    x_teleport_ani[ 5 ].h = 97;    x_teleport_ani[ 6 ].x = 574;    x_teleport_ani[ 6 ].y = 65;    x_teleport_ani[ 6 ].w = 97;    x_teleport_ani[ 6 ].h = 97;    x_teleport_ani[ 7 ].x = 684;    x_teleport_ani[ 7 ].y = 74;    x_teleport_ani[ 7 ].w = 82;    x_teleport_ani[ 7 ].h = 79;    x_teleport_ani[ 8 ].x = 123;    x_teleport_ani[ 8 ].y = 192;    x_teleport_ani[ 8 ].w = 62;    x_teleport_ani[ 8 ].h = 63;    x_teleport_ani[ 9 ].x = 196;    x_teleport_ani[ 9 ].y = 186;    x_teleport_ani[ 9 ].w = 52;    x_teleport_ani[ 9 ].h = 63;    x_teleport_ani[ 10 ].x = 295;    x_teleport_ani[ 10 ].y = 183;    x_teleport_ani[ 10 ].w = 52;    x_teleport_ani[ 10 ].h = 66;    x_teleport_ani[ 11 ].x = 328;    x_teleport_ani[ 11 ].y = 180;    x_teleport_ani[ 11 ].w = 49;    x_teleport_ani[ 11 ].h = 69;    x_teleport_ani[ 12 ].x = 390;    x_teleport_ani[ 12 ].y = 167;    x_teleport_ani[ 12 ].w = 32;    x_teleport_ani[ 12 ].h = 82;    x_teleport_ani[ 13 ].x = 435;    x_teleport_ani[ 13 ].y = 165;    x_teleport_ani[ 13 ].w = 31;    x_teleport_ani[ 13 ].h = 84;    x_teleport_ani[ 14 ].x = 477;    x_teleport_ani[ 14 ].y = 177;    x_teleport_ani[ 14 ].w = 103;    x_teleport_ani[ 14 ].h = 72;    x_teleport_ani[ 15 ].x = 583;    x_teleport_ani[ 15 ].y = 183;    x_teleport_ani[ 15 ].w = 102;    x_teleport_ani[ 15 ].h = 66;    x_teleport_ani[ 16 ].x = 693;    x_teleport_ani[ 16 ].y = 180;    x_teleport_ani[ 16 ].w = 56;    x_teleport_ani[ 16 ].h = 69;    // Walk    x_walk_ani[ 0 ].x = 174;    x_walk_ani[ 0 ].y = 640;    x_walk_ani[ 0 ].w = 50;    x_walk_ani[ 0 ].h = 68;    x_walk_ani[ 1 ].x = 174;    x_walk_ani[ 1 ].y = 640;    x_walk_ani[ 1 ].w = 50;    x_walk_ani[ 1 ].h = 68;    x_walk_ani[ 2 ].x = 174;    x_walk_ani[ 2 ].y = 640;    x_walk_ani[ 2 ].w = 50;    x_walk_ani[ 2 ].h = 68;    x_walk_ani[ 3 ].x = 174;    x_walk_ani[ 3 ].y = 640;    x_walk_ani[ 3 ].w = 50;    x_walk_ani[ 3 ].h = 68;    x_walk_ani[ 4 ].x = 231;    x_walk_ani[ 4 ].y = 639;    x_walk_ani[ 4 ].w = 48;    x_walk_ani[ 4 ].h = 68;    x_walk_ani[ 5 ].x = 231;    x_walk_ani[ 5 ].y = 639;    x_walk_ani[ 5 ].w = 48;    x_walk_ani[ 5 ].h = 68;    x_walk_ani[ 6 ].x = 231;    x_walk_ani[ 6 ].y = 639;    x_walk_ani[ 6 ].w = 48;    x_walk_ani[ 6 ].h = 68;    x_walk_ani[ 7 ].x = 231;    x_walk_ani[ 7 ].y = 639;    x_walk_ani[ 7 ].w = 48;    x_walk_ani[ 7 ].h = 68;    x_walk_ani[ 8 ].x = 290;    x_walk_ani[ 8 ].y = 635;    x_walk_ani[ 8 ].w = 47;    x_walk_ani[ 8 ].h = 69;    x_walk_ani[ 9 ].x = 290;    x_walk_ani[ 9 ].y = 635;    x_walk_ani[ 9 ].w = 47;    x_walk_ani[ 9 ].h = 69;    x_walk_ani[ 10 ].x = 290;    x_walk_ani[ 10 ].y = 635;    x_walk_ani[ 10 ].w = 47;    x_walk_ani[ 10 ].h = 69;    x_walk_ani[ 11 ].x = 290;    x_walk_ani[ 11 ].y = 635;    x_walk_ani[ 11 ].w = 47;    x_walk_ani[ 11 ].h = 69;    x_walk_ani[ 12 ].x = 348;    x_walk_ani[ 12 ].y = 638;    x_walk_ani[ 12 ].w = 61;    x_walk_ani[ 12 ].h = 67;    x_walk_ani[ 13 ].x = 348;    x_walk_ani[ 13 ].y = 638;    x_walk_ani[ 13 ].w = 61;    x_walk_ani[ 13 ].h = 67;    x_walk_ani[ 14 ].x = 348;    x_walk_ani[ 14 ].y = 638;    x_walk_ani[ 14 ].w = 61;    x_walk_ani[ 14 ].h = 67;    x_walk_ani[ 15 ].x = 348;    x_walk_ani[ 15 ].y = 638;    x_walk_ani[ 15 ].w = 61;    x_walk_ani[ 15 ].h = 67;    x_walk_ani[ 16 ].x = 415;    x_walk_ani[ 16 ].y = 639;    x_walk_ani[ 16 ].w = 73;    x_walk_ani[ 16 ].h = 66;    x_walk_ani[ 17 ].x = 415;    x_walk_ani[ 17 ].y = 639;    x_walk_ani[ 17 ].w = 73;    x_walk_ani[ 17 ].h = 66;    x_walk_ani[ 18 ].x = 415;    x_walk_ani[ 18 ].y = 639;    x_walk_ani[ 18 ].w = 73;    x_walk_ani[ 18 ].h = 66;    x_walk_ani[ 19 ].x = 415;    x_walk_ani[ 19 ].y = 639;    x_walk_ani[ 19 ].w = 73;    x_walk_ani[ 19 ].h = 66;    x_walk_ani[ 20 ].x = 497;    x_walk_ani[ 20 ].y = 641;    x_walk_ani[ 20 ].w = 73;    x_walk_ani[ 20 ].h = 64;    x_walk_ani[ 21 ].x = 497;    x_walk_ani[ 21 ].y = 641;    x_walk_ani[ 21 ].w = 73;    x_walk_ani[ 21 ].h = 64;    x_walk_ani[ 22 ].x = 497;    x_walk_ani[ 22 ].y = 641;    x_walk_ani[ 22 ].w = 73;    x_walk_ani[ 22 ].h = 64;    x_walk_ani[ 23 ].x = 497;    x_walk_ani[ 23 ].y = 641;    x_walk_ani[ 23 ].w = 73;    x_walk_ani[ 23 ].h = 64;    x_walk_ani[ 24 ].x = 579;    x_walk_ani[ 24 ].y = 640;    x_walk_ani[ 24 ].w = 59;    x_walk_ani[ 24 ].h = 65;    x_walk_ani[ 25 ].x = 579;    x_walk_ani[ 25 ].y = 640;    x_walk_ani[ 25 ].w = 59;    x_walk_ani[ 25 ].h = 65;    x_walk_ani[ 26 ].x = 579;    x_walk_ani[ 26 ].y = 640;    x_walk_ani[ 26 ].w = 59;    x_walk_ani[ 26 ].h = 65;    x_walk_ani[ 27 ].x = 579;    x_walk_ani[ 27 ].y = 640;    x_walk_ani[ 27 ].w = 59;    x_walk_ani[ 27 ].h = 65;    x_walk_ani[ 28 ].x = 652;    x_walk_ani[ 28 ].y = 638;    x_walk_ani[ 28 ].w = 46;    x_walk_ani[ 28 ].h = 68;    x_walk_ani[ 29 ].x = 652;    x_walk_ani[ 29 ].y = 638;    x_walk_ani[ 29 ].w = 46;    x_walk_ani[ 29 ].h = 68;    x_walk_ani[ 30 ].x = 652;    x_walk_ani[ 30 ].y = 638;    x_walk_ani[ 30 ].w = 46;    x_walk_ani[ 30 ].h = 68;    x_walk_ani[ 31 ].x = 652;    x_walk_ani[ 31 ].y = 638;    x_walk_ani[ 31 ].w = 46;    x_walk_ani[ 31 ].h = 68;    x_walk_ani[ 32 ].x = 182;    x_walk_ani[ 32 ].y = 721;    x_walk_ani[ 32 ].w = 41;    x_walk_ani[ 32 ].h = 70;    x_walk_ani[ 33 ].x = 182;    x_walk_ani[ 33 ].y = 721;    x_walk_ani[ 33 ].w = 41;    x_walk_ani[ 33 ].h = 70;    x_walk_ani[ 34 ].x = 182;    x_walk_ani[ 34 ].y = 721;    x_walk_ani[ 34 ].w = 41;    x_walk_ani[ 34 ].h = 70;    x_walk_ani[ 35 ].x = 182;    x_walk_ani[ 35 ].y = 721;    x_walk_ani[ 35 ].w = 41;    x_walk_ani[ 35 ].h = 70;    x_walk_ani[ 36 ].x = 235;    x_walk_ani[ 36 ].y = 720;    x_walk_ani[ 36 ].w = 54;    x_walk_ani[ 36 ].h = 69;    x_walk_ani[ 37 ].x = 235;    x_walk_ani[ 37 ].y = 720;    x_walk_ani[ 37 ].w = 54;    x_walk_ani[ 37 ].h = 69;    x_walk_ani[ 38 ].x = 235;    x_walk_ani[ 38 ].y = 720;    x_walk_ani[ 38 ].w = 54;    x_walk_ani[ 38 ].h = 69;    x_walk_ani[ 39 ].x = 235;    x_walk_ani[ 39 ].y = 720;    x_walk_ani[ 39 ].w = 54;    x_walk_ani[ 39 ].h = 69;    x_walk_ani[ 40 ].x = 298;    x_walk_ani[ 40 ].y = 722;    x_walk_ani[ 40 ].w = 61;    x_walk_ani[ 40 ].h = 68;    x_walk_ani[ 41 ].x = 298;    x_walk_ani[ 41 ].y = 722;    x_walk_ani[ 41 ].w = 61;    x_walk_ani[ 41 ].h = 68;    x_walk_ani[ 42 ].x = 298;    x_walk_ani[ 42 ].y = 722;    x_walk_ani[ 42 ].w = 61;    x_walk_ani[ 42 ].h = 68;    x_walk_ani[ 43 ].x = 298;    x_walk_ani[ 43 ].y = 722;    x_walk_ani[ 43 ].w = 61;    x_walk_ani[ 43 ].h = 68;    x_walk_ani[ 44 ].x = 364;    x_walk_ani[ 44 ].y = 723;    x_walk_ani[ 44 ].w = 64;    x_walk_ani[ 44 ].h = 67;    x_walk_ani[ 45 ].x = 364;    x_walk_ani[ 45 ].y = 723;    x_walk_ani[ 45 ].w = 64;    x_walk_ani[ 45 ].h = 67;    x_walk_ani[ 46 ].x = 364;    x_walk_ani[ 46 ].y = 723;    x_walk_ani[ 46 ].w = 64;    x_walk_ani[ 46 ].h = 67;    x_walk_ani[ 47 ].x = 364;    x_walk_ani[ 47 ].y = 723;    x_walk_ani[ 47 ].w = 64;    x_walk_ani[ 47 ].h = 67;    x_walk_ani[ 48 ].x = 440;    x_walk_ani[ 48 ].y = 724;    x_walk_ani[ 48 ].w = 64;    x_walk_ani[ 48 ].h = 67;    x_walk_ani[ 49 ].x = 440;    x_walk_ani[ 49 ].y = 724;    x_walk_ani[ 49 ].w = 64;    x_walk_ani[ 49 ].h = 67;    x_walk_ani[ 50 ].x = 440;    x_walk_ani[ 50 ].y = 724;    x_walk_ani[ 50 ].w = 64;    x_walk_ani[ 50 ].h = 67;    x_walk_ani[ 51 ].x = 440;    x_walk_ani[ 51 ].y = 724;    x_walk_ani[ 51 ].w = 64;    x_walk_ani[ 51 ].h = 67;    x_walk_ani[ 52 ].x = 514;    x_walk_ani[ 52 ].y = 723;    x_walk_ani[ 52 ].w = 57;    x_walk_ani[ 52 ].h = 69;    x_walk_ani[ 53 ].x = 514;    x_walk_ani[ 53 ].y = 723;    x_walk_ani[ 53 ].w = 57;    x_walk_ani[ 53 ].h = 69;    x_walk_ani[ 54 ].x = 514;    x_walk_ani[ 54 ].y = 723;    x_walk_ani[ 54 ].w = 57;    x_walk_ani[ 54 ].h = 69;    x_walk_ani[ 55 ].x = 514;    x_walk_ani[ 55 ].y = 723;    x_walk_ani[ 55 ].w = 57;    x_walk_ani[ 55 ].h = 69;    x_walk_ani[ 56 ].x = 585;    x_walk_ani[ 56 ].y = 721;    x_walk_ani[ 56 ].w = 49;    x_walk_ani[ 56 ].h = 70;    x_walk_ani[ 57 ].x = 585;    x_walk_ani[ 57 ].y = 721;    x_walk_ani[ 57 ].w = 49;    x_walk_ani[ 57 ].h = 70;    x_walk_ani[ 58 ].x = 585;    x_walk_ani[ 58 ].y = 721;    x_walk_ani[ 58 ].w = 49;    x_walk_ani[ 58 ].h = 70;    x_walk_ani[ 59 ].x = 585;    x_walk_ani[ 59 ].y = 721;    x_walk_ani[ 59 ].w = 49;    x_walk_ani[ 59 ].h = 70;    x_walk_ani[ 60 ].x = 644;    x_walk_ani[ 60 ].y = 720;    x_walk_ani[ 60 ].w = 42;    x_walk_ani[ 60 ].h = 72;    x_walk_ani[ 61 ].x = 644;    x_walk_ani[ 61 ].y = 720;    x_walk_ani[ 61 ].w = 42;    x_walk_ani[ 61 ].h = 72;    x_walk_ani[ 62 ].x = 644;    x_walk_ani[ 62 ].y = 720;    x_walk_ani[ 62 ].w = 42;    x_walk_ani[ 62 ].h = 72;    x_walk_ani[ 63 ].x = 644;    x_walk_ani[ 63 ].y = 720;    x_walk_ani[ 63 ].w = 42;    x_walk_ani[ 63 ].h = 72;    // Dash    x_dash_ani[ 0 ].x = 144;    x_dash_ani[ 0 ].y = 808;    x_dash_ani[ 0 ].w = 55;    x_dash_ani[ 0 ].h = 63;    x_dash_ani[ 1 ].x = 206;    x_dash_ani[ 1 ].y = 818;    x_dash_ani[ 1 ].w = 70;    x_dash_ani[ 1 ].h = 55;    x_dash_ani[ 2 ].x = 284;    x_dash_ani[ 2 ].y = 825;    x_dash_ani[ 2 ].w = 81;    x_dash_ani[ 2 ].h = 48;    x_dash_ani[ 3 ].x = 284;    x_dash_ani[ 3 ].y = 825;    x_dash_ani[ 3 ].w = 81;    x_dash_ani[ 3 ].h = 48;    x_dash_ani[ 4 ].x = 284;    x_dash_ani[ 4 ].y = 825;    x_dash_ani[ 4 ].w = 81;    x_dash_ani[ 4 ].h = 48;    x_dash_ani[ 5 ].x = 372;    x_dash_ani[ 5 ].y = 825;    x_dash_ani[ 5 ].w = 86;    x_dash_ani[ 5 ].h = 48;    x_dash_ani[ 6 ].x = 372;    x_dash_ani[ 6 ].y = 825;    x_dash_ani[ 6 ].w = 86;    x_dash_ani[ 6 ].h = 48;    x_dash_ani[ 7 ].x = 372;    x_dash_ani[ 7 ].y = 825;    x_dash_ani[ 7 ].w = 86;    x_dash_ani[ 7 ].h = 48;    x_dash_ani[ 8 ].x = 466;    x_dash_ani[ 8 ].y = 808;    x_dash_ani[ 8 ].w = 58;    x_dash_ani[ 8 ].h = 65;    x_dash_ani[ 9 ].x = 531;    x_dash_ani[ 9 ].y = 807;    x_dash_ani[ 9 ].w = 47;    x_dash_ani[ 9 ].h = 65;    x_dash_ani[ 10 ].x = 580;    x_dash_ani[ 10 ].y = 807;    x_dash_ani[ 10 ].w = 71;    x_dash_ani[ 10 ].h = 66;    x_dash_ani[ 11 ].x = 657;    x_dash_ani[ 11 ].y = 808;    x_dash_ani[ 11 ].w = 56;    x_dash_ani[ 11 ].h = 65;    // Idle    x_idle_ani[ 0 ].x = 286;    x_idle_ani[ 0 ].y = 257;    x_idle_ani[ 0 ].w = 55;    x_idle_ani[ 0 ].h = 70;    x_idle_ani[ 1 ].x = 349;    x_idle_ani[ 1 ].y = 258;    x_idle_ani[ 1 ].w = 54;    x_idle_ani[ 1 ].h = 69;    x_idle_ani[ 2 ].x = 414;    x_idle_ani[ 2 ].y = 259;    x_idle_ani[ 2 ].w = 53;    x_idle_ani[ 2 ].h = 68;    x_idle_ani[ 3 ].x = 479;    x_idle_ani[ 3 ].y = 261;    x_idle_ani[ 3 ].w = 54;    x_idle_ani[ 3 ].h = 66;    x_idle_ani[ 4 ].x = 541;    x_idle_ani[ 4 ].y = 259;    x_idle_ani[ 4 ].w = 55;    x_idle_ani[ 4 ].h = 68;    // Jump    x_jump_ani[ 0 ].x = 150;    x_jump_ani[ 0 ].y = 338;    x_jump_ani[ 0 ].w = 39;    x_jump_ani[ 0 ].h = 79;    x_jump_ani[ 1 ].x = 200;    x_jump_ani[ 1 ].y = 338;    x_jump_ani[ 1 ].w = 36;    x_jump_ani[ 1 ].h = 80;    x_jump_ani[ 2 ].x = 246;    x_jump_ani[ 2 ].y = 338;    x_jump_ani[ 2 ].w = 36;    x_jump_ani[ 2 ].h = 80;    x_jump_ani[ 3 ].x = 307;    x_jump_ani[ 3 ].y = 338;    x_jump_ani[ 3 ].w = 37;    x_jump_ani[ 3 ].h = 87;    x_jump_ani[ 4 ].x = 357;    x_jump_ani[ 4 ].y = 343;    x_jump_ani[ 4 ].w = 41;    x_jump_ani[ 4 ].h = 82;    x_jump_ani[ 5 ].x = 411;    x_jump_ani[ 5 ].y = 344;    x_jump_ani[ 5 ].w = 52;    x_jump_ani[ 5 ].h = 76;    // Falling    x_fall_ani[ 0 ].x = 472;    x_fall_ani[ 0 ].y = 343;    x_fall_ani[ 0 ].w = 48;    x_fall_ani[ 0 ].h = 79;    x_fall_ani[ 1 ].x = 531;    x_fall_ani[ 1 ].y = 342;    x_fall_ani[ 1 ].w = 46;    x_fall_ani[ 1 ].h = 81;    // Reversed Idle    reverse_x_idle_ani[ 0 ].x = 560;    reverse_x_idle_ani[ 0 ].y = 258;    reverse_x_idle_ani[ 0 ].w = 55;    reverse_x_idle_ani[ 0 ].h = 69;    reverse_x_idle_ani[ 1 ].x = 495;    reverse_x_idle_ani[ 1 ].y = 258;    reverse_x_idle_ani[ 1 ].w = 55;    reverse_x_idle_ani[ 1 ].h = 70;    reverse_x_idle_ani[ 2 ].x = 432;    reverse_x_idle_ani[ 2 ].y = 260;    reverse_x_idle_ani[ 2 ].w = 55;    reverse_x_idle_ani[ 2 ].h = 68;    reverse_x_idle_ani[ 3 ].x = 365;    reverse_x_idle_ani[ 3 ].y = 258;    reverse_x_idle_ani[ 3 ].w = 57;    reverse_x_idle_ani[ 3 ].h = 70;    reverse_x_idle_ani[ 4 ].x = 302;    reverse_x_idle_ani[ 4 ].y = 258;    reverse_x_idle_ani[ 4 ].w = 57;    reverse_x_idle_ani[ 4 ].h = 69;    // Reversed Walk    reverse_x_walk_ani[ 0 ].x = 675;    reverse_x_walk_ani[ 0 ].y = 639;    reverse_x_walk_ani[ 0 ].w = 50;    reverse_x_walk_ani[ 0 ].h = 68;    reverse_x_walk_ani[ 1 ].x = 675;    reverse_x_walk_ani[ 1 ].y = 639;    reverse_x_walk_ani[ 1 ].w = 50;    reverse_x_walk_ani[ 1 ].h = 68;    reverse_x_walk_ani[ 2 ].x = 675;    reverse_x_walk_ani[ 2 ].y = 639;    reverse_x_walk_ani[ 2 ].w = 50;    reverse_x_walk_ani[ 2 ].h = 68;    reverse_x_walk_ani[ 3 ].x = 675;    reverse_x_walk_ani[ 3 ].y = 639;    reverse_x_walk_ani[ 3 ].w = 50;    reverse_x_walk_ani[ 3 ].h = 68;    reverse_x_walk_ani[ 4 ].x = 619;    reverse_x_walk_ani[ 4 ].y = 638;    reverse_x_walk_ani[ 4 ].w = 48;    reverse_x_walk_ani[ 4 ].h = 69;    reverse_x_walk_ani[ 5 ].x = 619;    reverse_x_walk_ani[ 5 ].y = 638;    reverse_x_walk_ani[ 5 ].w = 48;    reverse_x_walk_ani[ 5 ].h = 69;    reverse_x_walk_ani[ 6 ].x = 619;    reverse_x_walk_ani[ 6 ].y = 638;    reverse_x_walk_ani[ 6 ].w = 48;    reverse_x_walk_ani[ 6 ].h = 69;    reverse_x_walk_ani[ 7 ].x = 619;    reverse_x_walk_ani[ 7 ].y = 638;    reverse_x_walk_ani[ 7 ].w = 48;    reverse_x_walk_ani[ 7 ].h = 69;    reverse_x_walk_ani[ 8 ].x = 561;    reverse_x_walk_ani[ 8 ].y = 636;    reverse_x_walk_ani[ 8 ].w = 49;    reverse_x_walk_ani[ 8 ].h = 69;    reverse_x_walk_ani[ 9 ].x = 561;    reverse_x_walk_ani[ 9 ].y = 636;    reverse_x_walk_ani[ 9 ].w = 49;    reverse_x_walk_ani[ 9 ].h = 69;    reverse_x_walk_ani[ 10 ].x = 561;    reverse_x_walk_ani[ 10 ].y = 636;    reverse_x_walk_ani[ 10 ].w = 49;    reverse_x_walk_ani[ 10 ].h = 69;    reverse_x_walk_ani[ 11 ].x = 561;    reverse_x_walk_ani[ 11 ].y = 636;    reverse_x_walk_ani[ 11 ].w = 49;    reverse_x_walk_ani[ 11 ].h = 69;    reverse_x_walk_ani[ 12 ].x = 490;    reverse_x_walk_ani[ 12 ].y = 638;    reverse_x_walk_ani[ 12 ].w = 62;    reverse_x_walk_ani[ 12 ].h = 67;    reverse_x_walk_ani[ 13 ].x = 490;    reverse_x_walk_ani[ 13 ].y = 638;    reverse_x_walk_ani[ 13 ].w = 62;    reverse_x_walk_ani[ 13 ].h = 67;    reverse_x_walk_ani[ 14 ].x = 490;    reverse_x_walk_ani[ 14 ].y = 638;    reverse_x_walk_ani[ 14 ].w = 62;    reverse_x_walk_ani[ 14 ].h = 67;    reverse_x_walk_ani[ 15 ].x = 490;    reverse_x_walk_ani[ 15 ].y = 638;    reverse_x_walk_ani[ 15 ].w = 62;    reverse_x_walk_ani[ 15 ].h = 67;    reverse_x_walk_ani[ 16 ].x = 411;    reverse_x_walk_ani[ 16 ].y = 638;    reverse_x_walk_ani[ 16 ].w = 74;    reverse_x_walk_ani[ 16 ].h = 67;    reverse_x_walk_ani[ 17 ].x = 411;    reverse_x_walk_ani[ 17 ].y = 638;    reverse_x_walk_ani[ 17 ].w = 74;    reverse_x_walk_ani[ 17 ].h = 67;    reverse_x_walk_ani[ 18 ].x = 411;    reverse_x_walk_ani[ 18 ].y = 638;    reverse_x_walk_ani[ 18 ].w = 74;    reverse_x_walk_ani[ 18 ].h = 67;    reverse_x_walk_ani[ 19 ].x = 411;    reverse_x_walk_ani[ 19 ].y = 638;    reverse_x_walk_ani[ 19 ].w = 74;    reverse_x_walk_ani[ 19 ].h = 67;    reverse_x_walk_ani[ 20 ].x = 330;    reverse_x_walk_ani[ 20 ].y = 640;    reverse_x_walk_ani[ 20 ].w = 75;    reverse_x_walk_ani[ 20 ].h = 67;    reverse_x_walk_ani[ 21 ].x = 330;    reverse_x_walk_ani[ 21 ].y = 640;    reverse_x_walk_ani[ 21 ].w = 75;    reverse_x_walk_ani[ 21 ].h = 67;    reverse_x_walk_ani[ 22 ].x = 330;    reverse_x_walk_ani[ 22 ].y = 640;    reverse_x_walk_ani[ 22 ].w = 75;    reverse_x_walk_ani[ 22 ].h = 67;    reverse_x_walk_ani[ 23 ].x = 330;    reverse_x_walk_ani[ 23 ].y = 640;    reverse_x_walk_ani[ 23 ].w = 75;    reverse_x_walk_ani[ 23 ].h = 67;    reverse_x_walk_ani[ 24 ].x = 261;    reverse_x_walk_ani[ 24 ].y = 638;    reverse_x_walk_ani[ 24 ].w = 61;    reverse_x_walk_ani[ 24 ].h = 69;    reverse_x_walk_ani[ 25 ].x = 261;    reverse_x_walk_ani[ 25 ].y = 638;    reverse_x_walk_ani[ 25 ].w = 61;    reverse_x_walk_ani[ 25 ].h = 69;    reverse_x_walk_ani[ 26 ].x = 261;    reverse_x_walk_ani[ 26 ].y = 638;    reverse_x_walk_ani[ 26 ].w = 61;    reverse_x_walk_ani[ 26 ].h = 69;    reverse_x_walk_ani[ 27 ].x = 261;    reverse_x_walk_ani[ 27 ].y = 638;    reverse_x_walk_ani[ 27 ].w = 61;    reverse_x_walk_ani[ 27 ].h = 69;    reverse_x_walk_ani[ 28 ].x = 200;    reverse_x_walk_ani[ 28 ].y = 638;    reverse_x_walk_ani[ 28 ].w = 47;    reverse_x_walk_ani[ 28 ].h = 67;    reverse_x_walk_ani[ 29 ].x = 200;    reverse_x_walk_ani[ 29 ].y = 638;    reverse_x_walk_ani[ 29 ].w = 47;    reverse_x_walk_ani[ 29 ].h = 67;    reverse_x_walk_ani[ 30 ].x = 200;    reverse_x_walk_ani[ 30 ].y = 638;    reverse_x_walk_ani[ 30 ].w = 47;    reverse_x_walk_ani[ 30 ].h = 67;    reverse_x_walk_ani[ 31 ].x = 200;    reverse_x_walk_ani[ 31 ].y = 638;    reverse_x_walk_ani[ 31 ].w = 47;    reverse_x_walk_ani[ 31 ].h = 67;    reverse_x_walk_ani[ 32 ].x = 674;    reverse_x_walk_ani[ 32 ].y = 719;    reverse_x_walk_ani[ 32 ].w = 45;    reverse_x_walk_ani[ 32 ].h = 72;    reverse_x_walk_ani[ 33 ].x = 674;    reverse_x_walk_ani[ 33 ].y = 719;    reverse_x_walk_ani[ 33 ].w = 45;    reverse_x_walk_ani[ 33 ].h = 72;    reverse_x_walk_ani[ 34 ].x = 674;    reverse_x_walk_ani[ 34 ].y = 719;    reverse_x_walk_ani[ 34 ].w = 45;    reverse_x_walk_ani[ 34 ].h = 72;    reverse_x_walk_ani[ 35 ].x = 674;    reverse_x_walk_ani[ 35 ].y = 719;    reverse_x_walk_ani[ 35 ].w = 45;    reverse_x_walk_ani[ 35 ].h = 72;    reverse_x_walk_ani[ 36 ].x = 609;    reverse_x_walk_ani[ 36 ].y = 719;    reverse_x_walk_ani[ 36 ].w = 57;    reverse_x_walk_ani[ 36 ].h = 69;    reverse_x_walk_ani[ 37 ].x = 609;    reverse_x_walk_ani[ 37 ].y = 719;    reverse_x_walk_ani[ 37 ].w = 57;    reverse_x_walk_ani[ 37 ].h = 69;    reverse_x_walk_ani[ 38 ].x = 609;    reverse_x_walk_ani[ 38 ].y = 719;    reverse_x_walk_ani[ 38 ].w = 57;    reverse_x_walk_ani[ 38 ].h = 69;    reverse_x_walk_ani[ 39 ].x = 609;    reverse_x_walk_ani[ 39 ].y = 719;    reverse_x_walk_ani[ 39 ].w = 57;    reverse_x_walk_ani[ 39 ].h = 69;    reverse_x_walk_ani[ 40 ].x = 541;    reverse_x_walk_ani[ 40 ].y = 722;    reverse_x_walk_ani[ 40 ].w = 62;    reverse_x_walk_ani[ 40 ].h = 65;    reverse_x_walk_ani[ 41 ].x = 541;    reverse_x_walk_ani[ 41 ].y = 722;    reverse_x_walk_ani[ 41 ].w = 62;    reverse_x_walk_ani[ 41 ].h = 65;    reverse_x_walk_ani[ 42 ].x = 541;    reverse_x_walk_ani[ 42 ].y = 722;    reverse_x_walk_ani[ 42 ].w = 62;    reverse_x_walk_ani[ 42 ].h = 65;    reverse_x_walk_ani[ 43 ].x = 541;    reverse_x_walk_ani[ 43 ].y = 722;    reverse_x_walk_ani[ 43 ].w = 62;    reverse_x_walk_ani[ 43 ].h = 65;    reverse_x_walk_ani[ 44 ].x = 469;    reverse_x_walk_ani[ 44 ].y = 722;    reverse_x_walk_ani[ 44 ].w = 69;    reverse_x_walk_ani[ 44 ].h = 64;    reverse_x_walk_ani[ 45 ].x = 469;    reverse_x_walk_ani[ 45 ].y = 722;    reverse_x_walk_ani[ 45 ].w = 69;    reverse_x_walk_ani[ 45 ].h = 64;    reverse_x_walk_ani[ 46 ].x = 469;    reverse_x_walk_ani[ 46 ].y = 722;    reverse_x_walk_ani[ 46 ].w = 69;    reverse_x_walk_ani[ 46 ].h = 64;    reverse_x_walk_ani[ 47 ].x = 469;    reverse_x_walk_ani[ 47 ].y = 722;    reverse_x_walk_ani[ 47 ].w = 69;    reverse_x_walk_ani[ 47 ].h = 64;    reverse_x_walk_ani[ 48 ].x = 393;    reverse_x_walk_ani[ 48 ].y = 724;    reverse_x_walk_ani[ 48 ].w = 65;    reverse_x_walk_ani[ 48 ].h = 66;    reverse_x_walk_ani[ 49 ].x = 393;    reverse_x_walk_ani[ 49 ].y = 724;    reverse_x_walk_ani[ 49 ].w = 65;    reverse_x_walk_ani[ 49 ].h = 66;    reverse_x_walk_ani[ 50 ].x = 393;    reverse_x_walk_ani[ 50 ].y = 724;    reverse_x_walk_ani[ 50 ].w = 65;    reverse_x_walk_ani[ 50 ].h = 66;    reverse_x_walk_ani[ 51 ].x = 393;    reverse_x_walk_ani[ 51 ].y = 724;    reverse_x_walk_ani[ 51 ].w = 65;    reverse_x_walk_ani[ 51 ].h = 66;    reverse_x_walk_ani[ 52 ].x = 327;    reverse_x_walk_ani[ 52 ].y = 724;    reverse_x_walk_ani[ 52 ].w = 61;    reverse_x_walk_ani[ 52 ].h = 65;    reverse_x_walk_ani[ 53 ].x = 327;    reverse_x_walk_ani[ 53 ].y = 724;    reverse_x_walk_ani[ 53 ].w = 61;    reverse_x_walk_ani[ 53 ].h = 65;    reverse_x_walk_ani[ 54 ].x = 327;    reverse_x_walk_ani[ 54 ].y = 724;    reverse_x_walk_ani[ 54 ].w = 61;    reverse_x_walk_ani[ 54 ].h = 65;    reverse_x_walk_ani[ 55 ].x = 327;    reverse_x_walk_ani[ 55 ].y = 724;    reverse_x_walk_ani[ 55 ].w = 61;    reverse_x_walk_ani[ 55 ].h = 65;    reverse_x_walk_ani[ 56 ].x = 264;    reverse_x_walk_ani[ 56 ].y = 721;    reverse_x_walk_ani[ 56 ].w = 52;    reverse_x_walk_ani[ 56 ].h = 71;    reverse_x_walk_ani[ 57 ].x = 264;    reverse_x_walk_ani[ 57 ].y = 721;    reverse_x_walk_ani[ 57 ].w = 52;    reverse_x_walk_ani[ 57 ].h = 71;    reverse_x_walk_ani[ 58 ].x = 264;    reverse_x_walk_ani[ 58 ].y = 721;    reverse_x_walk_ani[ 58 ].w = 52;    reverse_x_walk_ani[ 58 ].h = 71;    reverse_x_walk_ani[ 59 ].x = 264;    reverse_x_walk_ani[ 59 ].y = 721;    reverse_x_walk_ani[ 59 ].w = 52;    reverse_x_walk_ani[ 59 ].h = 71;    reverse_x_walk_ani[ 60 ].x = 213;    reverse_x_walk_ani[ 60 ].y = 720;    reverse_x_walk_ani[ 60 ].w = 47;    reverse_x_walk_ani[ 60 ].h = 72;    reverse_x_walk_ani[ 61 ].x = 213;    reverse_x_walk_ani[ 61 ].y = 720;    reverse_x_walk_ani[ 61 ].w = 47;    reverse_x_walk_ani[ 61 ].h = 72;    reverse_x_walk_ani[ 62 ].x = 213;    reverse_x_walk_ani[ 62 ].y = 720;    reverse_x_walk_ani[ 62 ].w = 47;    reverse_x_walk_ani[ 62 ].h = 72;    reverse_x_walk_ani[ 63 ].x = 213;    reverse_x_walk_ani[ 63 ].y = 720;    reverse_x_walk_ani[ 63 ].w = 47;    reverse_x_walk_ani[ 63 ].h = 72;    // Reversed Dash    reverse_x_dash_ani[ 0 ].x = 700;    reverse_x_dash_ani[ 0 ].y = 807;    reverse_x_dash_ani[ 0 ].w = 53;    reverse_x_dash_ani[ 0 ].h = 65;    reverse_x_dash_ani[ 1 ].x = 621;    reverse_x_dash_ani[ 1 ].y = 818;    reverse_x_dash_ani[ 1 ].w = 72;    reverse_x_dash_ani[ 1 ].h = 55;    reverse_x_dash_ani[ 2 ].x = 531;    reverse_x_dash_ani[ 2 ].y = 825;    reverse_x_dash_ani[ 2 ].w = 83;    reverse_x_dash_ani[ 2 ].h = 50;    reverse_x_dash_ani[ 3 ].x = 531;    reverse_x_dash_ani[ 3 ].y = 825;    reverse_x_dash_ani[ 3 ].w = 83;    reverse_x_dash_ani[ 3 ].h = 50;    reverse_x_dash_ani[ 4 ].x = 531;    reverse_x_dash_ani[ 4 ].y = 825;    reverse_x_dash_ani[ 4 ].w = 83;    reverse_x_dash_ani[ 4 ].h = 50;    reverse_x_dash_ani[ 5 ].x = 441;    reverse_x_dash_ani[ 5 ].y = 825;    reverse_x_dash_ani[ 5 ].w = 86;    reverse_x_dash_ani[ 5 ].h = 50;    reverse_x_dash_ani[ 6 ].x = 441;    reverse_x_dash_ani[ 6 ].y = 825;    reverse_x_dash_ani[ 6 ].w = 86;    reverse_x_dash_ani[ 6 ].h = 50;    reverse_x_dash_ani[ 7 ].x = 441;    reverse_x_dash_ani[ 7 ].y = 825;    reverse_x_dash_ani[ 7 ].w = 86;    reverse_x_dash_ani[ 7 ].h = 50;    reverse_x_dash_ani[ 8 ].x = 375;    reverse_x_dash_ani[ 8 ].y = 808;    reverse_x_dash_ani[ 8 ].w = 58;    reverse_x_dash_ani[ 8 ].h = 65;    reverse_x_dash_ani[ 9 ].x = 320;    reverse_x_dash_ani[ 9 ].y = 806;    reverse_x_dash_ani[ 9 ].w = 48;    reverse_x_dash_ani[ 9 ].h = 67;    reverse_x_dash_ani[ 10 ].x = 248;    reverse_x_dash_ani[ 10 ].y = 809;    reverse_x_dash_ani[ 10 ].w = 62;    reverse_x_dash_ani[ 10 ].h = 65;    reverse_x_dash_ani[ 11 ].x = 188;    reverse_x_dash_ani[ 11 ].y = 808;    reverse_x_dash_ani[ 11 ].w = 54;    reverse_x_dash_ani[ 11 ].h = 66;    // Reverse Jump    reverse_x_jump_ani[ 0 ].x = 710;    reverse_x_jump_ani[ 0 ].y = 341;    reverse_x_jump_ani[ 0 ].w = 39;    reverse_x_jump_ani[ 0 ].h = 73;    reverse_x_jump_ani[ 1 ].x = 664;    reverse_x_jump_ani[ 1 ].y = 340;    reverse_x_jump_ani[ 1 ].w = 36;    reverse_x_jump_ani[ 1 ].h = 77;    reverse_x_jump_ani[ 2 ].x = 615;    reverse_x_jump_ani[ 2 ].y = 342;    reverse_x_jump_ani[ 2 ].w = 37;    reverse_x_jump_ani[ 2 ].h = 81;    reverse_x_jump_ani[ 3 ].x = 554;    reverse_x_jump_ani[ 3 ].y = 340;    reverse_x_jump_ani[ 3 ].w = 40;    reverse_x_jump_ani[ 3 ].h = 88;    reverse_x_jump_ani[ 4 ].x = 500;    reverse_x_jump_ani[ 4 ].y = 344;    reverse_x_jump_ani[ 4 ].w = 42;    reverse_x_jump_ani[ 4 ].h = 80;    reverse_x_jump_ani[ 5 ].x = 434;    reverse_x_jump_ani[ 5 ].y = 346;    reverse_x_jump_ani[ 5 ].w = 54;    reverse_x_jump_ani[ 5 ].h = 75;    reverse_x_jump_ani[ 6 ].x = 377;    reverse_x_jump_ani[ 6 ].y = 345;    reverse_x_jump_ani[ 6 ].w = 50;    reverse_x_jump_ani[ 6 ].h = 77;    reverse_x_jump_ani[ 7 ].x = 322;    reverse_x_jump_ani[ 7 ].y = 341;    reverse_x_jump_ani[ 7 ].w = 44;    reverse_x_jump_ani[ 7 ].h = 81;    reverse_x_jump_ani[ 8 ].x = 261;    reverse_x_jump_ani[ 8 ].y = 347;    reverse_x_jump_ani[ 8 ].w = 50;    reverse_x_jump_ani[ 8 ].h = 75;    reverse_x_jump_ani[ 9 ].x = 207;    reverse_x_jump_ani[ 9 ].y = 351;    reverse_x_jump_ani[ 9 ].w = 47;    reverse_x_jump_ani[ 9 ].h = 71;    reverse_x_jump_ani[ 10 ].x = 150;    reverse_x_jump_ani[ 10 ].y = 353;    reverse_x_jump_ani[ 10 ].w = 51;    reverse_x_jump_ani[ 10 ].h = 66;    // Falling    reverse_x_fall_ani[ 0 ].x  = 322;    reverse_x_fall_ani[ 0 ].y  = 342;    reverse_x_fall_ani[ 0 ].w  = 45;    reverse_x_fall_ani[ 0 ].h  = 82;}void clean_up(){    //Free the images    SDL_FreeSurface( background );    SDL_FreeSurface( no_armor_x );    SDL_FreeSurface( reverse_no_armor_x );    SDL_FreeSurface( charge_ani_one );    SDL_FreeSurface( screen );    /* Free Sounds    Mix_FreeMusic(music);    Mix_FreeChunk(blast);    // Close Audio Mixer    Mix_CloseAudio();    */    // Close the font    TTF_CloseFont(font);    // NULL all pointers    // Close Joystick    SDL_JoystickClose( joystick );    // Quit SDL_ttf    TTF_Quit();    //Quit SDL    SDL_Quit();}void loadStage(){    ground.x = 0;    ground.y = 300;    ground.w = 600;    ground.h = 500;}int main(int argc, char* args[]){    //Make sure that main waits for a quit    bool quit = false;    loadStage();    //Initialize    if( init() == false)    {   return 1;    }    //Load the files    if(load_files() == false)    {   return 1;    }    Timer fps;    setClips();    //While the user hasn't quit    while(1)    {   // Timer START   fps.start();   //While there's an event to handle   while( SDL_PollEvent( &event ) )   {  X.handle_events(); if(event.type == SDL_QUIT || event.key.keysym.sym == SDLK_ESCAPE) {//Quit the programclean_up();SDL_Quit();return 0; }   }   X.move();   // Fill the screen white   SDL_FillRect( screen, &screen->clip_rect, SDL_MapRGB( screen->format, 255, 255, 255 ) );   // Ground color   SDL_FillRect( screen, &ground, SDL_MapRGB( screen->format, 0x77, 0x77, 0x77 ) );   // Some sort of draw code needs to go here.   X.draw();   //Update Screen   if(SDL_Flip( screen ) == -1)   {  return 1;   }   // Cap the frame rate   if(fps.get_ticks() < 1000 / FRAMES_PER_SECOND );   {  SDL_Delay( (1000 / FRAMES_PER_SECOND) - fps.get_ticks() );   }    }    return 0;}
bool checkContactCollision(SDL_Rect* A, SDL_Rect B){    // The sides of the rectangles    int leftA, leftB;    int rightA, rightB;    int topA, topB;    int bottomA, bottomB;    // Calculate sides of A    leftA = A->x;    rightA = A->x + A->w;    topA = A->y;    bottomA = A->y + A->h;    // Calculate sides of B    leftB = B.x;    rightB = B.x + B.w;    topB = B.y;    bottomB = B.y + B.h;    // If any of the sides from A are outside of B    if(bottomA < topB)    {   return false;    }    if(rightA < leftB)    {   return false;    }    if(leftA > rightB)    {   return false;    }    if(bottomA == topB)    {   return true;    }}OK, I narrowed it down to this. Somehow this function is changing the frame variables when it gets called so when X walks and stuff, he doesn't get blitted to the screen properly. On top of that, the collisions don't get detected because the numbers are already higher than the ground variables, and I believe I may have done the above function incorrectly anyways.My interweb is back on, and even though no one decided to answer to this, I think I may just figure this one out on my own. Any suggestions for some proper collision detections would be great though.I want to make the game check each animation frame to see if the bottom of that frame is touching the ground. I thought I'd figured out how, but it's back to the drawing board.   ;  I did my best to chug through your code. It's a lot to look at, and I can't say that I found the exact problem...but one thing that I noticed is that you're confusing velocity and position.    if(checkContactCollision(&x_idle_ani[frame], ground) && (velocity >= 0 || velocity <= 0) && lastInput == MMX::IDLE_RIGHT)    {   x_idle_ani[frame].y = ground.y;    }If we're colliding, and I'm moving somewhere, continually lock my position to the ground (while leaving velocity intact).What SHOULD happen here is, check the collision, set your y to that of the ground (which you currently do) ASWELL as your y velocity. If you don't set the velocity to 0, you're prone to missing the collision check and falling through the world.   ;  Thank you for taking the time out to look though my code. I wasn't sure what the problem was so I just posted it all. I know that annoys the crap outta alot of people here but I was at my wits end.Also, I must have been so preoccupied with the animation glitches that I forgot about the vertical velocity. Thanks for pointing that out. I'll keep that in mind when I edit this program.   