void loop(char campo[V][H], int tam) { int muerto = 0; int tecla = 0; do { draw(campo); input(campo, &tam, &muerto); // comprobar la tecla que se pulsa if(muerto == 0) { if(keypressed()) { tecla = readkey() >> 8; if(tecla == KEY_DOWN && snake[0].ModY != -1) { snake[0].ModX = 0; snake[0].ModY = 1; } if(tecla == KEY_UP && snake[0].ModY != 1) { snake[0].ModX = 0; snake[0].ModY = -1; } if(tecla == KEY_LEFT && snake[0].ModX != 1) { snake[0].ModX = -1; snake[0].ModY = 0; } if(tecla == KEY_RIGHT && snake[0].ModX != -1) { snake[0].ModX = 1; snake[0].ModY = 0; } } } else { allegro_message("GAME OVER"); } update(campo, tam); if(PAUSA == 50) rest(50); else rest(PAUSA); } while (muerto == 0 && tecla != KEY_ESC);
void cmd_viewtex(){ // Views a texture (made up of patches). WAD_TEX *temp_tex; // Try to load up and then display the texture. temp_tex=wad_loadpatch(parse_words[1]); if(temp_tex!=NULL){ // Display texture statistics. sprintf(saybuf,"width %d, height %d",temp_tex->w,temp_tex->h); con_printf(saybuf); // Dump the texture to the screen. clear_to_color(vgabuf,0); draw_tex(temp_tex); vsync(); blit(vgabuf,screen,0,0,0,0,screen_width,screen_height); readkey(); wad_killpatch(temp_tex); } else{ con_printf("viewtex failed"); } }
static u16 kbd_hwi(dcpu *dcpu) { switch (dcpu->reg[REG_A]) { case 0: // clear kbd buf. of course the terminal could still have stuff buffered. term.keybufwrite = 0; term.keybufread = 0; break; case 1: readkey(dcpu); break; case 2: // check if key is currently pressed. curses keypresses are // effectively instantaneous, so the answer is always 'no'. dcpu->reg[REG_C] = 0; break; case 3: term.kbdints = dcpu->reg[REG_B]; break; default: dcpu_msg("warning: unknown keyboard HWI: 0x%04x\n", dcpu->reg[REG_A]); } return 0; // no extra cycles }
int main() { allegro_init(); install_keyboard(); set_color_depth( 32 ); set_gfx_mode( GFX_AUTODETECT_WINDOWED, 800, 600, 0, 0 ); clear_to_color( screen, makecol( 128, 128, 128 ) ); BITMAP * ludek = NULL; ludek = load_bmp( "Ok.bmp", default_palette ); if( !ludek ) { set_gfx_mode( GFX_TEXT, 0, 0, 0, 0 ); allegro_message( "nie mogê za³adowaæ obrazka Ludek !" ); allegro_exit(); return 0; } blit( ludek, screen, 0, 0, 100, 100, ludek->w, ludek->h ); readkey(); destroy_bitmap( ludek ); allegro_exit(); return 0; }
void runStriker(struct Striker * striker,char push){ char i; push = readkey(); if(push == 0x01){ if(striker->pos.x <= 8191){ striker->pos.x += 50; } }else if(push == 0x02){ if(striker->pos.x >= 1){ striker->pos.x -= 50; } } }
struct menuinfo move_menu_cursor(struct menuinfo menu) { // function detects keystrokes and moves cursor/selects something int c; clear_keybuf(); c = readkey(); switch (c>>8) { case KEY_UP : menu.highlight--; break; case KEY_DOWN : menu.highlight++; break; case KEY_LEFT : menu.selection = menu.highlight; menu.selectupdn = -1; break; case KEY_RIGHT : case KEY_ENTER : menu.selection = menu.highlight; menu.selectupdn = 1; break; case KEY_ESC : exit(0); break; } if (menu.highlight < 0) menu.highlight = menu.num_of_options - 1; else if (menu.highlight > menu.num_of_options - 1) menu.highlight = 0; return(menu); }
int menu_mode( int matrix[][50]) // boot the menu { char button; BITMAP *menu = load_bitmap("Image/Menu.bmp",NULL); // circle(250,98,5); circle(250,129,5); BITMAP *selector = load_bitmap("Image/Selector.bmp",NULL); BITMAP *erase = load_bitmap("Image/Erase.bmp",NULL); mode = 1; clear_to_color(screen,0x4D4D4D); if(menu!=NULL) { blit(menu,screen,0,0,150,50,300,100); } while(button!=enter) { if(mode>0) { blit(selector,screen,0,0,154,85,90,30); blit(erase,screen,0,0,154,115,90,30); } else { blit(selector,screen,0,0,154,115,90,30); blit(erase,screen,0,0,154,85,90,30); } button = readkey(); if(button!= enter) { mode = mode*(-1); } rest(10); } if(mode==-1) { select_stage(matrix); } else { build_scenery(matrix,"sceneryx.txt"); scenery_number = -1; } return mode; }
void ManSettings() { blit(GainBox, screen, 0, 0, 300, 400, 114,55); while (!key[KEY_ESC]) { Letteri= readkey(); if(key[KEY_ENTER]) break; if(key[KEY_ESC]) exit(0); if(key[KEY_BACKSPACE]) { Letteri=NULL; uremove(Gain,-1); } if(uisdigit(Letteri)!=0) { Letterj= Letteri; strcat(Gain, &Letterj); } textprintf_ex(screen, font, 320, 415, 0, WHITE, "%s ", Gain); } Proceed(); }
void ControlType() { textprintf_ex(screen, font, 150, 250, 0, -1, "Tipo de Control:"); textprintf_ex(screen, font, 210, 280, DARK_GRAY, -1, "*Manual *Automatico "); while (!key[KEY_ESC]) { Letteri= readkey(); if(key[KEY_ENTER]) break; if(key[KEY_RIGHT]) { textprintf_ex(screen, font, 210, 280, DARK_GRAY, -1, "*Manual *Automatico "); textprintf_ex(screen, font, 372, 280, 0, -1, "*Automatico"); Option='A'; } if(key[KEY_LEFT]) { textprintf_ex(screen, font, 210, 280, DARK_GRAY, -1, "*Manual *Automatico "); textprintf_ex(screen, font, 210, 280, 0, -1, "*Manual"); Option='M'; } if(key[KEY_UP]) CaptureNumber(); } if(Option=='M') ManSettings(); if(Option=='A') AutoSettings(); Proceed(); return 0; }
void newGame() { BITMAP *loadScreen = NULL; loadScreen = load_bitmap("Loading Screen.bmp", NULL); // Load our picture BITMAP *newBuffer = NULL; newBuffer = create_bitmap(1024,768); //Create an empty bitmap. float creditPosition = 1024; int aKey = -1; creditPosition = advanceCredits(0, creditPosition); creditPosition = advanceCredits(735, creditPosition); creditPosition = advanceCredits(1590, creditPosition); creditPosition = advanceCredits(2500, creditPosition); stop_midi(); SAMPLE *transmission1 = load_sample("Transmission1.wav"); play_sample(transmission1, 255, 0, 1000, 0); fallingText(); stop_sample(transmission1); draw_sprite(newBuffer, loadScreen, 0, 0); blit(newBuffer, screen, 0,0,0,0,1024,768);//Draw the buffer to the screen while (!key[KEY_SPACE]) { readkey(); } return; }
int quitGame() { BITMAP *quitBackground = NULL; quitBackground = load_bitmap("Quit Background.bmp", NULL); // Load our picture BITMAP *quitBuffer = NULL; quitBuffer = create_bitmap(1024,768); //Create an empty bitmap. MIDI *midSuspense = NULL; midSuspense = load_midi("Suspense.mid"); MIDI *midResolve = NULL; midResolve = load_midi("Resolve.mid"); draw_sprite(quitBuffer, quitBackground, 0, 0); blit(quitBuffer, screen, 0,0,0,0,1024,768);//Draw the buffer to the screen play_midi(midSuspense, 1); readkey(); play_midi(midResolve, 0); clear_bitmap(quitBuffer); // Clear the contents of the buffer bitmap blit(quitBuffer, screen, 0,0,0,0,1024,768);//Draw the buffer to the screen sleep(700); return 0; }
static void fill_srt(lua_State *L, struct srt *srt, int idx) { luaL_checktype(L,idx,LUA_TTABLE); double x = readkey(L, idx, SRT_X, 0); double y = readkey(L, idx, SRT_Y, 0); double scale = readkey(L, idx, SRT_SCALE, 0); double sx; double sy; double rot = readkey(L, idx, SRT_ROT, 0); if (scale > 0) { sx = sy = scale; } else { sx = readkey(L, idx, SRT_SX, 1); sy = readkey(L, idx, SRT_SY, 1); } srt->offx = x*SCREEN_SCALE; srt->offy = y*SCREEN_SCALE; srt->scalex = sx*1024; srt->scaley = sy*1024; srt->rot = rot * (1024.0 / 360.0); }
int main() { int exit_flag = 0, i; VERTEX cube[8]; cube[0].local = (_3D) { -10.0, -10.0, 0.0 }; cube[1].local = (_3D) { 10.0, -10.0, 0.0 }; cube[2].local = (_3D) { 10.0, 10.0, 0.0 }; cube[3].local = (_3D) { -10.0, 10.0, -10.0 }; cube[4].local = (_3D) { -10.0, -10.0, 10.0 }; cube[5].local = (_3D) { 10.0, -10.0, 10.0 }; cube[6].local = (_3D) { 10.0, 10.0, 10.0 }; cube[7].local = (_3D) { -10.0, 10.0, 10.0 }; _3D world_pos = {0.0, 0.0, 100.0}; init(); printf("D1:=%f;\nD2:=%f;\nD3:=%f;\nD4:=%f;\n", dist_3d(cube[0].local, cube[1].local), dist_3d(cube[1].local, cube[2].local), dist_3d(cube[2].local, cube[3].local), dist_3d(cube[3].local, cube[0].local)); readkey(); int xang, yang, zang; while(!exit_flag) { rest(10); xang = 0; yang = 0; zang = 0; if(keypressed()) { if(key[KEY_ESC]) { exit_flag = 1; } if(key[KEY_A]) { world_pos.x -= 1.0; } if(key[KEY_D]) { world_pos.x += 1.0; } if(key[KEY_W]) { world_pos.z += 3.0; } if(key[KEY_S]) { world_pos.z -= 3.0; } if(key[KEY_UP]) { xang = 3; } if(key[KEY_DOWN]) { xang = -3; } if(key[KEY_RIGHT]) { yang = 3; } if(key[KEY_LEFT]) { yang = -3; } } clear_to_color(buffer, 0); for(i = 0; i < 8; i++) { rotate_vertex(&cube[i], xang, yang, zang); project_vertex(&cube[i], world_pos); } /* printf("%f, %f, %f\n", dist_3d(cube[0].local, cube[1].local), dist_3d(cube[1].local, cube[2].local), dist_3d(cube[2].local, cube[0].local)); */ printf("Sx1:=%f;\nSy1:=%f;\nSx2:=%f;\nSy2:=%f;\nSx3:=%f;\nSy3:=%f;\nSx4:=%f;\nSy4:=%f;\n", cube[0].screen[0].x, cube[0].screen[0].y, cube[1].screen[0].x, cube[1].screen[0].y, cube[2].screen[0].x, cube[2].screen[0].y, cube[3].screen[0].x, cube[3].screen[0].y); printf("t = %f\n\n\n\n\n\n", (cube[0].local.x + world_pos.x) / cube[0].screen[0].x); /*printf("{%f %f %f}\n", cube[0].local.x + world_pos.x, cube[0].local.y + world_pos.y, cube[0].local.z + world_pos.z); */ _2d_line(cube[0].screen[0], cube[1].screen[0], RED); _2d_line(cube[1].screen[0], cube[2].screen[0], RED); _2d_line(cube[2].screen[0], cube[3].screen[0], RED); _2d_line(cube[3].screen[0], cube[0].screen[0], RED); /* _2d_line(cube[4].screen[0], cube[5].screen[0], RED); _2d_line(cube[5].screen[0], cube[6].screen[0], RED); _2d_line(cube[6].screen[0], cube[7].screen[0], RED); _2d_line(cube[7].screen[0], cube[4].screen[0], RED); _2d_line(cube[0].screen[0], cube[4].screen[0], RED); _2d_line(cube[1].screen[0], cube[5].screen[0], RED); _2d_line(cube[2].screen[0], cube[6].screen[0], RED); _2d_line(cube[3].screen[0], cube[7].screen[0], RED); */ /* _2d_line(cube[0].screen[1], cube[1].screen[1], BLUE); _2d_line(cube[1].screen[1], cube[2].screen[1], BLUE); _2d_line(cube[2].screen[1], cube[3].screen[1], BLUE); _2d_line(cube[3].screen[1], cube[0].screen[1], BLUE); _2d_line(cube[4].screen[1], cube[5].screen[1], BLUE); _2d_line(cube[5].screen[1], cube[6].screen[1], BLUE); _2d_line(cube[6].screen[1], cube[7].screen[1], BLUE); _2d_line(cube[7].screen[1], cube[4].screen[1], BLUE); _2d_line(cube[0].screen[1], cube[4].screen[1], BLUE); _2d_line(cube[1].screen[1], cube[5].screen[1], BLUE); _2d_line(cube[2].screen[1], cube[6].screen[1], BLUE); _2d_line(cube[3].screen[1], cube[7].screen[1], BLUE); */ blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H); } destroy_bitmap(buffer); return 0; }
//lire un caractère ou une chaine de caractère char* lireChaine(char* nomfichier,int lig,int col,int R,int V,int B) { //ressources int touche=0; int i=0; char C[500]; //lire les caractères saisis while((i<499)&&(touche!=KEY_ENTER)&&(touche!=KEY_ENTER_PAD)) { touche=readkey()>>8; switch(touche) { case KEY_BACKSPACE: if(i>0) { i--; textprintf_ex(screen,font,col+10*i,lig,getpixel(screen,col+10*i,lig+8),-1,"%c",C[i]); } break; case KEY_SPACE: C[i]=touche-43; textprintf_ex(screen,font,col+10*i,lig,makecol(R,V,B),-1,"%c",C[i]); i++; break; case KEY_A: C[i]='q'; textprintf_ex(screen,font,col+10*i,lig,makecol(R,V,B),-1,"%c",C[i]); i++; break; case KEY_Q: C[i]='a'; textprintf_ex(screen,font,col+10*i,lig,makecol(R,V,B),-1,"%c",C[i]); i++; break; case KEY_Z: C[i]='w'; textprintf_ex(screen,font,col+10*i,lig,makecol(R,V,B),-1,"%c",C[i]); i++; break; case KEY_W: C[i]='z'; textprintf_ex(screen,font,col+10*i,lig,makecol(R,V,B),-1,"%c",C[i]); i++; break; case KEY_M: C[i]='m'; textprintf_ex(screen,font,col+10*i,lig,makecol(R,V,B),-1,"%c",C[i]); i++; break; default: if((touche>=1)&&(touche<=26)) { C[i]=touche+96; textprintf_ex(screen,font,col+10*i,lig,makecol(R,V,B),-1,"%c",C[i]); i++; } if((touche>=27)&&(touche<=36)) { C[i]=touche+21; textprintf_ex(screen,font,col+10*i,lig,makecol(R,V,B),-1,"%c",C[i]); i++; } if((touche>=37)&&(touche<=46)) { C[i]=touche+11; textprintf_ex(screen,font,col+10*i,lig,makecol(R,V,B),-1,"%c",C[i]); i++; } break; } } C[i]='\0'; //allocation dynamique nomfichier=(char*)malloc((i+2)*sizeof(char)); //copier la chaine c dans nomfichier nomfichier=strcpy(nomfichier,C); //retour de nomfichier return nomfichier; }
int RunSettingsMenu() { static int index = 0; static int spy = 72; int done = 0, y, i; g_dirty = 1; while (!done) { // Parse input readkey(); if (parsekey(DINGOO_B)) done = 1; if (parsekey(DINGOO_UP, 1)) { if (index > 0) { index--; spy -= 16; } else { index = 3; spy = 72 + 16*index; } } if (parsekey(DINGOO_DOWN, 1)) { if (index < 3) { index++; spy += 16; } else { index = 0; spy = 72; } } if (parsekey(DINGOO_A)) { done = settings_menu[index].command(); } // Must draw bg only when needed // Draw stuff if (g_dirty) { draw_bg(g_bg); //Draw Top and Bottom Bars DrawChar(gui_screen, SP_SELECTOR, 0, 37); DrawChar(gui_screen, SP_SELECTOR, 81, 37); DrawChar(gui_screen, SP_SELECTOR, 0, 225); DrawChar(gui_screen, SP_SELECTOR, 81, 225); DrawText(gui_screen, "B - Go Back", 235, 225); DrawChar(gui_screen, SP_LOGO, 12, 9); // Draw selector DrawChar(gui_screen, SP_SELECTOR, 56, spy); DrawChar(gui_screen, SP_SELECTOR, 77, spy); DrawText(gui_screen, "Settings", 8, 37); // Draw menu for (i = 0, y = 72; i < 4; i++, y += 16) { DrawText(gui_screen, settings_menu[i].name, 60, y); } // Draw info DrawText(gui_screen, settings_menu[index].info, 8, 225); g_dirty = 0; } SDL_Delay(16); // Update real screen FCEUGUI_Flip(); } // Must update emulation core and drivers UpdateEMUCore(g_config); FCEUD_DriverReset(); // Clear screen dingoo_clear_video(); g_dirty = 1; }
/* initializeAllObjects() Loads all images, sounds, etc. Operations are quite self-explanatory */ void initializeAllObjects() { screenBuffer = create_bitmap(1024, 768); loadBackground = makeBitmap("Images/Loading Background.gif"); mousePic = makeBitmap("Images/GameMouse.gif"); font15 = makeFont("Text/Hand15.pcx"); loadAllObjects(); showLoadingBar("Building Sounds"); buildingSound[EMPTY] = makeSample("Sound/Building/BUILD1.wav"); buildingSound[ROAD] = makeSample("Sound/Building/BUILD1.wav"); buildingSound[MARKET] = makeSample("Sound/Building/COIN.wav"); buildingSound[FARM] = makeSample("Sound/Building/GRANARY1.wav"); buildingSound[FOUNTAIN] = makeSample("Sound/Building/FOUNTAIN.wav"); buildingSound[THEATRE] = makeSample("Sound/Building/ART_PIT.wav"); buildingSound[TEMPLE] = makeSample("Sound/Building/ORACLE.wav"); buildingSound[POTTERSHOP] = makeSample("Sound/Building/CLAY_PIT.wav"); buildingSound[BARBERSHOP] = makeSample("Sound/Building/BARBER.wav"); buildingSound[FURNITUREWORKSHOP] = makeSample("Sound/Building/FORUM.wav"); buildingSound[WINEPRESS] = makeSample("Sound/Building/wine_workshop.wav"); buildingSound[BATHHOUSE] = makeSample("Sound/Building/BATHS.wav"); buildingSound[SLAVETRADER] = makeSample("Sound/Building/CLINIC.wav"); buildingSound[OLIVEPRESS] = makeSample("Sound/Building/MINE.wav"); buildingSound[ACADEMY] = makeSample("Sound/Building/FORUM.wav"); buildingSound[TENT] = makeSample("Sound/Building/HOUSING.wav"); selector = makeBitmap("Images/Selector.gif"); showLoadingBar("People"); personPic[0] = makeBitmap("Images/Person0.gif"); personPic[1] = makeBitmap("Images/Person1.gif"); personPic[2] = makeBitmap("Images/Person2.gif"); personPic[3] = makeBitmap("Images/Person3.gif"); personPic[4] = makeBitmap("Images/Person4.gif"); personPic[5] = makeBitmap("Images/Person5.gif"); infoFile = fopen("Text/InfoFile.txt", "w"); HUD = makeBitmap("Images/HUD.bmp"); int tY[NUMHUDBUTTONS] = {49, 100, 151, 202, 254, 304, 355, 401, 452, 508, 559, 610, 661, 712}; for (int i = 0; i < NUMHUDBUTTONS; i++) { resourceButton[i].left = 968; resourceButton[i].top = tY[i]; resourceButton[i].width = 34; resourceButton[i].height = 34; } menuButton.left = 309; menuButton.top = 0; menuButton.width = 77; menuButton.height = 33; buildingButton.left = 802; buildingButton.top = 42; buildingButton.width = 63; buildingButton.height = 115; personButton.left = 867; personButton.top = 42; personButton.width = 63; personButton.height = 115; placmentOutline = makeBitmap("Images/placmentOutline.bmp"); showLoadingBar("Ambient Sounds"); ambientSound[0] = makeSample("Sound/Bird0.wav"); ambientSound[1] = makeSample("Sound/Bird1.wav"); ambientSound[2] = makeSample("Sound/Bird2.wav"); ambientSound[3] = makeSample("Sound/Bird3.wav"); ambientSound[4] = makeSample("Sound/Bird4.wav"); ambientSound[5] = makeSample("Sound/Bird5.wav"); ambientSound[6] = makeSample("Sound/Bird6.wav"); ambientSound[7] = makeSample("Sound/Bird7.wav"); font70 = makeFont("Text/Hand70.pcx"); font15 = makeFont("Text/Hand15.pcx"); resourceColour[FOOD] = makecol(255, 255,0); resourceColour[WATER] = makecol(0,0,255); resourceColour[ENTERTAINMENT] = makecol(255 ,0,0); resourceColour[RELIGION] = makecol(170, 170, 170); resourceColour[POTTERY] = makecol(230, 196, 113); resourceColour[BARBER] = makecol(214, 214, 214); resourceColour[FURNITURE] = makecol(94, 74,0); resourceColour[WINE] = makecol(255, 43, 124); resourceColour[BATHING] = makecol(0,0,255); resourceColour[SLAVES] = makecol(255,100,100); resourceColour[OLIVE_OIL] = makecol(0, 143, 75); resourceColour[EDUCATION] = makecol(255,255,255); showLoadingBar("Resource Icons"); resourceIcon[0] = makeBitmap("Images/Icon0.gif"); resourceIcon[1] = makeBitmap("Images/Icon1.gif"); resourceIcon[2] = makeBitmap("Images/Icon2.gif"); resourceIcon[3] = makeBitmap("Images/Icon3.gif"); resourceIcon[4] = makeBitmap("Images/Icon4.gif"); resourceIcon[5] = makeBitmap("Images/Icon5.gif"); resourceIcon[6] = makeBitmap("Images/Icon6.gif"); resourceIcon[7] = makeBitmap("Images/Icon7.gif"); resourceIcon[8] = makeBitmap("Images/Icon8.gif"); resourceIcon[9] = makeBitmap("Images/Icon9.gif"); resourceIcon[10] = makeBitmap("Images/Icon10.gif"); resourceIcon[11] = makeBitmap("Images/Icon11.gif"); draw_sprite(screenBuffer, loadBackground, 0, 0); rectfill(screenBuffer, 209, 524, 209 + (int)(((float)((float)loadingPhase)/(float)(loadingPhases)) * (810 - 209)), 531, makecol(255, 0, 0)); textprintf_centre_ex(screenBuffer, font15, 509, 482, 0, -1, "Loading Complete! Press any key to continue"); textprintf_centre_ex(screenBuffer, font15, 510, 480, makecol(255, 255, 255), -1, "Loading Complete! Press any key to continue"); draw_sprite(screenBuffer, mousePic, mouseX, mouseY); blit(screenBuffer, screen, 0,0,0,0,1024,768); clear_bitmap(screenBuffer); destroy_bitmap(loadBackground); readkey(); }
void site_docs(void) { FILE *fp, *hp, *toc; char temp[PATH_MAX], temp1[PATH_MAX]; int page = 0, line = 0; if (config_read() == -1) return; snprintf(temp, PATH_MAX, "%s/share/doc/site.doc", getenv("FTND_ROOT")); mkdirs(temp, 0755); if ((fp = fopen(temp, "w")) == NULL) return; snprintf(temp1, PATH_MAX, "%s/tmp/toc.tmp", getenv("FTND_ROOT")); if ((toc = fopen(temp1, "w+")) == NULL) { fclose(fp); return; } clr_index(); working(1, 0, 0); IsDoing("Making Sitedocs"); Syslog('+', "Start creating sitedocs"); set_color(WHITE, BLACK); ftnd_mvprintw( 5, 6, "21. CREATING SITEDOCS"); set_color(CYAN, BLACK); ftnd_mvprintw( 7,11, (char *)"Erasing directory %s/share/doc/html", getenv("FTND_ROOT")); fflush(stdout); snprintf(temp, PATH_MAX, "-r -f %s/share/doc/html", getenv("FTND_ROOT")); execute_pth((char *)"rm", temp, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null"); if ((hp = open_webdoc((char *)"index.html", (char *)"BBS Site Documentation", NULL))) { fprintf(hp, "<UL>\n"); fprintf(hp, " <LI><A HREF=\"global.html\">Global Configuration</A></LI>\n"); fprintf(hp, " <LI><A HREF=\"fidonet.html\">Fido Networks</A></LI>\n"); fprintf(hp, " <LI><A HREF=\"archivers.html\">Archivers</A></LI>\n"); fprintf(hp, " <LI><A HREF=\"virscan.html\">Virus Scanners</A></LI>\n"); fprintf(hp, " <LI><A HREF=\"modem.html\">Modem Types</A></LI>\n"); fprintf(hp, " <LI><A HREF=\"ttyinfo.html\">TTY Lines Info</A></LI>\n"); fprintf(hp, " <LI><A HREF=\"nodes.html\">Fidonet Nodes</A></LI>\n"); fprintf(hp, " <LI>BBS: <A HREF=\"limits.html\">Security Limits</A></LI>\n"); fprintf(hp, " <LI>BBS: <A HREF=\"language.html\">Language Setup</A></LI>\n"); fprintf(hp, " <LI>BBS: <A HREF=\"menus.html\">BBS Menus</A></LI>\n"); fprintf(hp, " <LI>BBS: <A HREF=\"fileareas.html\">File Areas</A></LI>\n"); fprintf(hp, " <LI>BBS: <A HREF=\"protocol.html\">Transfer Protocols</A></LI>\n"); fprintf(hp, " <LI>BBS: <A HREF=\"oneliners.html\">Oneliners</A></LI>\n"); fprintf(hp, " <LI>Mail: <A HREF=\"msggroup.html\">Echomail Groups</A></LI>\n"); fprintf(hp, " <LI>Mail: <A HREF=\"msgareas.html\">Echomail Areas</A></LI>\n"); fprintf(hp, " <LI>TIC: <A HREF=\"filegroup.html\">FileEcho Groups</A></LI>\n"); fprintf(hp, " <LI>TIC: <A HREF=\"ticareas.html\">Fileecho Areas</A></LI>\n"); fprintf(hp, " <LI>TIC: <A HREF=\"hatch.html\">Hatch Manager</A></LI>\n"); fprintf(hp, " <LI>TIC: <A HREF=\"magic.html\">Magic Files</A></LI>\n"); fprintf(hp, " <LI><A HREF=\"newgroup.html\">Newfiles Groups</A></LI>\n"); fprintf(hp, " <LI><A HREF=\"newfiles.html\">Newfiles Reports</A></LI>\n"); fprintf(hp, " <LI><A HREF=\"filefind.html\">Filefind Setup</A></LI>\n"); fprintf(hp, " <LI><A HREF=\"users.html\">BBS Users</A></LI>\n"); fprintf(hp, " <LI><A HREF=\"service.html\">Mail Service Manager</A></LI>\n"); fprintf(hp, " <LI><A HREF=\"domain.html\">Domain translation</A></LI>\n"); fprintf(hp, " <LI><A HREF=\"task.html\">Task Manager</A></LI>\n"); fprintf(hp, " <LI><A HREF=\"route.html\">Network Routing</A></LI>\n"); fprintf(hp, " <LI><A HREF=\"ibcsrv.html\">Internet BBS Chat</A></LI>\n"); fprintf(hp, "</UL>\n"); close_webdoc(hp); } else { Syslog('+', "Can't create html documentation"); } ftnd_mvprintw(8,11, (char *)"Creating site documents"); fflush(stdout); horiz = 35; page = global_doc(fp, toc, page); dotter(); page = fido_doc(fp, toc, page); dotter(); page = archive_doc(fp, toc, page); dotter(); page = virus_doc(fp, toc, page); dotter(); page = modem_doc(fp, toc, page); dotter(); page = tty_doc(fp, toc, page); dotter(); page = node_doc(fp, toc, page); dotter(); page = bbs_doc(fp, toc, page); dotter(); page = mail_doc(fp, toc, page); dotter(); page = tic_doc(fp, toc, page); dotter(); page = newf_group_doc(fp, toc, page); dotter(); page = new_doc(fp, toc, page); dotter(); page = ff_doc(fp, toc, page); dotter(); page = service_doc(fp, toc, page); dotter(); page = domain_doc(fp, toc, page); dotter(); page = task_doc(fp, toc, page); dotter(); page = route_doc(fp, toc, page); dotter(); page = ibc_doc(fp, toc, page); dotter(); users_doc(); dotter(); ol_doc(); clrtoeol(); ftnd_mvprintw( 8,11, (char *)"Created site documents in %s/share/doc", getenv("FTND_ROOT")); fflush(stdout); /* * Append table of contents */ page = newpage(fp, page); addtoc(fp, toc, 21, 0, page, (char *)"Table of contents"); fprintf(fp, "\n\n"); line = 4; rewind(toc); while (fgets(temp, 256, toc) != NULL) { fprintf(fp, "%s", temp); line++; if (line == 56) { page = newpage(fp, page); line = 0; } } fprintf(fp, "\f"); fclose(fp); fclose(toc); unlink(temp1); Syslog('+', "Sitedocs created"); /* * Remove obsolete documents */ snprintf(temp, PATH_MAX, "%s/doc/xref.doc", getenv("FTND_ROOT")); unlink(temp); snprintf(temp, PATH_MAX, "%s/doc/stat.doc", getenv("FTND_ROOT")); unlink(temp); center_addstr(LINES -4, (char *)"Press any key"); readkey(LINES -4, COLS / 2 + 8, LIGHTGRAY, BLACK); return; }
int main() { int klaw = 0; allegro_init(); install_keyboard(); set_color_depth(16); set_gfx_mode(GFX_AUTODETECT,640,480,0,0); clear_to_color(screen,makecol(10,10,10)); while( !key[KEY_ESC]) { /* klaw = readkey(); clear_to_color(screen,makecol(10,10,10)); switch (klaw) { case 7217: textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : 1"); break; case 7474: textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : 2"); break; case 7731: textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : 3"); break; case 7988: textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : 4"); break; case 8245: textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : 5"); break; } if( key[KEY_LEFT]) textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : [KEY_LEFT]"); if( key[KEY_RIGHT]) textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : [KEY_RIGHT]"); if( key[KEY_UP]) textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : [KEY_UP]"); if( key[KEY_DOWN]) textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : [KEY_DOWN]"); if( key[KEY_0]) textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : [KEY_0]"); if( key[KEY_1]) textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : [KEY_1]"); if( key[KEY_2]) textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : [KEY_2]"); if( key[KEY_3]) textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : [KEY_3]"); if( key[KEY_4]) textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : [KEY_4]"); if( key[KEY_5]) textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : [KEY_5]"); if( key[KEY_6]) textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : [KEY_6]"); if( key[KEY_7]) textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : [KEY_7]"); if( key[KEY_8]) textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : [KEY_8]"); if( key[KEY_9]) textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : [KEY_9]"); if( key[KEY_SPACE]) textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : [KEY_SPACE]"); if( key[KEY_ENTER]) textprintf(screen,font,20,20,makecol(255,255,128),"Klawisz to : [KEY_ENTER]"); */ BITMAP *plik = NULL; plik = load_bmp("bmp.bmp",default_palette); if (!plik) { set_gfx_mode(GFX_TEXT,0,0,0,0); allegro_message("nie mogê za³adowaæ obrazka Plik!"); allegro_exit(); return 0; } blit( plik, screen, 0,0, 100,100, plik->w, plik->h); readkey(); destroy_bitmap(plik); allegro_exit(); } allegro_exit(); return 0; }
void newGame() { clear_keybuf(); readkey(); x=210,y=140,xx=0,yy=140,xxx=430,yyy=140; }
int main( int argc, char *argv[] ) { BITMAP *lobuf; BITMAP *backbuf; #ifndef NDEBUG // Create a win32 console for printfing AllocConsole(); freopen("CONIN$","rb",stdin); // reopen stdin handle as console window input freopen("CONOUT$","wb",stdout); // reopen stout handle as console window output freopen("CONOUT$","wb",stderr); // reopen stderr handle as console window output #endif //----- Game stuff --------------- // the map of the world TileMap map( 300 ); // the chunks of land std::vector<TileMap*> landChunks; set_color_depth( 32 ); if (allegro_init() != 0) return 1; install_keyboard(); install_timer(); install_mouse(); // install ticker LOCK_VARIABLE( ticks ); LOCK_FUNCTION( ticker ); install_int_ex( ticker, BPS_TO_TIMER( UPDATES_PER_SEC ) ); if (set_gfx_mode( GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0 ) != 0) { set_gfx_mode( GFX_TEXT, 0, 0, 0, 0 ); allegro_message( "Unable to set graphics mode:\n%s\n", allegro_error ); return 1; } enable_hardware_cursor(); select_mouse_cursor( MOUSE_CURSOR_ARROW ); lobuf = create_bitmap( 320, 240 ); backbuf = create_bitmap( SCREEN_W, SCREEN_H ); show_mouse( backbuf ); // printf("lobuf %p backbuf %p\n", lobuf, backbuf ); // init gameplay stuff srand( time(0)); //printf("init map...\n" ); map.init(); map.reset(); map.do_water = true; message( "I woke near the ocean. I didn't even know my own name." ); message( "So I started exploring (drag RMB to scroll)"); // load chunks loadLandChunks( "gamedata/land.txt", landChunks ); map.paste( landChunks[0], 148, 148 ); map.enableSelect( lobuf ); // make player BITMAP *npcCodeMask = load_bitmap( "gamedata/code_npc.bmp", NULL ); BITMAP *critterCodeMask = load_bitmap( "gamedata/code_critter.bmp", NULL ); BITMAP *playerBmp = make_pixbot( npcCodeMask ); // Init game objects std::vector<GameObj*> gameObjs; Player *player = new Player(); player->m_bmp = playerBmp; player->m_x = 150; player->m_y = 148; gameObjs.push_back( player ); int currTool = Tool_WALK; //printf("--- mainloop\n" ); bool done = false; bool dbgShowSelects = false; // near center on a 300x300 map int view_x = -1644, view_y = -800; bool dragging = false; int drag_x, drag_y; int view_drag_x, view_drag_y; int mouse_x2, mouse_y2; // in lobuf coords int last_b = 0; int px, py; bool doGenerate = true; while (!done) { // handle ticks -- give the ticker a chance to start while( ticks==0) { rest(100 / UPDATES_PER_SEC ); } while ( ticks > 0) { int old_ticks = ticks; //=== Update ==== map.m_wave_offs++; if (messageTime>0) { messageTime--; if (messageTime==0) { strcpy( messageText, "" ); } } else { if (!messageQueue.empty()) { strcpy( messageText, messageQueue.front().c_str() ); messageQueue.pop_front(); messageTime = MSG_TIME; } } for (int i=0; i < gameObjs.size(); ++i ) { if (gameObjs[i]) { gameObjs[i]->update( map, gameObjs ); } } // update may have NULL'd objects std::vector<GameObj*>::iterator removed; removed = std::remove( gameObjs.begin(), gameObjs.end(), (GameObj*)NULL ); gameObjs.erase( removed, gameObjs.end() ); // update bubbles for (int i=0; i < bubbles.size(); i++) { bubbles[i]->bub_age += 1.0 / (float)UPDATES_PER_SEC; } ticks--; if (old_ticks <= ticks) break; } int dropBubble = -1; // keyboard input if (keypressed()) { int k = readkey(); if (cheatsEnabled) { switch(k>>8) { //---- debug keys case KEY_F5: dbgShowSelects = !dbgShowSelects; break; case KEY_F6: playerBmp = make_pixbot( npcCodeMask ); player->m_bmp = playerBmp; break; case KEY_F7: bubbles.push_back( create_bubble( landChunks ) ); break; } } switch(k>>8) { case KEY_F11: cheatsEnabled = true; message("Cheats enabled."); break; //---- game keys case KEY_1: dropBubble = 0; break; case KEY_2: dropBubble = 1; break; case KEY_3: dropBubble = 2; break; case KEY_4: dropBubble = 3; break; case KEY_5: dropBubble = 4; break; // hack -- on keydown, clear walk wait counter case KEY_LEFT: case KEY_RIGHT: case KEY_UP: case KEY_DOWN: player->walk_c = 0; break; } } if ((dropBubble >= 0) && (dropBubble < bubbles.size()) ) { TileMap *bub = bubbles[dropBubble]; bubbles[dropBubble] = bubbles[ bubbles.size() -1 ]; bubbles.pop_back(); map.paste( bub, player->m_x - bub->m_size/2, player->m_y - bub->m_size/2 ); doGenerate = true; delete bub; } // generate entities if (doGenerate) { doGenerate = false; for (int i=0; i < map.m_size; i++) { for (int j=0; j < map.m_size; j++) { if (map.map(i,j).m_gen != Gen_NONE ) { if (map.map(i,j).m_gen == Gen_BUBBLE) { BubbleObj *bubObj = new BubbleObj(); bubObj->m_x = i; bubObj->m_y = j; bubObj->m_bub = create_bubble( landChunks ); bubObj->m_bmp = create_bitmap( 15, 15 ); BITMAP *bubBmp = bubObj->m_bub->bub_bmp; stretch_blit( bubBmp, bubObj->m_bmp, 0,0, bubBmp->w, bubBmp->h, 0,0, 15, 15 ); gameObjs.push_back( bubObj ); } else if (map.map(i,j).m_gen == Gen_CRITTER) { CritterObj *critObj = new CritterObj(); critObj->m_x = i; critObj->m_y = j; BITMAP *critpic; int critNdx = rand() % (critterBmps.size()+1); if (critNdx == critterBmps.size()) { // yay new critter critpic = make_pixbot( critterCodeMask ); critterBmps.push_back( critpic ); } else { critpic = critterBmps[ critNdx ]; } critObj->m_bmp = critpic; gameObjs.push_back( critObj ); } else if (map.map(i,j).m_gen == Gen_NPC) { NpcObj *npc = new NpcObj(); npc->m_x = i; npc->m_y = j; npc->m_bmp = make_pixbot( npcCodeMask ); gameObjs.push_back( npc ); } map.map(i,j).m_gen = Gen_NONE; } } } } // check for quit if (key[KEY_ESC]) { exit(0); break; } player->walk_x = 0; player->walk_y = 0; if (key[KEY_UP] && !key[KEY_DOWN]) { player->walk_x = 0; player->walk_y = 1; } else if (!key[KEY_UP] && key[KEY_DOWN]) { player->walk_x = 0; player->walk_y = -1; } else if (!key[KEY_LEFT] && key[KEY_RIGHT]) { player->walk_x = -1; player->walk_y = 0; } else if (key[KEY_LEFT] && !key[KEY_RIGHT]) { player->walk_x = 1; player->walk_y = 0; } // Map cursor char buff[246]; int mapX, mapY; map.clearSelected(); mouse_x2 = mouse_x/2; mouse_y2 = mouse_y/2; if (map.screenToMap( mouse_x2, mouse_y2, mapX, mapY )) { sprintf( buff, "V %d %d x y %d %d [%d] -- map %d %d", view_x, view_y, mouse_x, mouse_y, mouse_b, mapX, mapY ); // NOTE: Don't use mouse selection anymore -- just use selection // to mark player //map.map( mapX, mapY ).m_selected = true; } else { sprintf( buff, "V %d %d x y %d %d NO TILE", view_x, view_y, mouse_x, mouse_y ); } map.map( player->m_x, player->m_y ).m_selected = true; // Mouse button 2 -- drag if (mouse_b & 0x2) { if (!dragging) { dragging = true; drag_x = mouse_x2; drag_y = mouse_y2; view_drag_x = view_x; view_drag_y = view_y; } else { int dx = mouse_x2 - drag_x; int dy = mouse_y2 - drag_y; view_x = view_drag_x + dx; view_y = view_drag_y + dy; } } else { dragging = false; } // button 1 -- use tool (or walk) if (mouse_b & 0x1) { switch( currTool) { case Tool_WALK: { MapCell &cell = map.map(player->m_x, player->m_y ); px = cell.sx + 4; py = cell.sy + 10; if ((px < mouse_x2) && (py < mouse_y2 )) { player->walk_x = -1; player->walk_y = 0; } else if ((px > mouse_x2) && (py > mouse_y2 )) { player->walk_x = 1; player->walk_y = 0; } else if ((px > mouse_x2) && (py < mouse_y2 )) { player->walk_x = 0; player->walk_y = -1; } else if ((px < mouse_x2) && (py > mouse_y2 )) { player->walk_x = 0; player->walk_y = 1; } } break; } } else { switch( currTool ) { case Tool_WALK: if (last_b & 0x01) { player->walk_x = 0; player->walk_y = 0; } break; } } last_b = mouse_b; // ==== draw ===== rectfill( lobuf, 0, 0, 320, 240, makecol( 135, 171, 189 ) ); //map.draw( lobuf, 10, 30 ); map.draw( lobuf, view_x, view_y, gameObjs ); // draw bubbles int bx = 160 - (bubbles.size() * 12); char buf[10]; for (int i=0; i < bubbles.size(); i++) { TileMap *b = bubbles[i]; draw_sprite( lobuf, b->bub_bmp, bx, 215 - (int)(sin(b->bub_age * M_PI)*3) ); sprintf( buf,"%d", i+1 ); textout_centre_ex( lobuf, font, buf, bx + 13, 231, makecol( 0x44, 0x66, 0x77 ), -1); textout_centre_ex( lobuf, font, buf, bx + 12, 230, makecol( 0xff, 0xff, 0xff ), -1); bx += 24; } //DBG draw player //masked_stretch_blit( playerBmp, lobuf, 0, 0, playerBmp->w, playerBmp->h, // 10, 20, playerBmp->w * 4, playerBmp->h * 4 ); // scale buffer to screen stretch_blit( dbgShowSelects?map.m_selectMap:lobuf, backbuf, 0, 0, lobuf->w, lobuf->h, 0, 0, SCREEN_W, SCREEN_H ); // Draw text and stuff at full res //masked_blit( bubbles[0]->bub_bmp, backbuf, 0, 0, 50, 20, // bubbles[0]->bub_bmp->w, bubbles[0]->bub_bmp->h ); //textout( backbuf, font, buff, 10, 10, makecol( 0xff, 0xff, 0xff ) ); drawing_mode( DRAW_MODE_TRANS, NULL, 0, 0 ); set_trans_blender( 0, 0, 0, 128 ); rectfill( backbuf, 0, 7, 640, 75, makecol( 0xff, 0xff, 0xff ) ); solid_mode(); hline( backbuf, 0, 7, 640, makecol( 0, 0, 0x77 ) ); hline( backbuf, 0, 75, 640, makecol( 0, 0, 0x77 ) ); // player icon masked_stretch_blit( playerBmp, backbuf, 0, 0, playerBmp->w, playerBmp->h, 10, 10, playerBmp->w * 4, playerBmp->h * 4 ); //party icons for (int i=0; i < npcs.size(); i++) { BITMAP *npcBmp = npcs[i]->m_bmp; masked_stretch_blit( npcBmp, backbuf, 0, 0, npcBmp->w, npcBmp->h, 70 + 45*i, 10, npcBmp->w * 4, npcBmp->h * 4 ); } if (strlen(messageText)) { float t = (float)messageTime / MSG_TIME; //textout_centre_ex( backbuf, font, messageText, 322, 62, makecol( 0x44, 0x66, 0x77 ), -1 ); textout_centre_ex( backbuf, font, messageText, 320, 60, makecol( lerp( t, 0x00, 0xcc ), lerp( t, 0x00, 0xcc ), lerp( t, 0x00, 0xcc ) ), -1 ); //makecol( 0x44, 0x66, 0x77 ), //makecol( 0xff, 0xff, 0xff ), -1 ); } // flip screen vsync(); acquire_screen(); blit( backbuf, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H ); release_screen(); yield_timeslice(); } return 0; }
void menu(){ BITMAP *menu[4]; //Define o ponteiro "menu" int xpos = 250; int ypos = 270; int i = 1; int j = 2; buffer = create_bitmap(1280,720); //O Buffer cria um Bitmap de 1280x720 background[0] = load_bitmap("background.bmp", NULL); //O background recebe a imagem background[1] = load_bitmap("background1.bmp", NULL); //O background recebe a imagem background[2] = load_bitmap("background2.bmp", NULL); //O background recebe a imagem background[3] = load_bitmap("background3.bmp", NULL); //O background recebe a imagem background[4] = load_bitmap("background4.bmp", NULL); //O background recebe a imagem background[5] = load_bitmap("background5.bmp", NULL); //O background recebe a imagem background[6] = load_bitmap("background6.bmp", NULL); //O background recebe a imagem background[7] = load_bitmap("background7.bmp", NULL); //O background recebe a imagem draw_sprite(screen, background[back], 0, 0); //Coloca a imagem na tela draw_sprite(buffer, background[back], 0, 0); //Coloca a imagem na tela menu[0] = load_bitmap("mnuNewGame.bmp", NULL); menu[1] = load_bitmap("mnuNewGameM.bmp", NULL); menu[2] = load_bitmap("mnuOptions.bmp", NULL); menu[3] = load_bitmap("mnuOptionsM.bmp", NULL); draw_sprite(screen, menu[i], xpos,ypos); ypos += 100; xpos +=15; draw_sprite(screen, menu[j], xpos,ypos); while (!key[KEY_ENTER]) { readkey(); if (key[KEY_UP]) { if(i < 1 && j > 2) { i++; j--; xpos = 250; ypos = 270; blit(buffer, screen, 0,0,0,0,1280,720); //Limpa a tela clear_bitmap(buffer); //Limpa a tela draw_sprite(buffer, background[back], 0, 0); //Coloca a imagem na tela draw_sprite(screen, menu[i], xpos,ypos); ypos += 100; xpos +=15; draw_sprite(screen, menu[j], xpos,ypos); } } if (key[KEY_DOWN]) { if(i > 0 && j < 3) { i--; j++; xpos = 250; ypos = 270; blit(buffer, screen, 0,0,0,0,1280,720); //Limpa a tela clear_bitmap(buffer); //Limpa a tela draw_sprite(buffer, background[back], 0, 0); //Coloca a imagem na tela draw_sprite(screen, menu[i], xpos,ypos); ypos += 100; xpos +=15; draw_sprite(screen, menu[j], xpos,ypos); } } } if (i == 0 && j == 3){ options(); } }
int main(int argc, char *argv[]) { char buf[256]; PALETTE pal; BITMAP *image; BITMAP *page[2]; BITMAP *vimage; IMAGE images[MAX_IMAGES]; int num_images = 4; int page_num = 1; int done = FALSE; int i; if (allegro_init() != 0) return 1; install_keyboard(); install_timer(); /* see comments in exflip.c */ #ifdef ALLEGRO_VRAM_SINGLE_SURFACE if (set_gfx_mode(GFX_AUTODETECT, 1024, 768, 0, 2 * 768 + 200) != 0) { #else if (set_gfx_mode(GFX_AUTODETECT, 1024, 768, 0, 0) != 0) { #endif set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message("Error setting graphics mode\n%s\n", allegro_error); return 1; } /* read in the source graphic */ replace_filename(buf, argv[0], "mysha.pcx", sizeof(buf)); image = load_bitmap(buf, pal); if (!image) { set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message("Error reading %s!\n", buf); return 1; } set_palette(pal); /* initialise the images to random positions */ for (i=0; i<MAX_IMAGES; i++) init_image(images+i); /* create two video memory bitmaps for page flipping */ page[0] = create_video_bitmap(SCREEN_W, SCREEN_H); page[1] = create_video_bitmap(SCREEN_W, SCREEN_H); /* create a video memory bitmap to store our picture */ vimage = create_video_bitmap(image->w, image->h); if ((!page[0]) || (!page[1]) || (!vimage)) { set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message("Not enough video memory (need two 1024x768 pages " "and a 320x200 image)\n"); return 1; } /* copy the picture into offscreen video memory */ blit(image, vimage, 0, 0, 0, 0, image->w, image->h); while (!done) { acquire_bitmap(page[page_num]); /* clear the screen */ clear_bitmap(page[page_num]); /* draw onto it */ for (i=0; i<num_images; i++) blit(vimage, page[page_num], 0, 0, images[i].x, images[i].y, vimage->w, vimage->h); textprintf_ex(page[page_num], font, 0, 0, 255, -1, "Images: %d (arrow keys to change)", num_images); /* tell the user which functions are being done in hardware */ if (gfx_capabilities & GFX_HW_FILL) textout_ex(page[page_num], font, "Clear: hardware accelerated", 0, 16, 255, -1); else textout_ex(page[page_num], font, "Clear: software (urgh, this " "is not good!)", 0, 16, 255, -1); if (gfx_capabilities & GFX_HW_VRAM_BLIT) textout_ex(page[page_num], font, "Blit: hardware accelerated", 0, 32, 255, -1); else textout_ex(page[page_num], font, "Blit: software (urgh, this program " "will run too sloooooowly without hardware acceleration!)", 0, 32, 255, -1); release_bitmap(page[page_num]); /* page flip */ show_video_bitmap(page[page_num]); page_num = 1-page_num; /* deal with keyboard input */ while (keypressed()) { switch (readkey()>>8) { case KEY_UP: case KEY_RIGHT: if (num_images < MAX_IMAGES) num_images++; break; case KEY_DOWN: case KEY_LEFT: if (num_images > 0) num_images--; break; case KEY_ESC: done = TRUE; break; } } /* bounce the images around the screen */ for (i=0; i<num_images; i++) update_image(images+i); } destroy_bitmap(image); destroy_bitmap(vimage); destroy_bitmap(page[0]); destroy_bitmap(page[1]); return 0; } END_OF_MAIN()
int main(int argc, const char *const *argv) /* I'm const-crazy! */ { DUH *duh; /* Encapsulates the music file. */ AL_DUH_PLAYER *dp; /* Holds the current playback state. */ /* Initialise Allegro */ if (allegro_init()) return EXIT_FAILURE; /* Check that we have one argument (plus the executable name). */ if (argc != 2) usage(argv[0]); /* Tell Allegro where to find configuration data. This means you can * put any settings for Allegro in dumb.ini. See Allegro's * documentation for more information. */ set_config_file("dumb.ini"); /* Initialise Allegro's keyboard input. */ if (install_keyboard()) { allegro_message("Failed to initialise keyboard driver!\n"); return EXIT_FAILURE; } /* This function call is appropriate for a program that will play one * sample or one audio stream at a time. If you have sound effects * too, you may want to increase the parameter. See Allegro's * documentation for details on what the parameter means. Note that * newer versions of Allegro act as if set_volume_per_voice() was * called with parameter 1 initially, while older versions behave as * if -1 was passed, so you should call the function if you want * consistent behaviour. */ set_volume_per_voice(0); /* Initialise Allegro's sound output system. */ if (install_sound(DIGI_AUTODETECT, MIDI_NONE, NULL)) { allegro_message("Failed to initialise sound driver!\n%s\n", allegro_error); return EXIT_FAILURE; } /* dumb_exit() is a function defined by DUMB. This operation arranges * for dumb_exit() to be called last thing before the program exits. * dumb_exit() does a bit of cleaning up for you. atexit() is * declared in stdlib.h. */ atexit(&dumb_exit); /* DUMB defines its own wrappers for file input. There is a struct * called DUMBFILE that holds function pointers for the various file * operations needed by DUMB. You can decide whether to use stdio * FILE objects, Allegro's PACKFILEs or something else entirely. No * wrapper is installed initially, so you must call this or * dumb_register_stdfiles() or set up your own before trying to load * modules by file name. (If you are using another method, such as * loading an Allegro datafile with modules embedded in it, then DUMB * never opens a file by file name so this doesn't apply.) */ dumb_register_packfiles(); /* Load the module file into a DUH object. Quick and dirty: try the * loader for each format until one succeeds. Note that 15-sample * mods have no identifying features, so dumb_load_mod() may succeed * on files that aren't mods at all. We therefore try that one last. */ duh = dumb_load_it(argv[1]); if (!duh) { duh = dumb_load_xm(argv[1]); if (!duh) { duh = dumb_load_s3m(argv[1]); if (!duh) { duh = dumb_load_mod(argv[1]); if (!duh) { allegro_message("Failed to load %s!\n", argv[1]); return EXIT_FAILURE; } } } } /* Read the quality values from the config file we told Allegro to * use. You may want to hardcode these or provide a more elaborate * interface via which the user can control them. */ dumb_resampling_quality = get_config_int("sound", "dumb_resampling_quality", 4); dumb_it_max_to_mix = get_config_int("sound", "dumb_it_max_to_mix", 128); /* If we're not in DOS, show a window and register our close hook * function. */ # ifndef ALLEGRO_DOS { const char *fn = get_filename(argv[1]); gfx_half_width = strlen(fn); if (gfx_half_width < 22) gfx_half_width = 22; gfx_half_width = (gfx_half_width + 2) * 4; /* set_window_title() is not const-correct (yet). */ set_window_title((char *)"DUMB Music Player"); if (set_gfx_mode(GFX_DUMB_MODE, gfx_half_width*2, 80, 0, 0) == 0) { acquire_screen(); textout_centre(screen, font, fn, gfx_half_width, 20, 14); textout_centre(screen, font, "Press any key to exit.", gfx_half_width, 52, 11); release_screen(); } else gfx_half_width = 0; } /* Silly check to get around the fact that someone stupidly removed * an old function from Allegro instead of deprecating it. The old * function was put back a version later, but we may as well use the * new one if it's there! */ # if ALLEGRO_VERSION*10000 + ALLEGRO_SUB_VERSION*100 + ALLEGRO_WIP_VERSION >= 40105 set_close_button_callback(&closehook); # else set_window_close_hook(&closehook); # endif # endif /* We want to continue running if the user switches to another * application. */ set_display_switch_mode(SWITCH_BACKGROUND); /* We have the music loaded, but it isn't playing yet. This starts it * playing. We construct a second object, the AL_DUH_PLAYER, to * represent the playing music. This means you can play the music * twice at the same time should you want to! * * Specify the number of channels (2 for stereo), which 'signal' to * play (always 0 for modules), the volume (1.0f for default), the * buffer size (4096 generally works well) and the sampling frequency * (ideally match the final output frequency Allegro is using). An * Allegro audio stream will be started. */ dp = al_start_duh(duh, 2, 0, 1.0f, get_config_int("sound", "buffer_size", 4096), get_config_int("sound", "sound_freq", 44100)); /* Register our callback functions so that they are called when the * music loops or stops. See docs/howto.txt for more information. * There is no threading issue: DUMB will only process playback * in al_poll_duh(), which we call below. */ { DUH_SIGRENDERER *sr = al_duh_get_sigrenderer(dp); DUMB_IT_SIGRENDERER *itsr = duh_get_it_sigrenderer(sr); dumb_it_set_loop_callback(itsr, &loop_callback, NULL); dumb_it_set_xm_speed_zero_callback(itsr, &xm_speed_zero_callback, NULL); } /* Main loop. */ for (;;) { /* Check for keys in the buffer. If we get one, discard it * and exit the main loop. */ if (keypressed()) { readkey(); break; } /* Poll the music. We exit the loop if al_poll_duh() has * returned nonzero (music finished) or the window has been * closed. al_poll_duh() might return nonzero if you have set * up a callback that tells the music to stop. */ if (al_poll_duh(dp) || closed) break; /* Give other threads a look-in, or allow the processor to * sleep for a bit. YIELD() is defined further up in this * file. */ YIELD(); } /* Remove the audio stream and deallocate the memory being used for * the playback state. We set dp to NULL to emphasise that the object * has gone. */ al_stop_duh(dp); dp = NULL; /* Free the DUH object containing the actual music data. */ unload_duh(duh); duh = NULL; /* All done! */ return EXIT_SUCCESS; }
string GuiField::updateFields() { FIELD_MASK *thisField = firstField; while (thisField != NULL) { if (thisField->displayed) { thisField->mouse_in = mouse.getMouseFocus(thisField->x, thisField->y, thisField->x + thisField->w, thisField->y + thisField->h); if (thisField->mouse_in) { if (mouse.getMouseLeftClick() == 0) { thisField->state = FIELD_ACTIVE; if (thisField->edittext == "0") { clearFieldText(thisField->ID); } } } else { if (mouse_b & 1) thisField->state = FIELD_INACTIVE; } if (thisField->state == FIELD_ACTIVE) { if (keypressed() && thisField->displayed && thisField->state == FIELD_ACTIVE) { int newkey = readkey(); char ASCII = newkey & 0xff; char scancode = newkey >> 8; if (ASCII >= 32 && ASCII <= 126) { if (thisField->caret < thisField->w/8) { if (thisField->insert || thisField->iter == thisField->edittext.end()) thisField->iter = thisField->edittext.insert(thisField->iter, ASCII); else thisField->edittext.replace(thisField->caret, 1, 1, ASCII); thisField->caret++; thisField->iter++; } } else switch (scancode) { case KEY_DEL: if (thisField->iter != thisField->edittext.end()) thisField->iter = thisField->edittext.erase(thisField->iter); break; case KEY_BACKSPACE: if (thisField->iter != thisField->edittext.begin()) { thisField->caret--; thisField->iter--; thisField->iter = thisField->edittext.erase(thisField->iter); } break; case KEY_RIGHT: if (thisField->iter != thisField->edittext.end()) thisField->caret++, thisField->iter++; break; case KEY_LEFT: if (thisField->iter != thisField->edittext.begin()) thisField->caret--, thisField->iter--; break; case KEY_INSERT: thisField->insert = !thisField->insert; break; case KEY_ENTER: return thisField->edittext; case KEY_TAB: if (thisField->next != NULL && thisField->next->displayed == true) { thisField->state = FIELD_INACTIVE; thisField->next->state = FIELD_ACTIVE; if (thisField->next->edittext == "0") { clearFieldText(thisField->next->ID); } } else { thisField->state = FIELD_INACTIVE; firstField->state = FIELD_ACTIVE; if (firstField->edittext == "0") { clearFieldText(firstField->ID); } } break; default: break; } } } }
void NinmanMenu::OptionMenu() { int y = 220; DrawOptionMenu(y); while (true) { readkey(); if (key[KEY_DOWN]) { y = y + 55; if (y > 440) y = 220; } if (key[KEY_UP]) { y = y - 55; if (y < 220) y = 440; } if (key[KEY_LEFT] || key[KEY_RIGHT]) { if (y == 220) { if (NinmanConfig::getFullScreenOption()) NinmanConfig::setFullScreenOption(false); else NinmanConfig::setFullScreenOption(true); if (NinmanConfig::getFullScreenOption()) set_gfx_mode(GFX_AUTODETECT, 800, 600, 0, 0); else set_gfx_mode(GFX_AUTODETECT_WINDOWED, 800, 600, 0, 0); } if (y == 275) { if (key[KEY_LEFT]) { NinmanConfig::setVolume(NinmanConfig::getVolume() - 25); } if (key[KEY_RIGHT]) { NinmanConfig::setVolume(NinmanConfig::getVolume() + 25); set_volume(NinmanConfig::getVolume(), 0); } set_volume(NinmanConfig::getVolume(), 0); } if (y == 330) { if (key[KEY_LEFT]) NinmanConfig::setNimanColor(-25); if (key[KEY_RIGHT]) NinmanConfig::setNimanColor(25); } if (y == 385) { if (key[KEY_LEFT]) NinmanConfig::setLab(-1); if (key[KEY_RIGHT]) NinmanConfig::setLab(1); } } if (key[KEY_ENTER]) { if (y == 440) break; } if (key[KEY_ESC]) break; DrawOptionMenu(y); } }
void startGame() { //allegro_init(); // Initialize Allegro //install_keyboard(); // Initialize keyboard routines //set_color_depth(16); // Set the color depth //set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, 1024,768,0,0); // Change our graphics mode to 1024x768 BITMAP *turret = NULL; //Declare a BITMAP called my_pic, setting it to NULL turret = load_bitmap("Tank.bmp", NULL); // Load our picture buffer = create_bitmap(1024,768); //Create an empty bitmap. BITMAP *bullet = NULL; bullet = load_bitmap("Bullet.bmp", NULL); BITMAP *redical = NULL; redical = load_bitmap("Redical.bmp", NULL); BITMAP *explosion = NULL; explosion = load_bitmap("Explosion.bmp", NULL); BITMAP *spider[4] = {NULL}; spider[0] = load_bitmap("Spider2.bmp", NULL); spider[1] = load_bitmap("Spider2.bmp", NULL); spider[2] = load_bitmap("Spider1.bmp", NULL); spider[3] = load_bitmap("Spider1.bmp", NULL); BITMAP *wheel = NULL; wheel = load_bitmap("Wheel.bmp", NULL); BITMAP *pierceBullet = NULL; pierceBullet = load_bitmap("PierceBullet.bmp", NULL); BITMAP *tank = NULL; tank = load_bitmap("Bullet.bmp", NULL); BITMAP *goldTurret = NULL; goldTurret = load_bitmap("InvincibleTurret.bmp", NULL); BITMAP *star = NULL; star = load_bitmap("Star.bmp", NULL); BITMAP *background; background = load_bitmap("Spider 3D.bmp", NULL); SAMPLE *spiderDeath = load_sample("Explosion.wav"); SAMPLE *ricochet1 = load_sample("Bullet Ricochet1.wav"); SAMPLE *ricochet2 = load_sample("Bullet Ricochet2.wav"); SAMPLE *ricochet3 = load_sample("Bullet Ricochet3.wav"); SAMPLE *ricochet4 = load_sample("Bullet Ricochet4.wav"); SAMPLE *ricochet5 = load_sample("Bullet Ricochet5.wav"); SAMPLE *ricochet6 = load_sample("Bullet Ricochet6.wav"); SAMPLE *ricochet7 = load_sample("Bullet Ricochet7.wav"); SAMPLE *ricochet8 = load_sample("Bullet Ricochet8.wav"); for (i = 0; i <= spiderNumber; i++) { spiderLives[i] = 2; } while(!key[KEY_ESC])//If the user hits escape, quit the program { while(playerIsDead != 1 && !key[KEY_ESC]) { score = score + 0.01; if (keypressed()) // If the user hits the space key, fire missile { nextKey = readkey(); } else { nextKey = -1; } switch ((nextKey & 0xff)) { case 'q': slowMo ^= 1; break; case 'o': respawns ^= 1; break; case 'w': bulletsPierce ^= 1; break; case 'e': sprayFire ^= 1; break; case 'r': bounceShot ^= 1; break; case 't': playerInvincible ^= 1; break; case 'y': playerCloak ^= 1; break; } if(mouse_b & 1) { fire(); play_sample(spiderDeath, 155, 0, 2000, 0); } bulletDelay++; if(bulletDelay >= fireSpeed) { bulletDelay = 0; } if(key[KEY_UP]) { vertMoveTank(0, speedModifier); } else if(key[KEY_DOWN]) { vertMoveTank(0, -speedModifier); } if(key[KEY_RIGHT]) { horzMoveTank(-speedModifier, 0); } if(key[KEY_LEFT]) { horzMoveTank(speedModifier, 0); } if (spiderMaker > 0 && spiderCounter < spiderNumber) { spiderSpawner = rand() % 4 + 1; if (spiderSpawner < 3) { spiderX[spiderCounter] = rand()%984; spiderY[spiderCounter] = rand()%2; if (spiderY[spiderCounter] == 1) { spiderY[spiderCounter] = 728; } else { spiderY[spiderCounter] = 0; } } if (spiderSpawner >= 3) { spiderY[spiderCounter] = rand()%728; spiderX[spiderCounter] = rand()%2; if (spiderX[spiderCounter] == 1) { spiderX[spiderCounter] = 984; } else { spiderX[spiderCounter] = 0; } } spiderCounter++; } for (i = 0; i <= spiderNumber; i++) { /*if (playerCloak) { spiderXVelocity[i] = 0.001*(500 - spiderX[i]) + rand() %10 - 4.5; spiderYVelocity[i] = 0.001*(350 - spiderY[i]) + rand() %10 - 4.5; } else { spiderXVelocity[i] = 0.003*(turretX - spiderX[i]) + rand() %10 - 4.5; spiderYVelocity[i] = 0.003*(turretY - spiderY[i]) + rand() %10 - 4.5; }*/ spiderXVelocity[i] = 0.003*(mouse_x - spiderX[i]) + rand() %10 - 4.5; spiderYVelocity[i] = 0.003*(mouse_y - spiderY[i]) + rand() %10 - 4.5; } for (i = 0; i <= spiderNumber; i++) { spiderX[i] = spiderX[i] + spiderXVelocity[i]; spiderY[i] = spiderY[i] + spiderYVelocity[i]; } for (i = 0; i <= bulletNumber; i++) { bulletX[i] = bulletX[i] + bulletXVelocity[i]; bulletY[i] = bulletY[i] + bulletYVelocity[i]; } clear_bitmap(buffer); // Clear the contents of the buffer bitmap draw_sprite(buffer, background, 0, 0); currentImage ++; if (currentImage == 4) { currentImage = 0; } for (i = 0; i <= bulletNumber; i++) { if (bulletIsDead[i] != 1) { if ((bulletX[i] > 10 && bulletX[i] < 1014 && bulletY[i] > 10 && bulletY[i] < 758) && bulletIsDead[i] != 1) { if (!bulletsPierce) { draw_sprite(buffer, bullet, bulletX[i], bulletY[i]); } else { draw_sprite(buffer, pierceBullet, bulletX[i], bulletY[i]); } } if (sprayFire) { for (j = 0; j <= spiderCounter; j++) { if (spiderIsDead[j] != 1 && (bulletX[i] > spiderX[j] && bulletX[i] < spiderX[j] + 40)) { if (spiderIsDead[j] != 1 && (bulletY[i] > spiderY[j] && bulletY[i] < spiderY[j] + 40)) { if (bulletsPierce == 0) { bulletIsDead[i] = 1; } draw_sprite(buffer, explosion, bulletX[i] - 30, bulletY[i] - 30); play_sample(spiderDeath, 155, 0, 1000, 0); spiderLives[j] = spiderLives[j] - 1; //if (spiderLives < 1) //{ spiderIsDead[j] = 1; //} } } } } if (!(bulletX[i] > 10 && bulletX[i] < 1000 && bulletY[i] > 10 && bulletY[i] < 748)) { if (!bounceShot) { draw_sprite(buffer, explosion, bulletX[i] - 25, bulletY[i] - 25); bulletIsDead[i] = 1; play_sample(spiderDeath, 255, 0, 1000, 0); } else bulletXVelocity[i] = -bulletXVelocity[i]; bulletYVelocity[i] = -bulletYVelocity[i]; j = rand() %7 + 1; switch (j) { case 1: play_sample(ricochet1, 255, 0, 1000, 0); break; case 2: play_sample(ricochet2, 255, 0, 1000, 0); break; case 3: play_sample(ricochet3, 255, 0, 1000, 0); break; case 4: play_sample(ricochet4, 255, 0, 1000, 0); break; case 5: play_sample(ricochet5, 255, 0, 1000, 0); break; case 6: play_sample(ricochet6, 255, 0, 1000, 0); break; case 7: play_sample(ricochet7, 255, 0, 1000, 0); break; case 8: play_sample(ricochet8, 255, 0, 1000, 0); break; } } } } if(respawns == 1) { for (i = 0; i <= spiderNumber; i++) { if (spiderIsDead[i] == 1) { spiderSpawner = rand() % 4 + 1; if (spiderSpawner < 3) { spiderX[i] = rand()%984; spiderY[i] = rand()%2; if (spiderY[i] == 1) { spiderY[i] = 728; } else { spiderY[i] = 0; } } if (spiderSpawner >= 3) { spiderY[i] = rand()%728; spiderX[i] = rand()%2; if (spiderX[i] == 1) { spiderX[i] = 984; } else { spiderX[i] = 0; } } spiderIsDead[i] = 0; } } } starSpinner = starSpinner + 0.1; if (starSpinner > 314) { starSpinner = 0; } if (playerInvincible != 0) { draw_sprite(buffer, goldTurret, turretX, turretY); draw_sprite(buffer, star, -35*cosf(starSpinner + 40) + turretX + 10, 35*sinf(starSpinner + 40) + turretY + 10); draw_sprite(buffer, star, -35*cosf(starSpinner - 40) + turretX + 10, 35*sinf(starSpinner - 40) + turretY + 10); draw_sprite(buffer, star, 35*cosf(starSpinner + 40) + turretX + 10, -35*sinf(starSpinner + 40) + turretY + 10); draw_sprite(buffer, star, 35*cosf(starSpinner - 40) + turretX + 10, -35*sinf(starSpinner - 40) + turretY + 10); } else { draw_sprite(buffer, turret, turretX, turretY); } //draw_sprite(buffer, redical, 100*cosf(turretRotation) + turretX, -100*sinf(turretRotation) + turretY); draw_sprite(buffer, redical, mouse_x - 10,mouse_y - 10); draw_sprite(buffer, wheel, -25*cosf(turretRotation + 45) + turretX + 15, 25*sinf(turretRotation + 45) + turretY + 15); draw_sprite(buffer, wheel, -25*cosf(turretRotation - 45) + turretX + 15, 25*sinf(turretRotation -45 ) + turretY + 15); draw_sprite(buffer, wheel, 25*cosf(turretRotation + 45) + turretX + 15, -25*sinf(turretRotation + 45) + turretY + 15); draw_sprite(buffer, wheel, 25*cosf(turretRotation - 45) + turretX + 15, -25*sinf(turretRotation - 45 ) + turretY + 15); if (slowMo != 0) { sleep(6); } for (j = 0; j <= spiderCounter; j++) { if (spiderIsDead[j] != 1 && (turretX + 20 > spiderX[j] && turretX + 20 < spiderX[j] + 40)) { if (spiderIsDead[j] != 1 && (turretY + 20 > spiderY[j] && turretY + 20 < spiderY[j] + 40)) { if (playerInvincible != 1) { playerLose(); sleep(2000); readkey(); return; } else { spiderIsDead[j] = 1; draw_sprite(buffer, explosion, spiderX[j], spiderY[j]); score = score + 2; play_sample(spiderDeath, 255, 0, 1000, 0); } } } } for (i = 0; i <= spiderNumber; i++) { if (spiderIsDead[i] != 1) { draw_sprite(buffer, spider[currentImage], spiderX[i], spiderY[i]); } } blit(buffer, screen, 0,0,0,0,1024,768);//Draw the buffer to the screen } } return; // Exit with no errors }
int RunControlSettings() { static int index = 0; static int spy = 72; int done = 0, y, i; int err = 1; int editMode = 0; g_dirty = 1; while (!done) { // Parse input readkey(); if (parsekey(DINGOO_SELECT)) { editMode = 1; DrawText(gui_screen, ">>", 185, spy); g_dirty = 0; } if (!editMode) { if (parsekey(DINGOO_A)) { if (index == 4) { cm_menu[index].update(g_key); } } if (parsekey(DINGOO_B)) { //ERROR CHECKING int iBtn1 = -1; int iBtn2 = -1; err = 1; for ( int i = 0; i < 4; i++ ) { for ( int y = 0; y < 4; y++ ) { g_config->getOption(cm_menu[i].option, &iBtn1); if (i != y) { g_config->getOption(cm_menu[y].option, &iBtn2); if (iBtn1 == iBtn2) { err = 0; g_dirty = 1; } } } } done= err; } } if ( !editMode ) { if (parsekey(DINGOO_UP, 1)) { if (index > 0) { index--; spy -= 15; } else { index = CONTROL_MENUSIZE - 1; spy = 72 + 15*index; } } if (parsekey(DINGOO_DOWN, 1)) { if (index < CONTROL_MENUSIZE - 1) { index++; spy += 15; } else { index = 0; spy = 72; } } } if ( editMode ) { if (parsekey(DINGOO_A, 0) || parsekey(DINGOO_B, 0) || parsekey(DINGOO_X, 0) || parsekey(DINGOO_Y, 0)) { cm_menu[index].update(g_key); g_dirty = 1; editMode = 0; } } // Draw stuff if( g_dirty ) { draw_bg(g_bg); //Draw Top and Bottom Bars DrawChar(gui_screen, SP_SELECTOR, 0, 37); DrawChar(gui_screen, SP_SELECTOR, 81, 37); DrawChar(gui_screen, SP_SELECTOR, 0, 225); DrawChar(gui_screen, SP_SELECTOR, 81, 225); DrawText(gui_screen, "B - Go Back", 235, 225); DrawChar(gui_screen, SP_LOGO, 12, 9); // Draw selector DrawChar(gui_screen, SP_SELECTOR, 56, spy); DrawChar(gui_screen, SP_SELECTOR, 77, spy); if (err == 0) { DrawText(gui_screen, "!!!Error - Duplicate Key Mapping!!! ", 8, 37); } else { DrawText(gui_screen, "Control Settings - Press select to edit", 8, 37); } // Draw menu for(i=0,y=72;i < CONTROL_MENUSIZE;i++,y+=15) { int iBtnVal = -1; char cBtn[32]; DrawText(gui_screen, cm_menu[i].name, 60, y); g_config->getOption(cm_menu[i].option, &iBtnVal); if (i == CONTROL_MENUSIZE-1) sprintf(cBtn, "%s", ""); else if (iBtnVal == DefaultGamePad[0][0]) sprintf(cBtn, "%s", "GCW_A"); else if (iBtnVal == DefaultGamePad[0][1]) sprintf(cBtn, "%s", "GCW_B"); else if (iBtnVal == DefaultGamePad[0][8]) sprintf(cBtn, "%s", "GCW_Y"); else if (iBtnVal == DefaultGamePad[0][9]) sprintf(cBtn, "%s", "GCW_X"); else sprintf(cBtn, "%s", "<empty>"); DrawText(gui_screen, cBtn, 210, y); } // Draw info DrawText(gui_screen, cm_menu[index].info, 8, 225); g_dirty = 0; } SDL_Delay(16); // Update real screen FCEUGUI_Flip(); } // Clear screen dingoo_clear_video(); g_dirty = 1; return 0; }
void toMenu() { BITMAP *menuBuffer = NULL; menuBuffer = create_bitmap(1024,768); //Create an empty bitmap. BITMAP *menuBackground = NULL; menuBackground = load_bitmap("Menu Background.bmp", NULL); // Load our picture BITMAP *highlighter = NULL; highlighter = load_bitmap("Menu Highlighter.bmp", NULL); // Load our picture BITMAP *smoke = NULL; smoke = load_bitmap("Menu Smoke.bmp", NULL); // Load our picture MIDI *menuMusic = NULL; menuMusic = load_midi("Soundtrack1.mid"); SAMPLE *menuClick = load_sample("Click.wav"); clear_bitmap(menuBuffer); // Clear the contents of the buffer bitmap int highlightedOption = 1; int inMenu = 1; int smokePosition = 1024; int smokePosition2 = 1024; draw_sprite(menuBuffer, menuBackground, 0, 0); draw_sprite(menuBuffer, highlighter, 6, 186); blit(menuBuffer, screen, 0,0,0,0,1024,768);//Draw the buffer to the screen play_midi(menuMusic, 1); while (inMenu == 1) { draw_sprite(menuBuffer, menuBackground, 0, 0); smokePosition --; smokePosition2 -= 3; if (smokePosition <= -1024) { smokePosition = 0; } readkey(); if(key[KEY_UP]) { play_sample(menuClick, 155, 0, 2000, 0); highlightedOption--; if (highlightedOption <= 0) { highlightedOption = 5; } } else if(key[KEY_DOWN]) { play_sample(menuClick, 155, 0, 2000, 0); highlightedOption++; if (highlightedOption >= 6) { highlightedOption = 1; } } else if(key[KEY_ENTER]) { play_sample(menuClick, 155, 0, 4000, 0); switch (highlightedOption) { case 1: isXenoPatriots = selectRace(); newGame(); startGame(); play_midi(menuMusic, 1); break; case 2: loadGame(); break; case 3: gameOptions(); break; case 4: break; case 5: quitGame(); inMenu ^= 0; return; break; } } switch (highlightedOption) { case 1: draw_sprite(menuBuffer, highlighter, 6, 186); break; case 2: draw_sprite(menuBuffer, highlighter, 6, 278); break; case 3: draw_sprite(menuBuffer, highlighter, 6, 373); break; case 4: draw_sprite(menuBuffer, highlighter, 6, 465); break; case 5: draw_sprite(menuBuffer, highlighter, 6, 629); break; } /*draw_sprite(menuBuffer, smoke, smokePosition, 0); draw_sprite(menuBuffer, smoke, smokePosition + 1024, 0); draw_sprite(menuBuffer, smoke, smokePosition2, 0); draw_sprite(menuBuffer, smoke, smokePosition2 + 1024, 0);*/ blit(menuBuffer, screen, 0,0,0,0,1024,768);//Draw the buffer to the screen } }
void colisao(){ int i = 0; int x = -50.0; int y = yini - 50.0; int k = 0; float l = 15.0; int m = 0; score += 100; explosao2(); winner(); blit(buffer, screen, 0,0,0,0,1280,720); //Limpa a tela clear_bitmap(buffer); //Limpa a tela draw_sprite(buffer, background[back], 0, 0); //Coloca a imagem na tela draw_sprite(screen, nave[e], xnave[e],ynave[e]); //Põe a nave na tela while (!key[KEY_ENTER]){ readkey(); textout(screen, font, "Acertou a nave desprotegida! Tecle 'Enter' para continuar", 400,350, makecol(255,0,0 ) ); char txt[15]; sprintf(txt,"x + %d = %d", b, a); //Inicializa o texto char txt2[15]; sprintf(txt2,"Pontos = %d", score); //Inicializa o texto textout(screen,font,txt,600,450,makecol(255,0,0)); //Exibe o texto textout(screen,font,txt2,5,5,makecol(255,0,0)); //Exibe o texto if (score == 300){ nivel = 2.0; textout(screen, font, "Nivel 2", 600,365, makecol(255,0,0 ) ); back = 1; } if (score == 500){ nivel = 4.0; textout(screen, font, "Nivel 3", 600,365, makecol(255,0,0 ) ); back = 2; } if (score == 600){ nivel = 5.0; textout(screen, font, "Nivel 4", 600,365, makecol(255,0,0 ) ); back = 3; } if (score == 700){ nivel = 6.0; textout(screen, font, "Nivel 5", 600,365, makecol(255,0,0 ) ); back = 4; } if (score == 800){ nivel = 10.0; textout(screen, font, "Nivel 6", 600,365, makecol(255,0,0 ) ); back = 5; } if (score == 900){ nivel = 16.0; textout(screen, font, "Nivel 7", 600,365, makecol(255,0,0 ) ); back = 6; } if (score == 1000){ nivel = 20.0; textout(screen, font, "Nivel MAX", 600,365, makecol(255,0,0 ) ); back = 7; } } equacao(); yini = 40.0; c = 0; }
void InputDeviceSingleton::BeginJoystickCalibration() { int msgColor = makecol(255, 255, 255); int bgColor = makecol(0, 0, 255); // for each joystick, run a calibration sequence for (int index = 0; index < num_joysticks; index++) { // clear the screen clear_to_color(screen, bgColor); // while the jostick needs to be calibrated while (joy[index].flags & JOYFLAG_CALIBRATE) { // get the calibration message const char* message = calibrate_joystick_name(index); // show the message on the screen textprintf_centre_ex(screen, font, SCREEN_W / 2, SCREEN_H / 2, msgColor, -1, "%s, and press a key.", message); // read a key readkey(); // try to calibrate the joystick if (0 != calibrate_joystick(index)) { // show a message that we failed textprintf_centre_ex(screen, font, SCREEN_W / 2, 64 + (SCREEN_H / 2), msgColor, -1, "Could not calibrate the Joystick!"); // read a key readkey(); // and bail with a fatal error LogFatal("Could not calibrate the joystick!"); } } } // try to save the calibration data to a file if (0 != save_joystick_data("joysettings.dat")) { // clear the screen to red clear_to_color(screen, makecol(255, 0, 0)); // show a message on the screen textprintf_centre_ex(screen, font, SCREEN_W / 2, SCREEN_H / 2, makecol(255, 255, 0), -1, "Joystick Calibration data file could not be saved! Press a key to exit the program."); // read a key readkey(); LogFatal("Joystick Calibration data file could not be saved! Program will now exit!"); } // clear the screen clear_to_color(screen, bgColor); // show a message on the screen textprintf_centre_ex(screen, font, SCREEN_W / 2, SCREEN_H / 2, msgColor, -1, "Joysticks have been calibrated. Press a key to exit the program."); // read a key readkey(); // log a message that the joysticks were calibrated LogMessage("Joysticks calibrated! Program Exiting..."); exit(1); }