void display(void) { lPosition(); /////////////////////////////////////////////////////////////////////////////////////////////////////// glClear (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glColor3f (1.0, 1.0, 1.0); glTexGeni(GL_S,GL_TEXTURE_GEN_MODE,GL_OBJECT_LINEAR); //Texturing Contour Anchored To The Object glTexGeni(GL_T,GL_TEXTURE_GEN_MODE,GL_OBJECT_LINEAR); //Texturing Contour Anchored To The Object //glEnable(GL_TEXTURE_GEN_S); //Auto Texture Generation //glEnable(GL_TEXTURE_GEN_T); //Auto Texture Generation glEnable(GL_TEXTURE_2D); /////////////////////////////////////////////////////////////////////////////////////////////////////// stars(); //glBindTexture(GL_TEXTURE_2D, g_cactus[1]); //gluSphere(g_text,0.4,48,48); stars(); sun(); adam(); hesper(); earth(); mars(); jupiter(); saturn(); uranus(); neptune(); /////////////////////////////////////////////////////////////////////////////////////////////////////// glDisable(GL_TEXTURE_2D); //glDisable(GL_TEXTURE_GEN_S); //Auto Texture Generation //glDisable(GL_TEXTURE_GEN_T); glutSwapBuffers(); }
/* Main program*/ int main() { int x; for (x=0;x<100;x++) { int i=0, numSpaces=13, numstars=1, count=0; printf("\007"); for (i=0;i<13;i++) { Space(numSpaces); stars(numstars,count); cout << endl; numSpaces--; numstars+=2 ; } for (i=14;i<16;i++) { Space(numSpaces=11); cout<< '|'; Space(numSpaces=4); cout<< '|'<<endl; } cout<< " MERRY"; count++; getch(); clrscr(); printf ("\a"); int y=0; for (numSpaces=12; numSpaces >= 0; numSpaces--) { Space(numSpaces); cout << '/'; stars(25 - 2*(numSpaces),count); cout << '\\' << endl; } for (i=14;i<16;i++) { Space(numSpaces=11); cout<< '|'; Space(numSpaces=4); cout<< '|'<<endl; } cout<< " CHRISTMAS"; printf ("\a"); getch(); clrscr(); } }
FRAGMENT(JSString, simple) { AutoSuppressHazardsForTest noanalysis; JS::Rooted<JSString*> empty(cx, JS_NewStringCopyN(cx, nullptr, 0)); JS::Rooted<JSString*> x(cx, JS_NewStringCopyN(cx, "x", 1)); JS::Rooted<JSString*> z(cx, JS_NewStringCopyZ(cx, "z")); // I expect this will be a non-inlined string. JS::Rooted<JSString*> stars(cx, JS_NewStringCopyZ(cx, "*************************" "*************************" "*************************" "*************************")); // This may well be an inlined string. JS::Rooted<JSString*> xz(cx, JS_ConcatStrings(cx, x, z)); // This will probably be a rope. JS::Rooted<JSString*> doubleStars(cx, JS_ConcatStrings(cx, stars, stars)); // Ensure we're not confused by typedefs for pointer types. JSString* xRaw = x; breakpoint(); use(empty); use(x); use(z); use(stars); use(xz); use(doubleStars); use(xRaw); }
// CONSTRUCTORS explicit StatsReport(std::ofstream* aofp) : os(*aofp) { header(); sumit(); stars(); stages(); }
void intro() { glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); stars(); glPushMatrix(); glTranslatef(-6, 1, 0); glRotatef(kd->theta, 0, 1, 0); kd->koch(4, 2); glPopMatrix(); glColor3f(0, 1, 1); p->printw(-3, 4, "Welcome to RFD : Revenge of fractal dimensions."); p->printw(-3.5, 3, "For many years we tried to contact the aliens, but we lost hope."); p->printw(-2.5, 2, "We did expect them to be hostile though."); p->printw(-4.5, 1, "We were unable to see them because they were lurking in fractal dimensions."); p->printw(-4.5, 0, "They revealed themselves dramatically, but we... we are prepared to fight them."); p->printw(-4.5, -1, "Be Captain Manyu and save us from the fractal monsters of planet Kochus."); p->printw(-4.5, -2, "Use space to shoot and use left and right arrows to move when the game starts."); p->printw(-2, -3, "Press c to start the game."); p->printw(-2.5, -4, "Feel free to quit at any time by hitting q."); glFlush(); glutSwapBuffers(); }
static void print_hist(int fd) { int key; long value; long data[MAX_INDEX] = {}; char starstr[MAX_STARS]; int i; int max_ind = -1; long max_value = 0; for (key = 0; key < MAX_INDEX; key++) { bpf_lookup_elem(fd, &key, &value); data[key] = value; if (value && key > max_ind) max_ind = key; if (value > max_value) max_value = value; } printf(" syscall write() stats\n"); printf(" byte_size : count distribution\n"); for (i = 1; i <= max_ind + 1; i++) { stars(starstr, data[i - 1], max_value, MAX_STARS); printf("%8ld -> %-8ld : %-8ld |%-*s|\n", (1l << i) >> 1, (1l << i) - 1, data[i - 1], MAX_STARS, starstr); } }
void testDefaultConstructor() { std::string stars("********"); std::string message("Test Default Constructor"); std::cout << stars << message << stars << std::endl; Point p1;//create point by its default constructor Point p2; //display points std::cout << "P1 = ( " << p1 << "," << p1 << ")" << std::endl; std::cout << "P2 = (" << p2 << "," << p2 << ")" << std::endl; //overwrite points using interface member funcitons, then redisplay p1.SetX(1.1); p1.SetY(2.1); p2.SetX(-1.1); p2.SetY(-2.2); std::cout << "P1 = (" << p1 << "," << p1 << ")" << std::endl; std::cout << "P2 = ( " << p2 << "," << p2 << ")" << std::endl; }
FRAGMENT(JSString, simple) { js::Rooted<JSString *> empty(cx, JS_NewStringCopyN(cx, NULL, 0)); js::Rooted<JSString *> x(cx, JS_NewStringCopyN(cx, "x", 1)); js::Rooted<JSString *> z(cx, JS_NewStringCopyZ(cx, "z")); // I expect this will be a non-inlined string. js::Rooted<JSString *> stars(cx, JS_NewStringCopyZ(cx, "*************************" "*************************" "*************************" "*************************")); // This may well be an inlined string. js::Rooted<JSString *> xz(cx, JS_ConcatStrings(cx, x, z)); // This will probably be a rope. js::Rooted<JSString *> doubleStars(cx, JS_ConcatStrings(cx, stars, stars)); breakpoint(); (void) empty; (void) x; (void) z; (void) stars; (void) xz; (void) doubleStars; }
void testOtherConstructor() { std::string stars("*********"); std::string message("Test the other constructor"); Point p3(2, 3); std::cout << "x = ( " << p3 << ")" << " y = " << "(" << p3 << ")" << std::endl; }
void inicio() { int i, j; inicializa(); clearviewport(); stars(); for(i=0; i<10; i++) for(j=0; j<10; j++) bar(170+j*30,100+i*30,200+j*30,130+i*30); getch(); }
mat E_beta_binom(vec &beta_k, double sigma_k, double v0, double v1, double p, double t){ mat stars(beta_k.n_elem, 2); // Compute p_star vec dens1 = density_norm(beta_k, 0.0, sigma_k * sqrt(v1)); vec dens0 = density_norm(beta_k, 0.0, sigma_k * sqrt(v0)); stars.col(1) = pow(p*dens1, t); stars.col(1) /= (pow(p*dens1,t) + pow((1-p)*dens0, t)); // Compute d_star stars.col(0) = stars.col(1)/v1 + (1-stars.col(1))/v0; return stars; }
void main() { inicializa(); stars(); eme(100, 150, 200, 250, 300, 100, 200, 250, 300, 5, LIGHTGRAY); getch(); clearviewport(); cruz(100,150,200,250,300,100,150,200,250,300,5, WHITE); stars(); getch(); clearviewport(); stars(); cinco(250,300,350,100,150,200,250,300,350,8, RED); getch(); clearviewport(); stars(); penta(200,300,400,350,250,120,200,300,9,BLUE); getch(); clearviewport(); stars(); batman(100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 330, 340, 360, 380, 400, 420, 440, 460, 480, 500, 520, 540, 560, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 2, YELLOW); getch(); }
void endscreen() { glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); stars(); glColor3f(0, 1, 1); p->printw(-2, 0, hits, "Your score is "); p->printw(-2, -1, "Enter x to exit... "); glFlush(); glutSwapBuffers(); }
int main(int argc, char **argv) { int i; int hitme; char ch; prelim(); if (argc > 1) { // look for -f option if (strcmp(argv[1], "-f")== 0) { coordfixed = 1; argc--; argv++; } } if (argc > 1) { fromcommandline = 1; line[0] = '\0'; while (--argc > 0) { strcat(line, *(++argv)); strcat(line, " "); } } else fromcommandline = 0; while (TRUE) { /* Play a game */ setup(); if (alldone) { score(0); alldone = 0; } else makemoves(); skip(2); stars(); skip(1); if (tourn && alldone) { printf("Do you want your score recorded?"); if (ja()) { chew2(); freeze(FALSE); } } printf("Do you want to play again?"); if (!ja()) break; } skip(1); prout("May the Great Bird of the Galaxy roost upon your home planet."); return 0; }
int main(int argc, char **argv) { unsigned int nr_cpus = bpf_num_possible_cpus(); const char *map_filename = "/sys/fs/bpf/tc/globals/lwt_len_hist_map"; uint64_t values[nr_cpus], sum, max_value = 0, data[MAX_INDEX] = {}; uint64_t key = 0, next_key, max_key = 0; char starstr[MAX_STARS]; int i, map_fd; map_fd = bpf_obj_get(map_filename); if (map_fd < 0) { fprintf(stderr, "bpf_obj_get(%s): %s(%d)\n", map_filename, strerror(errno), errno); return -1; } while (bpf_map_get_next_key(map_fd, &key, &next_key) == 0) { if (next_key >= MAX_INDEX) { fprintf(stderr, "Key %lu out of bounds\n", next_key); continue; } bpf_map_lookup_elem(map_fd, &next_key, values); sum = 0; for (i = 0; i < nr_cpus; i++) sum += values[i]; data[next_key] = sum; if (sum && next_key > max_key) max_key = next_key; if (sum > max_value) max_value = sum; key = next_key; } for (i = 1; i <= max_key + 1; i++) { stars(starstr, data[i - 1], max_value, MAX_STARS); printf("%8ld -> %-8ld : %-8ld |%-*s|\n", (1l << i) >> 1, (1l << i) - 1, data[i - 1], MAX_STARS, starstr); } close(map_fd); return 0; }
static void gamescreen(void) { clrscr(); stars(); setbg(blue); setfg(white); moveto(1,24); printf(" [j] left [k] rotate [l] right [space] drop [p] pause [n] next [q] quit "); setbg(border); frect(40-WIDTH-2,1,40+WIDTH+1,HEIGHT+1); #define VIEWX 5 #define VIEWY 8 setbg(yellow); rect(VIEWX-3,VIEWY-2,VIEWX+8,VIEWY+5); rect(VIEWX-2,VIEWY-2,VIEWX+7,VIEWY+5); setbg(bg); frect(VIEWX-1, VIEWY-1, VIEWX+6, VIEWY+4); frect(40-WIDTH,1,40+WIDTH-1,HEIGHT); moveto(1,24); flush(); }
void Exporter<MeshType>::computePostfix() { std::ostringstream index; index.fill( '0' ); if (M_timeIndex % M_save == 0) { index << std::setw(M_timeIndexWidth) << ( M_timeIndex / M_save ); M_postfix = "." + index.str(); } else { // M_postfix = "*****"; std::string stars(""); for (UInt cc(0); cc<M_timeIndexWidth; ++cc) stars+="*"; M_postfix = stars; } ++M_timeIndex; }
void main() { char op; inicializa(); stars(); menu(); op=toupper(getch()); switch(op) { case 'I': inicio(); break; case 'D': outtextxy(300,300, "DIFICULTAD"); break; case 'C': outtextxy(300,300, "CREDITOS"); break; case 'S': outtextxy(300,300, "SALIR"); break; } getch(); }
main() { stars(NUMSTARS); getchar(); }//end main()
//Display function when lives are present void displayer() { int f1 = 0, f2 = 0; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glClearColor(0.0, 0.0, 0.0, 0.0); stars(); if (counter>0) { static int i = 0; p->printw(-6.5, 4.5, hits, "Hits"); p->printw(6, 4.5, counter, "Lives left"); g = i; glPushMatrix(); glRotatef(kd->theta, 0, 1, 0); kd->koch(g, choice); glPopMatrix(); d->defender(); for (int i = 0; i<sx; i++) { me[i]->drawshooter(); me[i]->shoot(); } kb->kochb(4, 3); kb1->kochb(4, 3); f1 = kb->attack(kb->position); f2 = kb1->attack(kb1->position); counterinc(); if (!f1) { kb->position = (d->def[0][0] + d->def[4][0]) / 2; posX = kb->position; } if (!f2) { kb1->position = 4 - kb->position; } glFlush(); glutSwapBuffers(); i++; if (i == s + 1) i = 0; } else { if (termer == 1) return; delete kd; delete kb; delete kb1; delete d; for (int i = 0; i<100; i++) delete me[i]; termer = 1; } if (hits == 30000 && counter>0)//Maximum score is predefined. { glutDestroyWindow(game1); game2 = glutCreateWindow("RFD : Revenge of Fractal Dimensions"); glutDisplayFunc(endscreen); glutSpecialFunc(specialkeys); glutIdleFunc(beingIdle); glutKeyboardFunc(keyboard); glutReshapeFunc(myReshape); glutMainLoop(); } }
int main(int argc, char **argv) { int spi_fd; int effect=EFFECT_RANDOM; if (argc>1) { if ((!strncmp(argv[1],"-h",2)) || (!strncmp(argv[1],"help",4))) { help(argv[0]); return 0; } if (!strncmp(argv[1],"bargraph_mannual",15)) { effect=EFFECT_BARGRAPH_MANUAL; } if (!strncmp(argv[1],"bargraph",8)) { effect=EFFECT_BARGRAPH; } if (!strncmp(argv[1],"disable",7)) { effect=EFFECT_DISABLE; } if (!strncmp(argv[1],"falling",7)) { effect=EFFECT_FALLING; } if (!strncmp(argv[1],"fish",4)) { effect=EFFECT_FISH; } if (!strncmp(argv[1],"gradient",8)) { effect=EFFECT_GRADIENT; } if (!strncmp(argv[1],"noise",5)) { effect=EFFECT_NOISE; } if (!strncmp(argv[1],"pulsar",6)) { effect=EFFECT_PULSAR; } if (!strncmp(argv[1],"rainbow",7)) { effect=EFFECT_RAINBOW; } if (!strncmp(argv[1],"stars",5)) { effect=EFFECT_STARS; } if (!strncmp(argv[1],"red_green",9)) { effect=EFFECT_RED_GREEN; } if (!strncmp(argv[1],"blue_yellow",11)) { effect=EFFECT_BLUE_YELLOW; } if (!strncmp(argv[1],"two_color_scroll",15)) { effect=EFFECT_TWO_COLOR_SCROLL; } if (!strncmp(argv[1],"scanner_blinky",14)) { effect=EFFECT_SCANNER_BLINKY; } else if (!strncmp(argv[1],"scanner_dual",12)) { effect=EFFECT_SCANNER_DUAL; } else if (!strncmp(argv[1],"scanner_random",14)) { effect=EFFECT_SCANNER_RANDOM; } else if (!strncmp(argv[1],"scanner",7)) { effect=EFFECT_SCANNER; } } spi_fd=lpd8806_init(); if (spi_fd<0) { exit(-1); } switch(effect) { case EFFECT_BARGRAPH: bargraph(spi_fd,argc>2?argv[2]:NULL, argc>3?argv[3]:NULL); break; case EFFECT_BARGRAPH_MANUAL: bargraph_manual(spi_fd,argc>2?argv[2]:NULL, argc>3?argv[3]:NULL); break; case EFFECT_DISABLE: disable(spi_fd); break; case EFFECT_FALLING: falling(spi_fd, argc>2?argv[2]:NULL, argc>2?argv[3]:NULL); break; case EFFECT_FISH: fish(spi_fd,argc>2?argv[2]:NULL); break; case EFFECT_GRADIENT: gradient(spi_fd,argc>2?argv[2]:NULL); break; case EFFECT_NOISE: noise(spi_fd); break; case EFFECT_PULSAR: pulsar(spi_fd,argc>2?argv[2]:NULL); break; case EFFECT_RAINBOW: rainbow(spi_fd); break; case EFFECT_STARS: stars(spi_fd,argc>2?argv[2]:NULL, argc>3?argv[3]:NULL); break; case EFFECT_TWO_COLOR_SCROLL: two_color_scroll(spi_fd, argc>2?argv[2]:NULL, argc>3?argv[3]:NULL, argc>4?argv[4]:NULL); break; case EFFECT_RED_GREEN: two_color_scroll(spi_fd, "red", "green", "1"); break; case EFFECT_BLUE_YELLOW: two_color_scroll(spi_fd, "blue", "yellow", "0"); break; case EFFECT_SCANNER: scanner(spi_fd,argc>2?argv[2]:NULL); break; case EFFECT_SCANNER_BLINKY: scanner_blinky(spi_fd); break; case EFFECT_SCANNER_DUAL: scanner_dual(spi_fd, argc>2?argv[2]:NULL, argc>3?argv[3]:NULL); break; case EFFECT_SCANNER_RANDOM: scanner_random(spi_fd); break; } lpd8806_close(spi_fd); return 0; }
/********************************************************** * * SUBROUTINE display() * * This is our main rendering subroutine, called each frame * *********************************************************/ void display(void) { int i; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // This clear the background color to dark blue width = glutGet(GLUT_WINDOW_WIDTH); height = glutGet(GLUT_WINDOW_HEIGHT); glWindowPos2i(width - 100, height - 15); if(enter && flag3) { SwitchGameplay(2); glFlush(); // This force the execution of OpenGL commands glutSwapBuffers(); // In double buffered mode we invert the positions of the visible buffer and the writing buffer return; } Print("Score: %d", score); if(over) { SwitchGameplay(1); glFlush(); // This force the execution of OpenGL commands glutSwapBuffers(); // In double buffered mode we invert the positions of the visible buffer and the writing buffer return; } // Erase the window and the depth buffer glClearColor(0,0.3,0.7,0); Background(3.5*dim); // draw space like looking texture gluPerspective(45.0f,(GLfloat)screen_width/(GLfloat)screen_height,10.0f,10000.0f); glMatrixMode(GL_MODELVIEW); // Modeling transformation glLoadIdentity(); // Initialize the model matrix as identity // Perspective - set eye position gluLookAt(Ex,Ey,Ez , Ox,Oy,Oz , Ux,Uy,Uz); for ( i = 0; i < NUM_STAR; i++ ) { stars(star[i].x, star[i].y, star[i].z, star[i].a, star[i].b, star[i].c); } // draw laser cannon if fired if(bullet == 1 && space == 1) { laser_bullet(bx,by,bz,5,5,400); } // check if spaceship is hit by enemy if(px > ex-40 && px < ex+40 && py > ey-40 && py < ey+40 && pz > ez-40 && pz < ez+40 ) { space = 0; CreateExplosion (); Mix_PlayMusic(blast,0); over = 1; enemy = 0; } // Check if spaceship hits the wall if(px >= wall_x-100 && px <= wall_x+100 && py >= wall_y-30 && py <= wall_y+10 && pz >= wall_z-100 && pz <= wall_z+100 ) { space = 0; CreateExplosion (); Mix_PlayMusic(blast,0); over = 1; } // gravity, check if the spaceship fell off the road if( (px > 200 || px < -200) ) { py -= 5; if( py < -40) { space = 0; gravity = 1; CreateExplosion (); Mix_PlayMusic(blast,0); over = 1; } } if(space) spaceship(px, py, pz, -90+up, side, 180,0.85,0.85,0.85); if(enemy == 1) spaceship(ex, ey, ez, -90, 0, 0,1,1,1); glLoadIdentity(); glTranslatef(fx,fy,fz); if (fuel > 0) { glPushMatrix (); glBegin (GL_POINTS); for (i = 0; i < NUM_PARTICLES; i++) { glColor3fv (particles[i].color); glVertex3fv (particles[i].position); } glEnd (); for (i = 0; i < NUM_DEBRIS; i++) { glPushMatrix (); glTranslatef (debris[i].position[0], debris[i].position[1], debris[i].position[2]); glRotatef (debris[i].orientation[0], 1.0, 0.0, 0.0); glRotatef (debris[i].orientation[1], 0.0, 1.0, 0.0); glRotatef (debris[i].orientation[2], 0.0, 0.0, 1.0); glScalef (debris[i].scale[0], debris[i].scale[1], debris[i].scale[2]); glBegin (GL_TRIANGLES); glColor3f(((float) rand ()) / ((float) RAND_MAX), ((float) rand ()) / ((float) RAND_MAX), 0.3); glVertex3f (0.0, 0.5, 0.0); glVertex3f (-0.25, 0.0, 0.0); glVertex3f (0.25, 0.0, 0.0); glEnd (); glPopMatrix (); } } Road(road_x, road_y, road_z); wall(wall_x, wall_y, wall_z); glFlush(); // This force the execution of OpenGL commands glutSwapBuffers(); // In double buffered mode we invert the positions of the visible buffer and the writing buffer flag3++; }
void search(void) { Obj2 *p, *q; int i, j; double t; for(i=0; objlst[i]; i++) { p = objlst[i]; if(p == &oshad) continue; t = rise(p, -.833); if(t >= 0.) event("%s rises at ", p->name, "", t, i==0? PTIME: PTIME|DARK); t = set(p, -.833); if(t >= 0.) event("%s sets at ", p->name, "", t, i==0? PTIME: PTIME|DARK); if(p == &osun) { for(j=0; j<4; j++) { t = solstice(j); if(t >= 0) event("%s at ", solstr[j], "", t, SIGNIF|PTIME); } for(j=0; bettab[j].beta!=0; j++) { t = betcross(bettab[j].beta); if(t >= 0) event("%s meeteeor shouwer", bettab[j].betstr, "", t, SIGNIF); } t = rise(p, -18); if(t >= 0) event("Twilight starts at ", "", "", t, PTIME); t = set(p, -18); if(t >= 0) event("Twilight ends at ", "", "", t, PTIME); } if(p == &omoon) for(j=0; j<NPTS; j++) { if(p->point[j].mag > .75 && p->point[j+1].mag < .25) event("New moon", "", "", 0, 0); if(p->point[j].mag <= .25 && p->point[j+1].mag > .25) event("First quarter moon", "", "", 0, 0); if(p->point[j].mag <= .50 && p->point[j+1].mag > .50) event("Full moon", "", "", 0, 0); if(p->point[j].mag <= .75 && p->point[j+1].mag > .75) event("Last quarter moon", "", "", 0, 0); } if(p == &omerc || p == &ovenus) { t = melong(p); if(t >= 0) { t = rise(p, 0) - rise(&osun, 0); if(t < 0) t += NPTS; if(t > NPTS) t -= NPTS; if(t > NPTS/2) event("Morning elongation of %s", p->name, "", 0, SIGNIF); else event("Evening elongation of %s", p->name, "", 0, SIGNIF); } } for(j=i; objlst[j]; j++) { if(i == j) continue; q = objlst[j]; if(p == &omoon || q == &omoon) { occult(p, q, 0); if(occ.t3 < 0) continue; if(p == &osun || q == &oshad) { if(occ.t1 >= 0) event("Partial eclipse of %s begins at ", p->name, "", occ.t1, SIGNIF|PTIME); if(occ.t2 >= 0) event("Total eclipse of %s begins at ", p->name, "", occ.t2, SIGNIF|PTIME); if(occ.t4 >= 0) event("Total eclipse of %s ends at ", p->name, "", occ.t4, SIGNIF|PTIME); if(occ.t5 >= 0) event("Partial eclipse of %s ends at ", p->name, "", occ.t5, SIGNIF|PTIME); } else { if(occ.t1 >= 0) event("Occultation of %s begins at ", q->name, "", occ.t1, SIGNIF|PTIME); if(occ.t5 >= 0) event("Occultation of %s ends at ", q->name, "", occ.t5, SIGNIF|PTIME); } continue; } if(p == &osun) { if(q != &omerc && q != &ovenus) continue; occult(p, q, -1); if(occ.t3 >= 0.) { if(occ.t1 >= 0) event("Transit of %s begins at ", q->name, "", occ.t1, SIGNIF|LIGHT|PTIME); if(occ.t5 >= 0) event("Transit of %s ends at ", q->name, "", occ.t5, SIGNIF|LIGHT|PTIME); } continue; } t = dist(&p->point[0], &q->point[0]); if(t > 5000) continue; event("%s is in the house of %s", p->name, q->name, 0, 0); } } if(flags['o']) stars(); if(flags['a']) satels(); evflush(); }
void snova(int insx, int insy) { int comdead, nqx, nqy, nsx, nsy, num, kldead, iscdead; int nrmdead, npdead; int insipient=0; nsx = insy; nsy = insy; if (insy== 0) { if (insx == 1) { /* NOVAMAX being used */ nqx = probecx; nqy = probecy; } else { int stars = 0; /* Scheduled supernova -- select star */ /* logic changed here so that we won't favor quadrants in top left of universe */ for (nqx = 1; nqx<=8; nqx++) { for (nqy = 1; nqy<=8; nqy++) { stars += d.galaxy[nqx][nqy] % 10; } } if (stars == 0) return; /* nothing to supernova exists */ num = Rand()*stars + 1; for (nqx = 1; nqx<=8; nqx++) { for (nqy = 1; nqy<=8; nqy++) { num -= d.galaxy[nqx][nqy] % 10; if (num <= 0) break; } if (num <=0) break; } #ifdef DEBUG if (idebug) { proutn("Super nova here?"); if (ja()==1) { nqx = quadx; nqy = quady; } } #endif } if (nqx != quady || nqy != quady || justin != 0) { /* it isn't here, or we just entered (treat as inroute) */ if (damage[DRADIO] == 0.0 || condit == IHDOCKED) { skip(1); proutn("Message from Starfleet Command Stardate "); cramf(d.date, 0, 1); skip(1); proutn(" Supernova in"); cramlc(1, nqx, nqy); prout("; caution advised."); } } else { /* we are in the quadrant! */ insipient = 1; num = Rand()* (d.galaxy[nqx][nqy]%10) + 1; for (nsx=1; nsx < 10; nsx++) { for (nsy=1; nsy < 10; nsy++) { if (quad[nsx][nsy]==IHSTAR) { num--; if (num==0) break; } } if (num==0) break; } } } else { insipient = 1; } if (insipient) { skip(1); prouts("***RED ALERT! RED ALERT!"); skip(1); proutn("***Incipient supernova detected at"); cramlc(2, nsx, nsy); skip(1); nqx = quadx; nqy = quady; if (square(nsx-sectx) + square(nsy-secty) <= 2.1) { proutn("Emergency override attempts t"); prouts("***************"); skip(1); stars(); alldone=1; } } /* destroy any Klingons in supernovaed quadrant */ num=d.galaxy[nqx][nqy]; kldead = num/100; comdead = iscdead = 0; if (nqx==d.isx && nqy == d.isy) { /* did in the Supercommander! */ d.nscrem = d.isx = d.isy = isatb = iscate = 0; iscdead = 1; future[FSCMOVE] = future[FSCDBAS] = 1e30; } d.remkl -= kldead; if (d.remcom) { int maxloop = d.remcom, l; for (l = 1; l <= maxloop; l++) { if (d.cx[l] == nqx && d.cy[l] == nqy) { d.cx[l] = d.cx[d.remcom]; d.cy[l] = d.cy[d.remcom]; d.cx[d.remcom] = d.cy[d.remcom] = 0; d.remcom--; kldead--; comdead++; if (d.remcom==0) future[FTBEAM] = 1e30; break; } } } /* destroy Romulans and planets in supernovaed quadrant */ num = d.newstuf[nqx][nqy]; d.newstuf[nqx][nqy] = 0; nrmdead = num/10; d.nromrem -= nrmdead; npdead = num - nrmdead*10; if (npdead) { int l; for (l = 1; l <= inplan; l++) if (d.plnets[l].x == nqx && d.plnets[l].y == nqy) { d.plnets[l] = nulplanet; } } /* Destroy any base in supernovaed quadrant */ if (d.rembase) { int maxloop = d.rembase, l; for (l = 1; l <= maxloop; l++) if (d.baseqx[l]==nqx && d.baseqy[l]==nqy) { d.baseqx[l] = d.baseqx[d.rembase]; d.baseqy[l] = d.baseqy[d.rembase]; d.baseqx[d.rembase] = d.baseqy[d.rembase] = 0; d.rembase--; break; } } /* If starship caused supernova, tally up destruction */ if (insx) { num = d.galaxy[nqx][nqy] % 100; d.starkl += num % 10; d.basekl += num/10; d.killk += kldead; d.killc += comdead; d.nromkl += nrmdead; d.nplankl += npdead; d.nsckill += iscdead; } /* mark supernova in galaxy and in star chart */ if ((quadx == nqx && quady == nqy) || damage[DRADIO] == 0 || condit == IHDOCKED) starch[nqx][nqy] = 1; d.galaxy[nqx][nqy] = 1000; /* If supernova destroys last klingons give special message */ if (d.remkl==0 && (nqx != quadx || nqy != quady)) { skip(2); if (insx == 0) prout("Lucky you!"); proutn("A supernova in"); cramlc(1, nqx, nqy); prout(" has just destroyed the last Klingons."); finish(FWON); return; } /* if some Klingons remain, continue or die in supernova */ if (alldone) finish(FSNOVAED); return; }
int main(int argc, char **argv) { int spi_fd; int effect=EFFECT_RANDOM; if (argc>1) { if (!strncmp(argv[1],"-h",2)) { help(argv[0]); return 0; } if (!strncmp(argv[1],"bargraph",8)) { effect=EFFECT_BARGRAPH; } if (!strncmp(argv[1],"rainbow",7)) { effect=EFFECT_RAINBOW; } if (!strncmp(argv[1],"stars",5)) { effect=EFFECT_STARS; } if (!strncmp(argv[1],"red_green",9)) { effect=EFFECT_RED_GREEN; } if (!strncmp(argv[1],"blue_yellow",11)) { effect=EFFECT_BLUE_YELLOW; } if (!strncmp(argv[1],"two_color_scroll",15)) { effect=EFFECT_TWO_COLOR_SCROLL; } } spi_fd=lpd8806_init(); if (spi_fd<0) { exit(-1); } switch(effect) { case EFFECT_BARGRAPH: bargraph(spi_fd,argc>2?argv[2]:NULL, argc>3?argv[3]:NULL); break; case EFFECT_RAINBOW: rainbow(spi_fd); break; case EFFECT_STARS: stars(spi_fd,argc>2?argv[2]:NULL, argc>3?argv[3]:NULL); break; case EFFECT_TWO_COLOR_SCROLL: two_color_scroll(spi_fd, argc>2?argv[2]:NULL, argc>3?argv[3]:NULL, argc>4?argv[4]:NULL); break; case EFFECT_RED_GREEN: two_color_scroll(spi_fd, "red", "green", "1"); break; case EFFECT_BLUE_YELLOW: two_color_scroll(spi_fd, "blue", "yellow", "0"); break; } lpd8806_close(spi_fd); return 0; }