const int MOVE_DIST = 42;
const int BOUNDARY_MIN = 0;
const int BOUNDARY_MAX = 378;
//Handle movement (see other people's comments about testing against SDLK_ constants)
if(SDLK_UP) {PlayerLocationy -= MOVE_DIST;}
if(SDLK_DOWN) {PlayerLocationy += MOVE_DIST;}
if(SDLK_LEFT) {PlayerLocationx -= MOVE_DIST;}
if(SDLK_RIGHT) {PlayerLocationx += MOVE_DIST;}
//Correct out-of-bounds condition
Message = NULL;
if(PlayerLocationy < BOUNDARY_MIN) {
Message = DeniedMessage;
PlayerLocationy = BOUNDARY_MIN;
}
if(PlayerLocationy > BOUNDARY_MAX) {
Message = DeniedMessage;
PlayerLocationy = BOUNDARY_MAX;
}
if(PlayerLocationx < BOUNDARY_MIN) {
Message = DeniedMessage;
PlayerLocationx = BOUNDARY_MIN;
}
if(PlayerLocationy > BOUNDARY_MAX) {
Message = DeniedMessage;
PlayerLocationx = BOUNDARY_MAX;
}
//Render
if(Message != NULL) {
int mess_x = (ScreenWidth - Message->w) / 2;
//This next line is not clear. Get rid of the magic number and clarify order of operations
int mess_y = (ScreenHeight - Message->h + 420) / 2;
ApplySurface(mess_x,mess_y,Message,Screen,NULL);
Message = NULL;
}
else {
ApplySurface(0,421,Sprites,Screen,&TextBox);
}
The key here is that the things you're likely to change are easy to change and it's clear what's going on. You can change the constants at the top or the render stuff at the bottom and not have to worry about changing it all 4 times. The organization and alignment of the first set of tests also makes it easier to spot if there's any errors lurking there, such as having PlayerLocationy where there should be a PlayerLocationx, or a - where there should be a +.

Find content
Not Telling