void swi_log_setlevel(swi_log_level_t level, const char *module, ...) { va_list ap; const char *mod = NULL; va_start(ap, module); if (module == NULL) { default_level = level; return; } newlevel(module, level); while((mod = va_arg(ap, const char *))) newlevel(mod, level); va_end(ap); }
/* * setup_system sets up some basics which are needed to use parts of the * interpreter. * This is a common routine of rexx's or regina's main() and every * SAA function. * isclient should be set to 1 if called from the SAA interface, 0 otherwise. * * Note that you have to set TSD->currlevel->script_exit as fast as possible. * Otherwise you are at high risk that an error will stop the whole process, * which is fatal if an application uses us via SAA API. */ void setup_system( tsd_t *TSD, int isclient ) { TSD->stddump = stderr; TSD->systeminfo = creat_sysinfo( TSD, Str_creTSD( "SYSTEM" ) ); TSD->systeminfo->currlevel0 = TSD->currlevel = newlevel( TSD, NULL ); TSD->systeminfo->trace_override = 0; TSD->isclient = isclient; }
int strategize () { dwait (D_CONTROL, "Strategizing..."); /* If replaying, instead of making an action, return the old one */ if (replaying) return (replaycommand ()); /* Clear any messages we printed last turn */ if (msgonscreen) { at (0,0); clrtoeol (); msgonscreen = 0; at (row,col); } /* ----------------------- Production Rules --------------------------- */ if (fightmonster ()) /* We are under attack! */ return (1); if (fightinvisible ()) /* Claude Raines! */ return (1); if (tomonster ()) /* Go play with the pretty monster */ return (1); if (shootindark ()) /* Shoot arrows in dark rooms */ return (1); if (handleweapon ()) /* Play with the nice sword */ { dwait (D_BATTLE, "Switching to sword [1]"); return (1); } if (light ()) /* Fiat lux! Especially if we lost */ return (1); /* a monster from view. */ if (dinnertime ()) /* Soups on! */ return (1); /* * These variables are short term memory. Slowed and * cancelled are fuses which are disabled after a small * number of turns. */ lyinginwait = 0; /* No more monsters to wait for */ if (foughtmonster) foughtmonster--; /* Turns since fought monster */ if (slowed) slowed--; /* Turns since we slowed a monster */ if (cancelled) cancelled--; /* Turns since we zapped 'cancel' */ if (beingheld) beingheld--; /* Turns since held by a fungus */ /* ---- End of short term memory modification ---- */ if (dropjunk ()) /* Send it back */ return (1); if (readscroll ()) /* Get out the reading glasses */ return (1); /* Must come before handlearmor() */ if (handlearmor ()) /* Play dressup */ return (1); if (quaffpotion ()) /* Glug glug glug ... */ return (1); /* Must come before handlering() */ if (handlering ()) /* We are engaged! */ return (1); if (blinded && grope (50)) /* Who turned out the lights */ { display ("Blinded, groping..."); return (1); } if (aftermelee ()) /* Wait for lingering monsters */ return (1); if (tostuff ()) /* Pick up the play pretty */ return (1); if (restup ()) /* Yawn! */ return (1); if (goupstairs (NOTRUNNING)) /* Up we go! Make sure that we get */ return (1); /* a better rank on the board. */ if (trywand ()) /* Try to use a wand */ return (1); if (gotowardsgoal ()) /* Keep on trucking */ return (1); if (exploreroom ()) /* Search the room */ return (1); if (archery ()) /* Try to position for fight */ return (1); if (pickupafter ()) /* Look for stuff dropped by arched mon */ return (1); if (plunge ()) /* Plunge mode */ return (1); if (findarrow ()) /* Do we have an unitialized arrow? */ return (1); if (findroom ()) /* Look for another room */ return (1); /* * 'attempt' records the number of times we have completely searched * this level for secret doors. If attempt is greater than 0, then we * have failed once to find the stairs and go down. If this happens * three times, there could be amonster sleeping on the stairs. We set * the SLEEPER bit for each square with a sleeping monster. Go find * such a monster and kill it to see whether (s)he was on the stairs). */ if (attempt > 4 && makemove (ATTACKSLEEP, genericinit, sleepvalue, REUSE)) { display ("No stairs, attacking sleeping monster..."); return (1); } if (Level>1 && larder>0 && doorexplore ()) /* Grub around */ return (1); if (godownstairs (NOTRUNNING)) /* Down we go! */ return (1); if ((Level<2 || larder<1) && doorexplore()) /* Grub around anyway */ return (1); /* * If we think we are on the stairs, but arent, maybe they were moved * (ie we were hallucinating when we saw them last time). */ if (on (STAIRS) && (atrow != stairrow || atcol != staircol)) { dwait (D_ERROR, "Stairs moved!"); findstairs (NONE, NONE); return (1); } /* * If we failed to find the stairs, explore each possible secret door * another ten times. */ while (attempt++ < MAXATTEMPTS) { timestosearch += max (3, k_door / 5); foundnew (); if (doorexplore ()) return (1); } /* * Don't give up, start all over! */ newlevel (); display ("I would give up, but I am too stubborn, starting over..."); return (grope (10)); }
static void initmenu(void) { // Allocate Menu Background backup. menuback = new Back(MENUXS, MENUYS); // Load menu screen. demoTexture.loadPointer(SDL_CreateTexture(render.getBase(), SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, HWXMAX, YMAX), true); clearmenu(); // Take a snapshot of the plain menu screen. menuback->save(MENUX, MENUY); // .. freeze overlapping part of Title. head = (Sprite *)loadfile("pic\\ravage.spr", NULL); sHead.load(head, false); // Load pointer. pointer = (Sprite *)loadfile("pic\\pointer.spr", NULL); sPointer.load(pointer, false); // Set mouse area. //setmouselimits(MENUX, MENUY, MENUX+MENUXS-pointer->xs, MENUY+MENUYS-pointer->ys); setmouselimits(-BORDER, 0, 320, 240); // Initialize POINTER animation buffer. back = new Back(pointer->xs, pointer->ys); // Set events to initial values. pointer_enabled = 1; keys_enabled = 0; joy_enabled = 0; // Several buttons & fonts. blue = new Font("fonts\\blue.fnt"); tiny = new Font("fonts\\tiny.fnt"); addsub = (Sprite *)loadfile("pic\\addsub.spr", NULL); sAddSub.load(addsub, false); yesno = (Sprite *)loadfile("pic\\yesno.spr", NULL); sYesNo.load(yesno, false); // Write version information. #ifdef SHAREWARE tiny->vanilla(215, 65, "shareware 1.1", 10); #else tiny->vanilla(215, 65, "registered 1.1", 10); #endif // Save current game state in case the menu is in SHOP mode. gsave = gstate; psave = player[nowplayer]; psave2 = player[1-nowplayer]; player[1-nowplayer].active = 0; // Deactivate unused player. // Initialize DEMO GAME. cheatsave = cheatlevel; cheatlevel |= CHEAT_INVUL | CHEAT_NOMONEY; playback_start("demo1\\demo1.rec"); player[nowplayer].control = playback_device; gstate.nplayers = 1; gstate.difficulty = 3; newgame(1); newlevel("demo1\\demo1"); weapon_releaseall(nowplayer, STARTX1, STARTY); // Start playing background music. s_loadmod("mods\\menu.uni"); s_startmod(); // Fade In fadein(level.palette); }
int main(int argc, char* argv[]) { SDL_Init(SDL_INIT_EVERYTHING); SDL_Window *window = SDL_CreateWindow("Bloxz", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 480, 480.f/(320.f/480.f), SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_SHOWN); SDL_GL_CreateContext(window); bool done = 0; init(); int start = SDL_GetTicks(); while (!done) { SDL_Event e; while (SDL_PollEvent(&e)) { switch (e.type) { case SDL_QUIT: done = 1; break; case SDL_KEYDOWN: if (e.key.keysym.sym == SDLK_ESCAPE) done = 1; else if (menu == 2) { if (e.key.keysym.sym == SDLK_BACKSPACE) { name[--nameat] = 0; } if (e.key.keysym.sym == SDLK_RETURN) { menu = 1; playername = new char(strlen(name) + 2); strcpy(playername, name); addHighscore(); newlevel(); } else if (e.key.keysym.sym < 128 && e.key.keysym.sym>=32) { name[nameat++] = e.key.keysym.sym; name[nameat] = 0; } } break; case SDL_MOUSEBUTTONDOWN: { if (firing) break;; vec2 point(e.button.x, e.button.y); if (point.x<32 || point.x>320 - 32) { tx = -1; ty = (point.y - 30) / 32; } else if (point.y<62 || (point.y>316 && point.y < 390)) { ty = -1; tx = (point.x) / 32; } else { tx = ty = -1; } if (tx == 0 || tx == 9) tx = -1; if (ty == 0 || ty == 9) ty = -1; tim = 0; } break; case SDL_MOUSEMOTION: if (e.motion.state) { if (firing) break; vec2 point(e.motion.x, e.motion.y); if (point.x<32 || point.x>320 - 32) { tx = -1; ty = (point.y - 30) / 32; } else if (point.y<62 || (point.y>316 && point.y < 390)) { ty = -1; tx = (point.x) / 32; } else { tx = ty = -1; } if (tx == 0 || tx == 9) tx = -1; if (ty == 0 || ty == 9) ty = -1; } break; case SDL_MOUSEBUTTONUP: { if (firing) break; vec2 point(e.button.x, e.button.y); if (menu == 0) { if (point.x<32 && point.y>62 && point.y<316) fire(3, (point.y - 30) / 32, point.x); else if (point.x>32 * 9 && point.y > 62 && point.y<316) fire(1, (point.y - 30) / 32, point.x); if (point.y<62 && point.x>32 && point.x<316) fire(0, point.x / 32, point.y); else if (point.y>316 && point.x>32 && point.x < 32 * 9 && point.y<390) fire(2, point.x / 32, point.y); if (point.x<26 && point.y>454) { menu = 1; } } else if (menu == 1) { if (point.x>160 && gamemode != 0) menu = 0; else { if (point.y<330 && point.y>160) { menu = 0; if (point.y < 225) gamemode = 1; else if (point.y<280) gamemode = 2; else gamemode = 3; newlevel(); } if (point.y>360 && point.y<405) menu = 3; if (point.y>415 && point.y<465) { menu = 5; hst = 0; } } } else if (menu == 2) { if (point.y>320) { // if (textbox == nil) menu = 1; playername = new char(strlen(name) + 2); strcpy(playername, name); addHighscore(); newlevel(); } } else if (menu == 3) { if (point.x > 16 && point.x<48 && point.y>445 && point.y < 477) { hst--; if (hst<0) hst = 2; } else if (point.x>272 && point.x<304 && point.y>445 && point.y<477) { hst++; if (hst>2) hst = 0; } else if (point.x > 128 && point.x<192 && point.y>445 && point.y < 477) { menu = 1; } } else if (menu == 4)//gameover { name[0] = 0; strcpy(name, playername); nameat = strlen(name); menu = 2; } else if (menu == 5)//high { if (point.x<26 && point.y>454) { menu = 1; } else { hst++; if (hst > 7) menu = 1; } } printf("%f,%f\n", point.x, point.y); tx = ty = -1; } break; } } update(); SDL_GL_SwapWindow(window); int elapsed = (SDL_GetTicks() - start); SDL_Delay(max(0, 17 - elapsed)); start = SDL_GetTicks(); } saveHighscore(); SDL_Quit(); return 0; }