Well, I don't have a "simple" demo of how to set it up, but look at
Snowball,
My Two Bits, or
Wing Blaster for some ideas.
I use a frame limiter/throttler to ensure that the timing is consistent across all platforms. I update as long as there's frames being missed and render when the engine's caught up.
Untested general code loop:
int i;
while(!game_done)
{
// Draw while we're caught up.
Render();
// [Drawing stuff here]
ShowPage();
FrameThrottle();
// For every frame we miss, update.
// Gap is the distance in time between the
// current frame and last one.
for(i = 0; i < frame_throttler.gap; i++)
{
UpdateControls();
// [Update stuff here]
}
}
To check if buttons/keys are pressed, it's pretty easy, and it's fairly well documented and discussed. Attaching the scancodes to your own 'custom' buttons is simple enough, but I don't quite think it'll let you use defines in defines, so the next best thing.
int PLAYER_KEY_GET = SCAN_G;
int PLAYER_KEY_LOOK = SCAN_L;
int PLAYER_KEY_TALK = SCAN_T;
int PLAYER_KEY_DROP = SCAN_D;
int PLAYER_KEY_SLEEP = SCAN_S;
int PLAYER_KEY_EQUIP = SCAN_E;
int PLAYER_KEY_USE = SCAN_U;
int PLAYER_KEY_ATTACK = SCAN_A;
int PLAYER_KEY_PARRY = SCAN_P;
int PLAYER_KEY_SNEAK = SCAN_S;
Then use key[SCANCODE] to check if it's pressed.
Oh, and a lot of resources on the Internet for random map generation and item placement are documented in C code. Most of these solutions work okay with a bit of prodding. Random maps are probably more annoying than actually populating your dungeon. Someone else would probably be better able to explain a good dungeon generation algorithm.