本文整理汇总了C++中clear_keybuf函数的典型用法代码示例。如果您正苦于以下问题:C++ clear_keybuf函数的具体用法?C++ clear_keybuf怎么用?C++ clear_keybuf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了clear_keybuf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: gController_keyboard_thread
void gController_keyboard_thread(void *data)
{
int key_pressed;
clear_keybuf();
while((key_pressed = readkey())) {
key_pressed = key_pressed >> 8;
switch(key_pressed) {
/* Movement event. */
case KEY_UP:
case KEY_RIGHT:
case KEY_DOWN:
case KEY_LEFT:
gController_keyboard_move(key_pressed);
break;
case KEY_ESC:
gController_keyboard_misc(key_pressed);
break;
default:
error("No action registered to this key. Key %d", (key_pressed));
break;
}
clear_keybuf();
usleep(GCONTROLLER_KB_ACTION_INTERVAL_IN_USEC);
}
}
开发者ID:dendriel,项目名称:games,代码行数:32,代码来源:gController_keyboard.c
示例2: input_nodes
/* let the user input a list of path nodes */
void input_nodes(void)
{
clear_to_color(screen, makecol(255, 255, 255));
textout_centre_ex(screen, font, "Click the left mouse button to add path "
"nodes", SCREEN_W/2, 8, palette_color[255],
palette_color[0]);
textout_centre_ex(screen, font, "Right mouse button or any key to finish",
SCREEN_W/2, 24, palette_color[255], palette_color[0]);
node_count = 1;
show_mouse(screen);
do {
poll_mouse();
} while (mouse_b);
clear_keybuf();
for (;;) {
poll_mouse();
if (mouse_b & 1) {
if (node_count < MAX_NODES-1) {
nodes[node_count].x = mouse_x;
nodes[node_count].y = mouse_y;
show_mouse(NULL);
draw_node(node_count);
show_mouse(screen);
node_count++;
}
do {
poll_mouse();
} while (mouse_b & 1);
}
if ((mouse_b & 2) || (keypressed())) {
if (node_count < 3)
alert("You must enter at least two nodes",
NULL, NULL, "OK", NULL, 13, 0);
else
break;
}
}
show_mouse(NULL);
do {
poll_mouse();
} while (mouse_b);
clear_keybuf();
}
开发者ID:AntonLanghoff,项目名称:whitecatlib,代码行数:58,代码来源:exspline.c
示例3: end_game
/*
There was going to be a nice fadeout effect using the allegro fade_out and
fade_in functions, but for some reason these screwed up the palette. Oh well.
*/
void end_game(int fade_speed)
{
// fade_out(fade_speed);
rest(1000 / fade_speed);
clear_keybuf();
clear_bitmap(screen);
// set_palette(palet);
init_palette();
set_palette(palet);
int challenge_winner = 0;
if (arena[0].teams == 0)
challenge_winner = score_table();
else
challenge_winner = score_table_team();
if (arena[0].challenge_level != 0)
{
if (challenge_winner == 0)
{
switch(arena[0].challenge_level)
{
case 1: information_box("", "Norbert won?", "Hmm.", 0); break;
case 2: information_box("", "Looks like you need some more practice.", "", 0); break;
case 3: information_box("", "Sorry, you lose.", "", 0); break;
case 4: information_box("", "Good, but not great.", "", 0); break;
case 5: information_box("", "Oh well, better luck next time.", "", 0); break;
case 6: information_box("", "Almost there. Try again.", "", 0); break;
case 7: information_box("", "Very good, but not quite good enough.", "", 0); break;
}
end_challenge();
}
}
if (arena[0].qstart != QSTART_NONE)
end_qstart();
//shutdown_network();
// fade_in(*palet, fade_speed);
// set_palette(*palet);
do
{
} while (keypressed() == 0);
clear_keybuf();
//net_init();
}
开发者ID:flags,项目名称:CaptPorksRevenge,代码行数:60,代码来源:score.c
示例4: showAssignment
void showAssignment()
{
BITMAP *background = makeBitmap("Menu_Images/Instructions0.gif");
draw_sprite(menuBuffer, background, 0, 0);
blit(menuBuffer, screen, 0,0,0,0,1024,768);
clear_keybuf();
readkey();
background = makeBitmap("Menu_Images/Instructions1.gif");
draw_sprite(menuBuffer, background, 0, 0);
blit(menuBuffer, screen, 0,0,0,0,1024,768);
clear_keybuf();
readkey();
}
开发者ID:ChrisCooper,项目名称:SPQR,代码行数:14,代码来源:main.c
示例5: term_reinit
void term_reinit(int wait) /* fixup after running other progs */
{
struct text_info dat;
gppconio_init();
gettextinfo(&dat);
if (dat.screenheight != screen_h) {
_set_screen_lines(screen_h);
gettextinfo(&dat);
screen_h = dat.screenheight;
screen_w = dat.screenwidth;
mouse_init();
}
set_bright_backgrounds();
if (wait) {
clear_keybuf();
gch();
}
__djgpp_set_ctrl_c(0);
setcbrk(0);
}
开发者ID:OrangeTide,项目名称:fed,代码行数:25,代码来源:iodjgpp.c
示例6: DrawOptions
int NinmanGameGraph::DrawGameOptions() {
int y = 220;
DrawOptions(y);
while (true) {
clear_keybuf();
readkey();
if (key[KEY_DOWN]) {
y = y + 55;
{
if (y > 330)
y = 220;
}
}
if (key[KEY_UP]) {
y = y - 55;
{
if (y < 220)
y = 330;
}
}
if (key[KEY_ENTER]) {
return y;
}
DrawOptions(y);
}
}
开发者ID:guitcastro,项目名称:Ninman,代码行数:27,代码来源:NinmanGameGraph.cpp
示例7: cin_num
int cin_num(char *lab, int x, int y, int col)
{
clear_keybuf();
char *st_edit = new char[101];
st_edit[100] = char(NULL);
char null_char = char(NULL);
st_edit[0] = null_char;
int st_pos = 0;
while(!key[KEY_ENTER])
{
rectfill(screen,x,y,screen->w-1,y+10,BLACK);
textprintf(screen,font,x,y,col,lab); textprintf(screen,font,x+text_length(font,lab),y,col,st_edit);
st_edit[st_pos] = readkey() % 256;
st_edit[st_pos+1] = null_char;
if(!key[KEY_BACKSPACE]) st_pos++;
else if(st_pos) {st_pos--; st_edit[st_pos] = null_char;}
int char_num = int(st_edit[st_pos-1]);
if((char_num < 48 || char_num > 57) && st_pos){st_pos--;st_edit[st_pos] = null_char;}
}
int ret_num = 0;
for(int snum = 0; snum < st_pos; snum++)
ret_num += int((int(st_edit[snum])-48) * pow(10,st_pos-snum-1));
return ret_num;
}
开发者ID:awhipple,项目名称:3DEngine,代码行数:25,代码来源:aaron.cpp
示例8: selecionarItemTeclado
int selecionarItemTeclado(OPCOES *menu, int *selected, int *keyCount)
{
clear_keybuf();
if (key[KEY_UP] && *keyCount == 0 && *selected != 0)
{
*keyCount += 1;
*selected -= 1;
}
if (key[KEY_DOWN] && *keyCount == 0 && *selected < NUM_ITENS-1)
{
*keyCount += 1;
*selected += 1;
}
if (!key[KEY_UP] && !key[KEY_DOWN])
*keyCount = 0;
if (key[KEY_ENTER])
{
return menu->itens[*selected].code;
}
return -1;
}
开发者ID:flaviocdc,项目名称:asteroids-comp1,代码行数:25,代码来源:menu.c
示例9: main
int main ()
{
// initialize Allegro
if (allegro_init () < 0)
{
allegro_message ("Error: Could not initialize Allegro");
return -1;
}
// initialize gfx mode
if (set_gfx_mode (GFX_AUTODETECT, 320, 200, 0, 0) < 0)
{
allegro_message ("Error: Could not set graphics mode");
return -1;
}
// initialize keyboard
install_keyboard ();
clear_keybuf ();
// call the example function
test_mode_7 ();
// exit Allegro
allegro_exit ();
return 0;
} END_OF_MAIN ();
开发者ID:makhtardiouf,项目名称:C_Cpp,代码行数:27,代码来源:circ12.c
示例10: create_bitmap
//the final score screen
void CGame::ShowResults() {
int i;
int finalscore;
WINDOWS_BITMAP *text;
text = create_bitmap(220, 130);
clear_to_color(text,makecol(255,0,255));
scare_mouse();
//background image
blit((WINDOWS_BITMAP *)data[ZSCORE_BMP].dat, background,0,0,0,0,SCREEN_W,SCREEN_H);
//print text on temp image and resize
text_mode(-1);
for (i=0;i<numplayers;i++) {
finalscore = players[i].CalcFinalScore();
textprintf_centre(text,font,110,(i*40),players[i].color,"%d - %s",finalscore,players[i].name);
}
masked_stretch_blit(text,background,0,0,220,130,210,190,390,250);
blit(background,screen,0,0,0,0,SCREEN_W,SCREEN_H);
clear_keybuf();
readkey();
destroy_bitmap(text);
}
开发者ID:Josh-Stewart,项目名称:Scarbble,代码行数:35,代码来源:game.cpp
示例11: interfac_user_handler
// ==========================================================================
// MAIN loop
void interfac_user_handler(int start_ds1_idx)
{
//int ds1_idx;
//
int done, cx, cy;
int old_mouse_x = mouse_x, old_mouse_y=mouse_y, old_mouse_b=0;
int cur_mouse_z = 0, old_mouse_z = 0;
int ticks_elapsed;
// init
ds1_idx = start_ds1_idx;
done = FALSE;
// main loop
clear_keybuf();
while (! done) {
my_set_fps();
old_mouse_x = mouse_x;
old_mouse_y = mouse_y;
old_mouse_b = mouse_b;
cur_mouse_z = mouse_z;
mouse_to_tile(ds1_idx, &cx, &cy);
if (cx < 0) { cx = 0; } else if (cx >= glb_ds1.width) { cx = glb_ds1.width - 1; }
if (cy < 0) { cy = 0; } else if (cy >= glb_ds1.height) { cy = glb_ds1.height - 1; }
// check if need to redraw the screen because of floor animation
ticks_elapsed = glb_ds1edit.ticks_elapsed;
if ( ticks_elapsed && (glb_ds1.animations_layer_mask == 1)) {
// animated floor rate = 10 fps
// therefore it's at 2/5 of 25 fps
// but internal unit is in 5th
glb_ds1.cur_anim_floor_frame += ticks_elapsed * 2;
} else {
glb_ds1edit.ticks_elapsed = 0;
}
// redraw the whole screen
wpreview_draw_tiles(ds1_idx);
glb_ds1edit.fps++;
done = process_input();
}
}
开发者ID:gitustc,项目名称:d2imdev,代码行数:60,代码来源:interfac.c
示例12: textgfx_init
void textgfx_init()
{
#ifdef UNIX
strcpy(_xwin.application_name, "vitetris");
strcpy(_xwin.application_class, "Vitetris");
#endif
if (install_allegro(SYSTEM_AUTODETECT, &errno, NULL) != 0)
exit(1);
#ifdef UNIX
sigaction(SIGINT, NULL, &allegro_sigint_handler);
signal(SIGINT, sigint_handler);
#endif
load_pc8x16_font();
set_window_title(VITETRIS_VER);
set_close_button_callback(close_btn);
#ifndef UNIX
/* Seems to cause seg fault later quite randomly on Linux */
int depth = desktop_color_depth();
if (depth != 0)
set_color_depth(depth);
#endif
virt_screen = set_screen(getopt_int("", "fullscreen"));
lang |= LATIN1;
if (!font8x16) {
font8x16 = font;
textgfx_flags |= ASCII;
}
setattr_normal();
#if WIN32 && !ALLEGRO_USE_CONSOLE
if (exists("stdout.tmp")) {
FILE *fp;
freopen("stdout2.tmp", "w", stdout);
fp = fopen("stdout.tmp", "r");
if (fp) {
char line[80];
int i;
for (i=0; i < 25 && fgets(line, 80, fp); i++) {
setcurs(0, i);
i += printline(line);
}
fclose(fp);
if (i) {
refreshscreen();
if (!strncmp(line, "Press ", 6)) {
install_keyboard();
clear_keybuf();
readkey();
remove_keyboard();
}
}
}
freopen("stdout.tmp", "w", stdout);
delete_file("stdout2.tmp");
}
#endif
}
开发者ID:gsrr,项目名称:Python,代码行数:56,代码来源:allegro.c
示例13: setup_all_keys
/* handle the setup command */
static void setup_all_keys(void)
{
int focus = 2;
int i;
/* Prepare dialog. */
set_dialog_color(keymap_dialog, black, white);
centre_dialog(keymap_dialog);
/* Parse input. */
while (1) {
focus = do_dialog(keymap_dialog, focus);
switch (focus) {
case 2:
case 4:
textprintf_centre_ex (screen, font,
keymap_dialog[7].x, keymap_dialog[7].y, red, -1,
"Press a key to map to the current scancode");
textprintf_centre_ex (screen, font,
keymap_dialog[7].x, keymap_dialog[7].y + 8, red, -1,
"(or a mouse button to leave it unchanged)");
/* Wait for new key press. */
new_keycode = -1;
waiting_for_key = 1;
do {
poll_keyboard();
poll_mouse();
if (mouse_b)
waiting_for_key = 0;
}
while (waiting_for_key);
/* Save keycode to scancode mapping. */
if ((new_keycode >= 0) && (new_keycode < 256)) {
keycode_to_scancode[new_keycode] = keymap_dialog[2].d1 + 1;
}
clear_keybuf();
break;
case 5:
return;
case 6:
for (i = 0; i < 256; i++) {
if (keycode_to_scancode[i] >= 0)
_xwin.keycode_to_scancode[i] = keycode_to_scancode[i];
}
return;
}
}
}
开发者ID:sesc4mt,项目名称:mvcdecoder,代码行数:56,代码来源:xkeymap.c
示例14: descarregar
/***
* Cleanup and unloading
*/
void descarregar() {
clear_keybuf();
destroy_bitmap(fundo);
destroy_bitmap(bomba);
destroy_bitmap(coracao);
for(int i =0;i<framesPersonagem;i++)
{
delete personagem[i];
}
delete[] personagem;
}
开发者ID:juliopescuite,项目名称:projects,代码行数:15,代码来源:main.cpp
示例15: view_fli
/* handles double-clicking on a FLIC object in the grabber */
static int view_fli(DATAFILE *dat)
{
show_mouse(NULL);
clear_to_color(screen, gui_mg_color);
play_memory_fli(dat->dat, screen, TRUE, fli_stopper);
do {
} while (mouse_b);
clear_keybuf();
set_pallete(datedit_current_palette);
show_mouse(screen);
return D_REDRAW;
}
开发者ID:ifilex,项目名称:SRC,代码行数:13,代码来源:datfli.c
示例16: exit_sequence
void exit_sequence(Game* game){
//check exit keypress
if(key[KEY_ESC] || key[KEY_Q]){
fprintf(fpLog, "Game paused.\n");
stop_sample(game->bgMusic);
//ensure exit
textprintf_ex(screen, font, 5, 5,
makecol(255, 255, 255), -1,
"Press Q again to quit.");
clear_keybuf();
if(readkey() >> 8 == KEY_Q){
game->running = false;
}else{
开发者ID:PatzHum,项目名称:rpg,代码行数:13,代码来源:utils.c
示例17: input_char
KEYPRESS input_char()
{
KEYPRESS c;
/* all keyboard input should come through this function instead of
calling gch() directly. This function normally just calls getc(),
but will insert codes from the macro buffer instead if a macro is
being executed */
if (macro_mode == MACRO_FINISHED)
macro_mode = 0;
#if (defined TARGET_CURSES) || (defined TARGET_WIN)
if (macro_mode)
nosleep = TRUE;
else
nosleep = FALSE;
#endif
if (macro_mode == MACRO_PLAY) {
c = macro[macro_pos++];
if (macro_pos >= macro_size)
macro_mode = MACRO_FINISHED;
}
else {
if (unget_count > 0) {
int l;
c.key = _unget[0];
c.flags = 0;
unget_count--;
for (l=0; l<unget_count; l++)
_unget[l] = _unget[l+1];
}
else {
c.key = gch();
c.flags = modifiers();
}
}
if (macro_mode == MACRO_RECORD) {
if (macro_size >= MACRO_LENGTH) {
macro_mode = 0;
clear_keybuf();
alert_box("Macro too long");
}
else
macro[macro_size++] = c;
}
return c;
}
开发者ID:OrangeTide,项目名称:fed,代码行数:51,代码来源:util.c
示例18: deinicia_allegro
//---------------------------------------------------------------------
void deinicia_allegro() {
clear_keybuf();
//salvando o arquivo de configuracao
set_config_int("Inicializacao", "volume", volume);
set_config_int("Inicializacao", "vsync", vSync);
//fechando o allegro
if (get_update_method())
{
shutdown_screen_updating();
}
allegro_exit();
exit(0);
/* adicione outras deiniciacoes aqui */
}
开发者ID:ArthurAssuncao,项目名称:HaxGames,代码行数:15,代码来源:allegro_iniciacao.cpp
示例19: startNew
void startNew()
{
clear_keybuf();
readkey();
clear_to_color( buffer, makecol( 0, 0, 0));
ball_x = 320;
ball_y = 240;
p1_x = 20;
p1_y = 210;
p2_x = 620;
p2_y = 210;
}
开发者ID:sanchit234,项目名称:GamePack,代码行数:14,代码来源:ping_pong.c
示例20: GameInit
void GameInit(void)
{
allegro_init();
install_keyboard();
install_timer();
install_mouse();
clear_keybuf();
set_gfx_mode(GFX_AUTODETECT, 320, 240, 0, 0);
set_pallete(desktop_pallete);
return;
}
开发者ID:Shaduck,项目名称:OldGame01,代码行数:14,代码来源:NwLvlMak.cpp
注:本文中的clear_keybuf函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论