Skip to content

Instantly share code, notes, and snippets.

@RichardMarks
Created September 26, 2012 07:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RichardMarks/3786505 to your computer and use it in GitHub Desktop.
Save RichardMarks/3786505 to your computer and use it in GitHub Desktop.
EasyInput example
// Step #1 - Install Allegro 4.2.2 as specified here
// http://ccpssolutions.com/nogdusforums/index.php?topic=689.0
// Step #2 - Add these two files to your project
// http://storage.ccpssolutions.com/richard/easyinput/class_easy_input.h
// http://storage.ccpssolutions.com/richard/easyinput/class_easy_input.cpp
// Step #3 - Use this example source as a "guide" for using the EasyInput class.
// Any questions, please email ccpsceo@gmail.com with "EasyInput" in the subject line.
#include <allegro.h>
#pragma comment(lib, "alleg.lib")
#include "class_easy_input.h"
int main(int argc, char* argv[])
{
allegro_init();
install_timer();
install_keyboard();
set_color_depth(32);
set_gfx_mode(GFX_AUTODETECT_WINDOWED, 800, 600, 0, 0);
BITMAP* backBuffer = create_bitmap(SCREEN_W, SCREEN_H);
const int WHITE = makecol(255, 255, 255);
EasyInput entry("What is your name?");
struct Player{
char* name;
} myplayer;
std::string playername = entry.get();
myplayer.name = (char*)playername.c_str();
while(!key[KEY_ESC])
{
clear_bitmap(backBuffer);
textprintf_ex(backBuffer, font, 8, 32, WHITE, -1, "Name entered: %s", myplayer.name);
textprintf_ex(backBuffer, font, 8, 64, WHITE, -1, "Press ESC to end demo");
blit(backBuffer, screen, 0, 0, 0, 0, backBuffer->w, backBuffer->h);
rest(1);
}
destroy_bitmap(backBuffer);
return 0;
}
END_OF_MAIN()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment