int main(int argc, char *argv[]) { const char *filename = "2frame.y4m"; const int width = 360; const int height = 180; FILE *out = fopen(filename, "wb"); // Header. fprintf(out, "YUV4MPEG2 W%d H%d F24:1 Ip A1:1\n", width, height); // Blue frame. y4m *blue = newframe(width, height); fillframe(blue, 96, 224, 32); writeframe(blue, out); freeframe(blue); // Green frame. y4m *green = newframe(width, height); fillframe(green, 218, 32, 32); writeframe(green, out); freeframe(green); fclose(out); fprintf(stderr, "File written to %s.\n", filename); return 0; }
void linie_3d(int c,vecp v1p,vecp v2p){ int i; vec v1,v2; static int handle, initialized=0, maxnum=2000, aktnum=-1; static Gobject *linien,*linientmp; veq(v1,v1p);veq(v2,v2p); if (!initialized) { handle=getview3dhandle(); linien=malloc(maxnum*sizeof(Gobject)); for (i=0;i<maxnum;i++) il(i) initialized=1; } if (newframe(handle)) aktnum=-1; if (++aktnum>=maxnum){ linientmp=malloc(2*maxnum*sizeof(Gobject)); for (i=0;i<maxnum;i++)linientmp[i]=linien[i]; free(linien); linien=linientmp; for (i=maxnum;i<maxnum*2;i++) il(i) maxnum*=2; } linien[aktnum].van=c; veq(linien[aktnum].tva[0],mc2wc(v1)); veq(linien[aktnum].tva[1],mc2wc(v2)); veq(linien[aktnum].poswc,sm(0.5,vsum(linien[aktnum].tva[0], linien[aktnum].tva[1]))); insertGobject(&(linien[aktnum])); }
void einfache_flaeche_wc_3d(int c, vecp vr, vecp v0p, vecp v1p,vecp v2p,vecp v3p){ int i; static int handle, initialized=0, maxnum=1000, aktnum=-1; static Gobject *flaechen,*flaechentmp; if (!initialized) { handle=getview3dhandle(); flaechen=malloc(maxnum*sizeof(Gobject)); for (i=0;i<maxnum;i++) i_f(i) initialized=1; } if (newframe(handle)) aktnum=-1; if (++aktnum>=maxnum){ flaechentmp=malloc(2*maxnum*sizeof(Gobject)); for (i=0;i<maxnum;i++)flaechentmp[i]=flaechen[i]; free(flaechen); flaechen=flaechentmp; for (i=maxnum;i<maxnum*2;i++) i_f(i) maxnum*=2; } flaechen[aktnum].van=c; veq(flaechen[aktnum].poswc,vr); veq(flaechen[aktnum].tva[0],v0p); veq(flaechen[aktnum].tva[1],v1p); veq(flaechen[aktnum].tva[2],v2p); veq(flaechen[aktnum].tva[3],v3p); insertGobject(&(flaechen[aktnum])); }
void getinitials(void) { Sint4 k,i; newframe(); outtext("ENTER YOUR",100,70,3); outtext(" INITIALS",100,90,3); outtext("_ _ _",128,130,3); strcpy(scoreinit[0],"..."); killsound(); for (i=0;i<3;i++) { k=0; while (k==0) { k=getinitial(i*24+128,130); if (k==8 || k==127) { if (i>0) i--; k=0; } } if (k!=0) { gwrite(i*24+128,130,k,3); scoreinit[0][i]=k; } } for (i=0;i<20;i++) flashywait(15); setupsound(); gclear(); gpal(0); ginten(0); setretr(true); recputinit(scoreinit[0]); }
void endofgame(void) { Sint4 i; bool initflag=FALSE; for (i=0;i<diggers;i++) addscore(i,0); if (playing || !drfvalid) return; if (gauntlet) { cleartopline(); outtext("TIME UP",120,0,3); for (i=0;i<50 && !escape;i++) newframe(); outtext(" ",120,0,3); } for (i=curplayer;i<curplayer+diggers;i++) { scoret=scdat[i].score; if (scoret>scorehigh[11]) { gclear(); drawscores(); strcpy(pldispbuf,"PLAYER "); if (i==0) strcat(pldispbuf,"1"); else strcat(pldispbuf,"2"); outtext(pldispbuf,108,0,2); outtext(" NEW HIGH SCORE ",64,40,2); getinitials(); shufflehigh(); savescores(); initflag=TRUE; } } if (!initflag && !gauntlet) { cleartopline(); outtext("GAME OVER",104,0,3); for (i=0;i<50 && !escape;i++) newframe(); outtext(" ",104,0,3); setretr(TRUE); } }
void getinitials(void) { Sint4 k,i; #ifdef _WINDOWS pause_windows_sound_playback(); #endif newframe(); outtext("ENTER YOUR",100,70,3); outtext(" INITIALS",100,90,3); outtext("_ _ _",128,130,3); strcpy(scoreinit[0],"..."); killsound(); for (i=0;i<3;i++) { k=0; while (k==0) { k=getinitial(i*24+128,130); if (k==8 || k==127) { if (i>0) i--; k=0; } } if (k!=0) { gwrite(i*24+128,130,k,3); scoreinit[0][i]=k; } } for (i=0;i<20;i++) #ifdef _WINDOWS flashywait(2); #else flashywait(15); #endif setupsound(); gclear(); gpal(0); ginten(0); setretr(TRUE); recputinit(scoreinit[0]); #ifdef _WINDOWS resume_windows_sound_playback(); #endif }
void text_3d(int c,vecp v1p,vecp v2p,char *str,char *ref,double size){ int i; vec v1,v2,vnull={0.,0.,0.}; static int handle, initialized=0, maxnum=2000, aktnum=-1; static Gobject *texte,*textetmp; veq(v1,v1p); if (v2p!=NULL) veq(v2,v2p); if (!initialized) { handle=getview3dhandle(); texte=malloc(maxnum*sizeof(Gobject)); for (i=0;i<maxnum;i++) it(i) initialized=1; } if (newframe(handle)) aktnum=-1; if (++aktnum>=maxnum){ textetmp=malloc(2*maxnum*sizeof(Gobject)); for (i=0;i<maxnum;i++)textetmp[i]=texte[i]; free(texte); texte=textetmp; for (i=maxnum;i<maxnum*2;i++) it(i) maxnum*=2; } texte[aktnum].type=TEXTOBJECT; texte[aktnum].van=c; texte[aktnum].size=size; texte[aktnum].polygons=malloc(strlen(str)*sizeof(char)+1); sprintf((char *) texte[aktnum].polygons,"%s",str); texte[aktnum].transfv=(int *) ref; /* typecast to reuse pointer */ veq(texte[aktnum].poswc,mc2wc(v1)); if (v2p==NULL) veq(texte[aktnum].tva[0],vnull); else veq(texte[aktnum].tva[0],mc2wc(vsum(v2,v1))); insertGobject(&(texte[aktnum])); }
void dodigger(struct digger_draw_api *ddap) { int n; int16_t tdir; newframe(); if (gauntlet) { drawlives(ddap); if (cgtime<ftime) timeout=true; cgtime-=ftime; } for (n=curplayer;n<diggers+curplayer;n++) { if (digdat[n].bob.expsn!=0) drawexplosion(n); else updatefire(ddap, n); if (digvisible) { if (digdat[n].dob.alive) if (digdat[n].bagtime!=0) { tdir = digdat[n].dob.dir; digdat[n].dob.dir = digdat[n].mdir; drawdig(n); digdat[n].dob.dir = tdir; incpenalty(); digdat[n].bagtime--; } else updatedigger(ddap, n); else diggerdie(ddap, n); } if (digdat[n].emocttime>0) digdat[n].emocttime--; } if (bonusmode && isalive()) { if (bonustimeleft!=0) { bonustimeleft--; if (startbonustimeleft!=0 || bonustimeleft<20) { startbonustimeleft--; if (bonustimeleft&1) { ddap->ginten(0); soundbonus(); } else { ddap->ginten(1); soundbonus(); } if (startbonustimeleft==0) { music(0); soundbonusoff(); ddap->ginten(1); } } } else { endbonusmode(ddap); soundbonusoff(); music(1); } } if (bonusmode && !isalive()) { endbonusmode(ddap); soundbonusoff(); music(1); } }
void dodigger(void) { int n; newframe(); if (gauntlet) { drawlives(); if (cgtime<ftime) timeout=TRUE; cgtime-=ftime; } for (n=curplayer;n<diggers+curplayer;n++) { if (digdat[n].expsn!=0) drawexplosion(n); else updatefire(n); if (digvisible) if (digdat[n].alive) if (digdat[n].bagtime!=0) { drawdig(n,digdat[n].mdir,digdat[n].x,digdat[n].y, digdat[n].notfiring && digdat[n].rechargetime==0); incpenalty(); digdat[n].bagtime--; } else updatedigger(n); else diggerdie(n); if (digdat[n].emocttime>0) digdat[n].emocttime--; } if (bonusmode && isalive()) { if (bonustimeleft!=0) { bonustimeleft--; if (startbonustimeleft!=0 || bonustimeleft<20) { startbonustimeleft--; if (bonustimeleft&1) { ginten(0); soundbonus(); } else { ginten(1); soundbonus(); } if (startbonustimeleft==0) { music(0); soundbonusoff(); ginten(1); } } } else { endbonusmode(); soundbonusoff(); music(1); } } if (bonusmode && !isalive()) { endbonusmode(); soundbonusoff(); music(1); } }
int mainprog(void) { int16_t frame,t; struct monster_obj *nobbin, *hobbin; struct digger_obj odigger; struct obj_position newpos; loadscores(); escape=false; nobbin = NULL; hobbin = NULL; do { soundstop(); creatembspr(); detectjoy(); ddap->gclear(); ddap->gtitle(); outtext(ddap, "D I G G E R",100,0,3); shownplayers(); showtable(ddap); started=false; frame=0; newframe(); teststart(); while (!started) { started=teststart(); if ((akeypressed==27 || akeypressed=='n' || akeypressed=='N') && !gauntlet && diggers==1) { switchnplayers(); shownplayers(); akeypressed=0; } if (frame==0) for (t=54;t<174;t+=12) outtext(ddap, " ",164,t,0); if (frame==50) { if (nobbin != NULL) { CALL_METHOD(nobbin, dtor); } nobbin = monster_obj_ctor(0, MON_NOBBIN, DIR_LEFT, 292, 63); CALL_METHOD(nobbin, put); } if (frame>50 && frame<=77) { CALL_METHOD(nobbin, getpos, &newpos); newpos.x -= 4; if (frame == 77) { newpos.dir = DIR_RIGHT; } CALL_METHOD(nobbin, setpos, &newpos); } if (frame > 50) { CALL_METHOD(nobbin, animate); } if (frame==83) outtext(ddap, "NOBBIN",216,64,2); if (frame==90) { if (hobbin != NULL) { CALL_METHOD(hobbin, dtor); } hobbin = monster_obj_ctor(1, MON_NOBBIN, DIR_LEFT, 292, 82); CALL_METHOD(hobbin, put); } if (frame>90 && frame<=117) { CALL_METHOD(hobbin, getpos, &newpos); newpos.x -= 4; if (frame == 117) { newpos.dir = DIR_RIGHT; } CALL_METHOD(hobbin, setpos, &newpos); } if (frame == 100) { CALL_METHOD(hobbin, mutate); } if (frame > 90) { CALL_METHOD(hobbin, animate); } if (frame==123) outtext(ddap, "HOBBIN",216,83,2); if (frame==130) { digger_obj_init(&odigger, 0, DIR_LEFT, 292, 101); CALL_METHOD(&odigger, put); } if (frame>130 && frame<=157) { odigger.x -= 4; } if (frame>157) { odigger.dir = DIR_RIGHT; } if (frame >= 130) { CALL_METHOD(&odigger, animate); } if (frame==163) outtext(ddap, "DIGGER",216,102,2); if (frame==178) { movedrawspr(FIRSTBAG,184,120); drawgold(0,0,184,120); } if (frame==183) outtext(ddap, "GOLD",216,121,2); if (frame==198) drawemerald(184,141); if (frame==203) outtext(ddap, "EMERALD",216,140,2); if (frame==218) drawbonus(184,158); if (frame==223) outtext(ddap, "BONUS",216,159,2); if (frame == 235) { CALL_METHOD(nobbin, damage); } if (frame == 239) { CALL_METHOD(nobbin, kill); } if (frame == 242) { CALL_METHOD(hobbin, damage); } if (frame == 246) { CALL_METHOD(hobbin, kill); } newframe(); frame++; if (frame>250) frame=0; } if (savedrf) { if (gotgame) { recsavedrf(); gotgame=false; } savedrf=false; continue; } if (escape) break; recinit(); game(); gotgame=true; if (gotname) { recsavedrf(); gotgame=false; } savedrf=false; escape=false; } while (!escape); finish(); return 0; }
void game(void) { int16_t t,c,i; bool flashplayer=false; if (gauntlet) { cgtime=gtime*1193181l; timeout=false; } initlives(); gamedat[0].level=startlev; if (nplayers==2) gamedat[1].level=startlev; alldead=false; ddap->gclear(); curplayer=0; initlevel(); curplayer=1; initlevel(); zeroscores(); bonusvisible=true; if (nplayers==2) flashplayer=true; curplayer=0; while (getalllives()!=0 && !escape && !timeout) { while (!alldead && !escape && !timeout) { initmbspr(); if (playing) randv=playgetrand(); else randv=getlrt(); #ifdef INTDRF fprintf(info,"%lu\n",randv); frame=0; #endif recputrand(randv); if (levnotdrawn) { levnotdrawn=false; drawscreen(ddap); if (flashplayer) { flashplayer=false; strcpy(pldispbuf,"PLAYER "); if (curplayer==0) strcat(pldispbuf,"1"); else strcat(pldispbuf,"2"); cleartopline(); for (t=0;t<15;t++) for (c=1;c<=3;c++) { outtext(ddap, pldispbuf,108,0,c); writecurscore(ddap, c); newframe(); if (escape) return; } drawscores(ddap); for (i=0;i<diggers;i++) addscore(ddap, i,0); } } else initchars(); outtext(ddap, " ",108,0,3); initscores(ddap); drawlives(ddap); music(1); flushkeybuf(); for (i=0;i<diggers;i++) readdirect(i); while (!alldead && !gamedat[curplayer].levdone && !escape && !timeout) { penalty=0; dodigger(ddap); domonsters(ddap); dobags(ddap); if (penalty>8) incmont(penalty-8); testpause(); checklevdone(); } erasediggers(); musicoff(); t=20; while ((getnmovingbags()!=0 || t!=0) && !escape && !timeout) { if (t!=0) t--; penalty=0; dobags(ddap); dodigger(ddap); domonsters(ddap); if (penalty<8) t=0; } soundstop(); for (i=0;i<diggers;i++) killfire(i); erasebonus(ddap); cleanupbags(); savefield(); erasemonsters(); recputeol(); if (playing) playskipeol(); if (escape) recputeog(); if (gamedat[curplayer].levdone) soundlevdone(); if (countem()==0 || gamedat[curplayer].levdone) { #ifdef INTDRF fprintf(info,"%i\n",frame); #endif for (i=curplayer;i<diggers+curplayer;i++) if (getlives(i)>0 && !digalive(i)) declife(i); drawlives(ddap); gamedat[curplayer].level++; if (gamedat[curplayer].level>1000) gamedat[curplayer].level=1000; initlevel(); } else if (alldead) { #ifdef INTDRF fprintf(info,"%i\n",frame); #endif for (i=curplayer;i<curplayer+diggers;i++) if (getlives(i)>0) declife(i); drawlives(ddap); } if ((alldead && getalllives()==0 && !gauntlet && !escape) || timeout) endofgame(ddap); } alldead=false; if (nplayers==2 && getlives(1-curplayer)!=0) { curplayer=1-curplayer; flashplayer=levnotdrawn=true; } } #ifdef INTDRF fprintf(info,"-1\n%lu\n%i",getscore0(),gamedat[0].level); #endif }
int mainprog(void) { Sint4 frame,t,x; loadscores(); escape=false; do { soundstop(); creatembspr(); detectjoy(); gclear(); gtitle(); outtext("D I G G E R",100,0,3); shownplayers(); showtable(); started=false; frame=0; newframe(); teststart(); while (!started) { started=teststart(); if ((akeypressed==27 || akeypressed=='n' || akeypressed=='N') && !gauntlet && diggers==1) { switchnplayers(); shownplayers(); akeypressed=0; } if (frame==0) for (t=54;t<174;t+=12) outtext(" ",164,t,0); if (frame==50) { movedrawspr(FIRSTMONSTER,292,63); x=292; } if (frame>50 && frame<=77) { x-=4; drawmon(0,1,DIR_LEFT,x,63); } if (frame>77) drawmon(0,1,DIR_RIGHT,184,63); if (frame==83) outtext("NOBBIN",216,64,2); if (frame==90) { movedrawspr(FIRSTMONSTER+1,292,82); drawmon(1,0,DIR_LEFT,292,82); x=292; } if (frame>90 && frame<=117) { x-=4; drawmon(1,0,DIR_LEFT,x,82); } if (frame>117) drawmon(1,0,DIR_RIGHT,184,82); if (frame==123) outtext("HOBBIN",216,83,2); if (frame==130) { movedrawspr(FIRSTDIGGER,292,101); drawdigger(0,DIR_LEFT,292,101,1); x=292; } if (frame>130 && frame<=157) { x-=4; drawdigger(0,DIR_LEFT,x,101,1); } if (frame>157) drawdigger(0,DIR_RIGHT,184,101,1); if (frame==163) outtext("DIGGER",216,102,2); if (frame==178) { movedrawspr(FIRSTBAG,184,120); drawgold(0,0,184,120); } if (frame==183) outtext("GOLD",216,121,2); if (frame==198) drawemerald(184,141); if (frame==203) outtext("EMERALD",216,140,2); if (frame==218) drawbonus(184,158); if (frame==223) outtext("BONUS",216,159,2); newframe(); frame++; if (frame>250) frame=0; } if (savedrf) { if (gotgame) { recsavedrf(); gotgame=false; } savedrf=false; continue; } if (escape) break; recinit(); game(); gotgame=true; if (gotname) { recsavedrf(); gotgame=false; } savedrf=false; escape=false; } while (!escape); finish(); return 0; }