deadlychicken22
Man is a reasoning rather than a reasonable animal
I have just started learning SDL and am having a little trouble...
I followed the tutorial from HERE but when I test it out (on my gp2x) the square doesn't move at all when I press the direction stick.....
Here is my code:
	
	
	
		
And here are the pictures needed:
bg.bmp

image.bmp

Could someone please tell me what is wrong? I'm sure it's just something stupid....
				
			I followed the tutorial from HERE but when I test it out (on my gp2x) the square doesn't move at all when I press the direction stick.....
Here is my code:
		Code:
	
	#include <stdio.h>
#include <stdlib.h>
#include <SDL/SDL.h>
//define gp2x buttons
#define GP2X_BUTTON_UP              (0)
#define GP2X_BUTTON_DOWN            (4)
#define GP2X_BUTTON_LEFT            (2)
#define GP2X_BUTTON_RIGHT           (6)
#define GP2X_BUTTON_UPLEFT          (1)
#define GP2X_BUTTON_UPRIGHT         (7)
#define GP2X_BUTTON_DOWNLEFT        (3)
#define GP2X_BUTTON_DOWNRIGHT       (5)
#define GP2X_BUTTON_CLICK           (18)
#define GP2X_BUTTON_A               (12)
#define GP2X_BUTTON_B               (13)
#define GP2X_BUTTON_X               (14)
#define GP2X_BUTTON_Y               (15)
#define GP2X_BUTTON_L               (10)
#define GP2X_BUTTON_R               (11)
#define GP2X_BUTTON_START           (8)
#define GP2X_BUTTON_SELECT          (9)
#define GP2X_BUTTON_VOLUP           (16)
#define GP2X_BUTTON_VOLDOWN         (17)
SDL_Surface *back;
SDL_Surface *image;
SDL_Surface *screen;
int xpos=0, ypos=0;
int InitImages()
{
    back = SDL_LoadBMP("bg.bmp");
    image = SDL_LoadBMP("image.bmp");
    return 0;
}
void DrawIMG(SDL_Surface *img, int x, int y)
{
  SDL_Rect dest;
  dest.x = x;
  dest.y = y;
  SDL_BlitSurface(img, NULL, screen, &dest);
}
void DrawIMG(SDL_Surface *img, int x, int y,int w, int h, int x2, int y2)
{
  SDL_Rect dest;
  dest.x = x;
  dest.y = y;
  SDL_Rect dest2;
  dest2.x = x2;
  dest2.y = y2;
  dest2.w = w;
  dest2.h = h;
  SDL_BlitSurface(img, &dest2, screen, &dest);
}
void DrawBG()
{
  DrawIMG(back, 0, 0);
}
void DrawScene()
{
  DrawIMG(back, xpos-2, ypos-2, 132, 132, xpos-2, ypos-2);
  DrawIMG(image, xpos, ypos);
  SDL_Flip(screen);
}
int main()
{
    if (SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO)<0)
    {
     printf("Unable to initialize sdl: %s\n", SDL_GetError());
     exit(1);
     }
    atexit(SDL_Quit);
    
    screen=SDL_SetVideoMode(320, 240, 16, SDL_SWSURFACE);
    if (screen==NULL)
    {
     printf("Unable to set 640x480 video: %s\n", SDL_GetError());
     exit(1);
     }
    InitImages();
    DrawBG();
    
    int done=0;
    
    while(done==0)
    {
                  SDL_Event event;
                  
                  while(SDL_PollEvent(&event))
                  {
                   if (event.type==GP2X_BUTTON_UP) ypos -= 1;
                   if (event.type==GP2X_BUTTON_DOWN) ypos += 1; 
                   if (event.type==GP2X_BUTTON_LEFT) xpos -= 1; 
                   if (event.type==GP2X_BUTTON_RIGHT) xpos += 1; 
                   }
                  DrawScene();
    }
    return 0;
}
	And here are the pictures needed:
bg.bmp

image.bmp

Could someone please tell me what is wrong? I'm sure it's just something stupid....
	