- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
//
if (delay == 0)
{
Uint8 *keys = SDL_GetKeyState(NULL);
// Checking for letters
for (c = 97; c < 123; c++)
if (cpos < 9)
if (keys[c] && !delay)
{
mapname[cpos] = c;
mapname[++cpos] = '\0';
delay = 5;
bg.show(400, 240, 0);
text.print(mapname, 200, 180);
render.backend();
break;
}
// Checking for numbers
for (c = 48; c < 58; c++)
if (cpos < 9)
if (keys[c] && !delay)
{
mapname[cpos] = c;
mapname[++cpos] = '\0';
delay = 5;
bg.show(400, 240, 0);
text.print(mapname, 200, 180);
render.backend();
break;
}
// On pressing ENTER
if (keys[13] && !delay && strlen(mapname) > 2)
break;
// On pressing BACKSPACE
if (keys[SDLK_BACKSPACE] && cpos > 0 && !delay)
{
mapname[--cpos] = '\0';
delay = 5;
bg.show(400, 240, 0);
if (cpos > 0) text.print(mapname, 200, 180);
render.backend();
}
}
if (delay > 0)
delay--;