1 2 3 4 5 6 7 8 9 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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
#include <allegro.h>
int x = 10;
int y = 10;
int textboxy1 = 400;
int arrowspace = 7;
double keypress1;
double currentmsg;
int main()
{
allegro_init();
set_color_depth(32);
install_keyboard();
set_gfx_mode(GFX_AUTODETECT_WINDOWED, 1040, 680, 0, 0);
while ( !key[KEY_ESC]) {
clear_keybuf();
acquire_screen();
textout_ex(screen, font, "________________________________________________________________________________________________________________________________", 7, textboxy1, makecol(255, 255, 255), makecol(0, 0, 0));
textout_ex(screen, font, "Use the arrow keys to move and use space as the action button.", arrowspace, 410, makecol(255, 255, 255), makecol(0, 0, 0));
textout_ex(screen, font, "#", 40, 40, makecol(255, 255, 255), makecol(0, 0, 0));
textout_ex(screen, font, "#", 50, 40, makecol(255, 255, 255), makecol(0, 0, 0));
textout_ex(screen, font, "#", 60, 40, makecol(255, 255, 255), makecol(0, 0, 0));
textout_ex(screen, font, "#", 70, 40, makecol(255, 255, 255), makecol(0, 0, 0));
textout_ex(screen, font, "#", 80, 40, makecol(255, 255, 255), makecol(0, 0, 0));
textout_ex(screen, font, "#", 90, 40, makecol(255, 255, 255), makecol(0, 0, 0));
textout_ex(screen, font, "#", 100, 40, makecol(255, 255, 255), makecol(0, 0, 0));
textout_ex(screen, font, "#", 110, 40, makecol(255, 255, 255), makecol(0, 0, 0));
textout_ex(screen, font, "#", 120, 40, makecol(255, 255, 255), makecol(0, 0, 0));
textout_ex(screen, font, "#", 130, 40, makecol(255, 255, 255), makecol(0, 0, 0));
textout_ex(screen, font, "#", 140, 40, makecol(255, 255, 255), makecol(0, 0, 0));
textout_ex(screen, font, "#", 150, 40, makecol(255, 255, 255), makecol(0, 0, 0));
textout_ex(screen, font, "#", 160, 40, makecol(255, 255, 255), makecol(0, 0, 0));
textout_ex(screen, font, "#", 170, 40, makecol(255, 255, 255), makecol(0, 0, 0));
textout_ex(screen, font, "#", 40, 50, makecol(255, 255, 255), makecol(0, 0, 0));
textout_ex(screen, font, "#", 40, 60, makecol(255, 255, 255), makecol(0, 0, 0));
textout_ex(screen, font, "#", 40, 70, makecol(255, 255, 255), makecol(0, 0, 0));
textout_ex(screen, font, "#", 40, 80, makecol(255, 255, 255), makecol(0, 0, 0));
textout_ex(screen, font, "#", 40, 90, makecol(255, 255, 255), makecol(0, 0, 0));
textout_ex(screen, font, "#", 40, 100, makecol(255, 255, 255), makecol(0, 0, 0));
textout_ex(screen, font, "#", 40, 110, makecol(255, 255, 255), makecol(0, 0, 0));
textout_ex(screen, font, "#", 40, 120, makecol(255, 255, 255), makecol(0, 0, 0));
textout_ex(screen, font, "#", 40, 130, makecol(255, 255, 255), makecol(0, 0, 0));
textout_ex(screen, font, " ", 44, 132, makecol(0, 0, 0), makecol(0, 0, 0));
textout_ex(screen, font, "#", 120, 130, makecol(255, 255, 255), makecol(0, 0, 0));
textout_ex(screen, font, " ", 124, 135, makecol(0, 0, 0), makecol(0, 0, 0));
textout_ex(screen, font, " ", 114, 126, makecol(0, 0, 0), makecol(0, 0, 0));
textout_ex(screen, font, " ", x, y, makecol(0, 0, 0), makecol(0, 0, 0));
if (key[KEY_UP]) --y;
else if (key[KEY_DOWN]) ++y;
else if (key[KEY_LEFT]) --x;
else if (key[KEY_RIGHT]) ++x;
if (key[KEY_LEFT] && x == 1){ ++x;}
if (key[KEY_DOWN] && y == 399){ --y;}
if (key[KEY_UP] && y == 2){ ++y;}
if (key[KEY_RIGHT] && x == 1032){ --x;}
if (key[KEY_RIGHT] && y > 29 && y < 138 && x == 30){ --x;}
if (key[KEY_DOWN] && x > 30 && x < 180 && y == 30 ){ --y;}
if (key[KEY_UP] && x > 40 && x < 180 && y == 50){ ++y;}
if (key[KEY_LEFT] && y > 50 && y < 138 && x == 50){ ++x;}
if (key[KEY_LEFT] && y > 30 && y < 50 && x == 178) { ++x;}
if (key[KEY_UP] && x > 30 && x < 50 && y == 140) { ++y;}
if (key[KEY_LEFT] && y > 120 && y < 140 && x == 130){ ++x;}
if (key[KEY_DOWN] && x > 110 && x < 130 && y == 120){ --y;}
if (key[KEY_UP] && x > 110 && x < 130 && y == 140){ ++y;}
if (key[KEY_RIGHT] && y > 120 && y < 140 && x == 110){ --x;}
textout_ex(screen, font, "E", x, y, makecol(0, 0, 255), makecol(0, 0, 0));
release_screen();
rest(10);
}
return 0;
}
END_OF_MAIN();
|