All right, I've made these slight changes and the sprite moves now, but it will only move down, and it will not move more than once. The message "You Cannot Move Here" also appears. This isn't supposed to happen unless the player is at the edge of the screen and tries to move in the direction of the edge. Here is the altered code:
if (SDLK_UP)
{
if (PlayerLocationy == 0)
{
Message = DeniedMessage;
ApplySurface((ScreenWidth - Message->w)/2,(ScreenHeight - Message->h + 420)/2,Message,Screen,NULL);
Message = NULL;
}
else
{
PlayerLocationy = PlayerLocationy - 42;
ApplySurface(0,421,Sprites,Screen,&TextBox);
}
}
if (SDLK_DOWN)
{
if (PlayerLocationy == 378)
{
Message = DeniedMessage;
ApplySurface((ScreenWidth - Message->w)/2,(ScreenHeight - Message->h + 420)/2,Message,Screen,NULL);
Message = NULL;
}
else
{
PlayerLocationy = PlayerLocationy + 42;
ApplySurface(0,421,Sprites,Screen,&TextBox);
break;
}
}
if (SDLK_LEFT)
{
if (PlayerLocationx == 0)
{
Message = DeniedMessage;
ApplySurface((ScreenWidth - Message->w)/2,(ScreenHeight - Message->h + 420)/2,Message,Screen,NULL);
Message = NULL;
}
else
{
PlayerLocationx = PlayerLocationx - 42;
ApplySurface(0,421,Sprites,Screen,&TextBox);
}
}
if (SDLK_RIGHT)
{
if (PlayerLocationx == 378)
{
Message = DeniedMessage;
ApplySurface((ScreenWidth - Message->w)/2,(ScreenHeight - Message->h + 420)/2,Message,Screen,NULL);
Message = NULL;
}
else
{
PlayerLocationx = PlayerLocationx + 42;
ApplySurface(0,421,Sprites,Screen,&TextBox);
}
}
if (SDLK_ESCAPE)
{
Message = EscapeMessage;
ApplySurface((ScreenWidth - Message->w)/2,(ScreenHeight - Message->h + 420)/2,Message,Screen,NULL);
if (SDL_KEYDOWN == SDLK_y)
{
QUIT = true;
}
}
I noticed that Khatharr had said something about not repeating the same functions, but I don't know how to do that quite yet.