[SDL] nooby question:how to get mappy to scroll

twoeyedhuman1111 at gmail.com twoeyedhuman1111 at gmail.com
Wed Jun 8 18:56:14 PDT 2005


Okay, I have been working on this piece of code for the past day or so, and 
it STILL WON'T SCROLL!!!!!!!!!!!!!!!!!!!!!!!!!!!!11
I am r3 at lly annoyed. Does anyone know why when I press the up down, left, 
and right keys, my map doesn't scroll?

#include <sdl/sdl.h>
#include <SDLMappy.h>
#include <windows.h>

#define COMPLAINANDEXIT(x) { MessageBox(NULL, x ,"Error",MB_OK); exit(1); }

SDLMappy * map = 0;
SDL_Surface * screen = 0;
Uint8 * keys;
int x = 0;
int y = 0;

SDL_Event event;

int main(int argc, char * argv[])
{
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) 
COMPLAINANDEXIT("Couldn't initialize SDL!");

atexit(SDL_Quit);

screen = SDL_SetVideoMode(640,480, 24, SDL_SWSURFACE);

if (screen == NULL)
COMPLAINANDEXIT("Could not make screen");
map = new SDLMappy();

if (map->LoadMap("mymap.fmp", 0, 0, 400, 400) < 0)
COMPLAINANDEXIT("Couldn't load mymap.fmp");

int done = 0;

while(done == 0)
{
SDL_PollEvent(&event);
keys = SDL_GetKeyState(NULL);
if (keys[SDLK_UP]) y-=1;
if (keys[SDLK_DOWN]) y+=1;
if (keys[SDLK_LEFT]) x-=1;
if (keys[SDLK_RIGHT]) x+=1;
if ( event.type == SDL_QUIT ) { done = 1;; }
if ( event.type == SDL_KEYDOWN )
{ 
if ( event.key.keysym.sym == SDLK_ESCAPE )
{ 
done = 1; 
} 
}

map->MapMoveTo(x,y);
map->MapChangeLayer(0);
map->MapDrawBGT(screen);
map->MapMoveTo(x,y);
SDL_Flip(screen);
}
return 0;
}


-- 
[img]http://www.aerojockey.com/fark/clippy.jpg[/img]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20050608/8be647e2/attachment.htm>


More information about the SDL mailing list