AcctRegSetDftEntry("TempleOS/BugBird","F64 best_score=9999;\n"); AcctRegExeBranch("TempleOS/BugBird"); $SP,"<1>",BI=1$ $SP,"<2>",BI=2$ $SP,"<3>",BI=3$ $SP,"<4>",BI=4$ #define BORDER 5 #define EAT_TIME 0.5 #define FLAP_TIME 0.5 #define BIRD_BOX 10 Bool flap_down,flap_up,game_reset; F64 flap_phase,bird_y,bird_x,eat_timeout,flap_time; F64 frame_x,game_t0,game_tf; #define MAX_BUGS 32 I32 bug_cnt,bugs_x[MAX_BUGS],bugs_y[MAX_BUGS]; Bool bugs_dead[MAX_BUGS]; U0 DrawIt(CTask *task,CDC *dc) { I64 i,y,x, h=MaxI64(1,task->pix_width-2*BORDER), v=MaxI64(1,task->pix_height-2*BORDER); CSprite *temps,*temps2,*temps3; F64 tt=flap_phase*flap_phase*flap_phase; temps=SpriteInterpolate($IB,"<1>",BI=1$,$IB,"<2>",BI=2$,tt); if (eat_timeout && tS",BI=3$,$IB,"<4>",BI=4$,tt); temps3=SpriteInterpolate(temps2,temps,1.0-(eat_timeout-tS)/EAT_TIME); Free(temps); Free(temps2); temps=temps3; } Sprite3(dc,bird_x,bird_y,0,temps); Free(temps); for (i=0;icolor=BLACK; GrPlot(dc,x,y); GrPlot(dc,x+1,y); dc->color=LTPURPLE; GrPlot(dc,x,y-1); } if (game_tf) { dc->color=RED; GrPrint(dc,(task->pix_width-FONT_WIDTH*14)/2, (task->pix_height-FONT_HEIGHT)/2,"Game Completed"); tt=game_tf; } else { dc->color=GREEN; tt=tS; } GrPrint(dc,0,0,"Bugs:%3.1f%% Time:%3.2f Best:%3.2f", 100.0*(MAX_BUGS-bug_cnt)/MAX_BUGS,tt-game_t0,best_score); } U0 CheckBugs(CTask *task,CTask *song_task) { I64 i,x,y, h=MaxI64(1,task->pix_width-2*BORDER), v=MaxI64(1,task->pix_height-2*BORDER); if (eat_timeout && eat_timeout-tS<0.75*EAT_TIME) { Suspend(song_task,FALSE); if (tS>=eat_timeout) eat_timeout=0; } for (i=0;itask_end_cb=&SndTaskEndCB; MusicSettingsRst; while (TRUE) { Play("3eBEBCBEsEFqEeBEBCBEsEF"); Play("qEeADABADsDCqDeBEBCB"); Play("EsEDqE"); } } U0 AnimateTask(I64) { F64 tt=0; while (TRUE) { if (game_reset) { Init(Fs->parent_task->song_task); tt=0; game_reset=FALSE; } if (flap_down) { flap_down=FALSE; tt=-0.005*Min(1.0,(tS-flap_time)/FLAP_TIME); flap_time=tS; } else if (flap_up) { flap_up=FALSE; tt= 0.005; } if (tt<0) { bird_y+=75*tt; tt+=0.000015; } else bird_y+=0.15; bird_y=Clamp(bird_y,BORDER,Fs->parent_task->pix_height-BORDER); flap_phase=Clamp(flap_phase+tt,0.0,1.0); CheckBugs(Fs->parent_task,Fs->parent_task->song_task); Sleep(1); } } U0 BugBird() { Bool rst_space=TRUE; I64 a1,a2; MenuPush( "File {" " Abort(,CH_SHIFT_ESC);" " Exit(,CH_ESC);" "}" "Play {" " Restart(,'\n');" " Flap(,CH_SPACE);" "}" ); PopUpOk("Use $$GREEN$$$$FG$$ to flap.\nHold down to glide."); SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$ WinBorder(ON); WinHorz(1,TEXT_COLS/2); WinVert(2,TEXT_ROWS/2); Fs->song_task=Spawn(&SongTask,NULL,"Song",,Fs); game_reset=TRUE; Fs->animate_task=Spawn(&AnimateTask,NULL,"Animate",,Fs); while (game_reset) Yield; DocCursor; DocClear; Fs->draw_it=&DrawIt; try { while (TRUE) { switch (GetMsg(&a1,&a2,1<