templeos-info/public/Wb/Demo/Games/FlapBat.HC.HTML

306 lines
26 KiB
Plaintext
Raw Normal View History

2024-03-24 21:24:44 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="generator" content="TempleOS V5.03">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="/style/templeos.css">
<script src="/script/templeos.js"></script>
<style type="text/css">
.c70{color:#000000;background-color:#aaaaaa;}
.c7A{color:#55ff55;background-color:#aaaaaa;}
.cF0{color:#000000;background-color:#ffffff;}
.cF1{color:#0000aa;background-color:#ffffff;}
.cF2{color:#00aa00;background-color:#ffffff;}
.cF3{color:#00aaaa;background-color:#ffffff;}
.cF4{color:#aa0000;background-color:#ffffff;}
.cF5{color:#aa00aa;background-color:#ffffff;}
.cF6{color:#aa5500;background-color:#ffffff;}
.cF7{color:#aaaaaa;background-color:#ffffff;}
.cF8{color:#555555;background-color:#ffffff;}
.cF9{color:#5555ff;background-color:#ffffff;}
.cFA{color:#55ff55;background-color:#ffffff;}
.cFB{color:#55ffff;background-color:#ffffff;}
.cFC{color:#ff5555;background-color:#ffffff;}
.cFD{color:#ff55ff;background-color:#ffffff;}
.cFE{color:#ffff55;background-color:#ffffff;}
.cFF{color:#ffffff;background-color:#ffffff;}
</style>
</head>
<body>
<pre id="content">
<a name="l1"></a><span class=cF5>RegDft</span><span class=cF0>(</span><span class=cF6>&quot;TempleOS/FlapBat&quot;</span><span class=cF0>,</span><span class=cF6>&quot;F64 best_score=9999;\n&quot;</span><span class=cF0>);
<a name="l2"></a></span><span class=cF5>RegExe</span><span class=cF0>(</span><span class=cF6>&quot;TempleOS/FlapBat&quot;</span><span class=cF0>);
<a name="l3"></a>
<a name="l4"></a>
<a name="l5"></a></span><span class=c70>
<a name="l6"></a>
<a name="l7"></a>
<a name="l8"></a>
<a name="l9"></a> </span><span class=c7A>&lt;1&gt;/* Graphics Not Rendered in HTML */</span><span class=c70>
<a name="l10"></a>
<a name="l11"></a>
<a name="l12"></a> </span><span class=c7A>&lt;2&gt;/* Graphics Not Rendered in HTML */</span><span class=c70>
<a name="l13"></a>
<a name="l14"></a>
<a name="l15"></a>
<a name="l16"></a>
<a name="l17"></a>
<a name="l18"></a> </span><span class=c7A>&lt;3&gt;/* Graphics Not Rendered in HTML */</span><span class=c70>
<a name="l19"></a>
<a name="l20"></a>
<a name="l21"></a> </span><span class=c7A>&lt;4&gt;/* Graphics Not Rendered in HTML */</span><span class=c70>
<a name="l22"></a>
<a name="l23"></a>
<a name="l24"></a> </span><span class=c7A>&lt;5&gt;/* Graphics Not Rendered in HTML */</span><span class=c70>
<a name="l25"></a>
<a name="l26"></a>
<a name="l27"></a>
<a name="l28"></a></span><span class=cF0>
<a name="l29"></a>#</span><span class=cF1>define</span><span class=cF0> BORDER 6
<a name="l30"></a>#</span><span class=cF1>define</span><span class=cF0> EAT_TIME 0.5
<a name="l31"></a>#</span><span class=cF1>define</span><span class=cF0> FLAP_TIME 0.5
<a name="l32"></a>#</span><span class=cF1>define</span><span class=cF0> BAT_BOX 10
<a name="l33"></a>
<a name="l34"></a></span><span class=cF1>Bool</span><span class=cF0> flap_down,flap_up;
<a name="l35"></a></span><span class=cF1>F64</span><span class=cF0> flap_phase,delta_phase,bat_y,bat_x,eat_timeout,flap_time;
<a name="l36"></a></span><span class=cF1>F64</span><span class=cF0> frame_x,game_t0,game_tf;
<a name="l37"></a>
<a name="l38"></a>#</span><span class=cF1>define</span><span class=cF0> BUGS_NUM 32
<a name="l39"></a></span><span class=cF9>I32</span><span class=cF0> bug_cnt,bugs_x[BUGS_NUM],bugs_y[BUGS_NUM];
<a name="l40"></a></span><span class=cF1>Bool</span><span class=cF0> bugs_dead[BUGS_NUM];
<a name="l41"></a>
<a name="l42"></a>#</span><span class=cF1>define</span><span class=cF0> GLOW_PERIOD 3.0
<a name="l43"></a></span><span class=cF1>F64</span><span class=cF0> bugs_glow_phase[BUGS_NUM];
<a name="l44"></a>
<a name="l45"></a></span><span class=cF9>CDC</span><span class=cF0> *limit_flood_fill_dc; </span><span class=cF2>//Prevent uncontrolled flood-fill flicker.</span><span class=cF0>
<a name="l46"></a>
<a name="l47"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>DrawIt</span><span class=cF0>(</span><span class=cF9>CTask</span><span class=cF0> *task,</span><span class=cF9>CDC</span><span class=cF0> *dc)
<a name="l48"></a>{
<a name="l49"></a> </span><span class=cF9>I64</span><span class=cF0> i,y,x,
<a name="l50"></a> h=</span><span class=cF5>MaxI64</span><span class=cF0>(1,task-&gt;pix_width-2*BORDER),
<a name="l51"></a> v=</span><span class=cF5>MaxI64</span><span class=cF0>(1,task-&gt;pix_height-2*BORDER);
<a name="l52"></a> </span><span class=cF1>U8</span><span class=cF0> *tmps,*tmps2,*tmps3;
<a name="l53"></a> </span><span class=cF1>F64</span><span class=cF0> tt=flap_phase*flap_phase*flap_phase,ts=</span><span class=cF5>tS</span><span class=cF0>;
<a name="l54"></a>
<a name="l55"></a> bat_x=task-&gt;pix_width&gt;&gt;3;
<a name="l56"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc,</span><span class=cF7>(</span><span class=cF0>7*task-&gt;pix_width</span><span class=cF7>)</span><span class=cF0>&gt;&gt;3,20,0,</span><span class=cFA>&lt;5&gt;</span><span class=cF0>);
<a name="l57"></a>
<a name="l58"></a> dc-&gt;color=</span><span class=cF3>DKGRAY</span><span class=cF0>;
<a name="l59"></a> </span><span class=cF5>GrCircle</span><span class=cF0>(dc,bat_x+5+20*</span><span class=cF5>Saw</span><span class=cF7>(</span><span class=cF0>15*</span><span class=cF5>tS</span><span class=cF0>,2</span><span class=cF7>)</span><span class=cF0>,bat_y,10+20*</span><span class=cF5>Saw</span><span class=cF7>(</span><span class=cF0>15*</span><span class=cF5>tS</span><span class=cF0>,2</span><span class=cF7>)</span><span class=cF0>,5,-</span><span class=cF3>pi</span><span class=cF0>/4,</span><span class=cF3>pi</span><span class=cF0>/2);
<a name="l60"></a>
<a name="l61"></a> tmps=</span><span class=cF5>SpriteInterpolate</span><span class=cF0>(tt,</span><span class=cFA>&lt;1&gt;</span><span class=cF0>,</span><span class=cFA>&lt;2&gt;</span><span class=cF0>);
<a name="l62"></a> </span><span class=cF1>if</span><span class=cF0> (eat_timeout &amp;&amp; </span><span class=cF5>tS</span><span class=cF0>&lt;eat_timeout) </span><span class=cF7>{</span><span class=cF0>
<a name="l63"></a> tmps2=</span><span class=cF5>SpriteInterpolate</span><span class=cF0>(tt,</span><span class=cFA>&lt;3&gt;</span><span class=cF0>,</span><span class=cFA>&lt;4&gt;</span><span class=cF0>);
<a name="l64"></a> tmps3=</span><span class=cF5>SpriteInterpolate</span><span class=cF0>(1.0-</span><span class=cF7>(</span><span class=cF0>eat_timeout-</span><span class=cF5>tS</span><span class=cF7>)</span><span class=cF0>/EAT_TIME,tmps2,tmps);
<a name="l65"></a> </span><span class=cF5>Free</span><span class=cF0>(tmps);
<a name="l66"></a> </span><span class=cF5>Free</span><span class=cF0>(tmps2);
<a name="l67"></a> tmps=tmps3;
<a name="l68"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l69"></a>
<a name="l70"></a> </span><span class=cF5>DCFill</span><span class=cF0>(limit_flood_fill_dc);
<a name="l71"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(limit_flood_fill_dc,16,32,0,tmps);
<a name="l72"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>GrPeek</span><span class=cF7>(</span><span class=cF0>limit_flood_fill_dc,0,0</span><span class=cF7>)</span><span class=cF0>!=</span><span class=cF3>TRANSPARENT</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF2>//Did FloodFill go crazy?</span><span class=cF0>
<a name="l73"></a> limit_flood_fill_dc-&gt;color=</span><span class=cF3>TRANSPARENT</span><span class=cF0>;
<a name="l74"></a> </span><span class=cF5>GrFloodFill</span><span class=cF0>(limit_flood_fill_dc,0,0);
<a name="l75"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l76"></a> </span><span class=cF5>GrBlot</span><span class=cF0>(dc,bat_x-16,bat_y-32,limit_flood_fill_dc);
<a name="l77"></a>
<a name="l78"></a> </span><span class=cF5>Free</span><span class=cF0>(tmps);
<a name="l79"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;BUGS_NUM;i++)
<a name="l80"></a> </span><span class=cF1>if</span><span class=cF0> (!bugs_dead[i]) </span><span class=cF7>{</span><span class=cF0>
<a name="l81"></a> x=(bugs_x[i]+frame_x)%h+BORDER;
<a name="l82"></a> y=bugs_y[i]%v+BORDER;
<a name="l83"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Saw</span><span class=cF7>(</span><span class=cF0>ts+bugs_glow_phase[i],GLOW_PERIOD</span><span class=cF7>)</span><span class=cF0>&lt;0.2) {
<a name="l84"></a> </span><span class=cF1>if</span><span class=cF0> (i&amp;1)
<a name="l85"></a> dc-&gt;color=</span><span class=cF3>YELLOW</span><span class=cF0>;
<a name="l86"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l87"></a> dc-&gt;color=</span><span class=cF3>LTGREEN</span><span class=cF0>;
<a name="l88"></a> } </span><span class=cF1>else</span><span class=cF0>
<a name="l89"></a> dc-&gt;color=</span><span class=cF3>BLACK</span><span class=cF0>;
<a name="l90"></a> </span><span class=cF5>GrPlot</span><span class=cF0>(dc,x,y);
<a name="l91"></a> </span><span class=cF5>GrPlot</span><span class=cF0>(dc,x+1,y);
<a name="l92"></a> dc-&gt;color=</span><span class=cF3>BLACK</span><span class=cF0>;
<a name="l93"></a> </span><span class=cF5>GrPlot</span><span class=cF0>(dc,x,y-1);
<a name="l94"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l95"></a> </span><span class=cF1>if</span><span class=cF0> (game_tf) </span><span class=cF7>{</span><span class=cF0>
<a name="l96"></a> dc-&gt;color=</span><span class=cF3>RED</span><span class=cF0>;
<a name="l97"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc,</span><span class=cF7>(</span><span class=cF0>task-&gt;pix_width-</span><span class=cF3>FONT_WIDTH</span><span class=cF0>*14</span><span class=cF7>)</span><span class=cF0>/2,
<a name="l98"></a> </span><span class=cF7>(</span><span class=cF0>task-&gt;pix_height-</span><span class=cF3>FONT_HEIGHT</span><span class=cF7>)</span><span class=cF0>/2,</span><span class=cF6>&quot;Game Completed&quot;</span><span class=cF0>);
<a name="l99"></a> tt=game_tf;
<a name="l100"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l101"></a> dc-&gt;color=</span><span class=cF3>BLACK</span><span class=cF0>;
<a name="l102"></a> tt=</span><span class=cF5>tS</span><span class=cF0>;
<a name="l103"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l104"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc,0,0,</span><span class=cF6>&quot;Bugs:%3.1f%% Time:%3.2f Best:%3.2f&quot;</span><span class=cF0>,
<a name="l105"></a> 100.0*</span><span class=cF7>(</span><span class=cF0>BUGS_NUM-bug_cnt</span><span class=cF7>)</span><span class=cF0>/BUGS_NUM,tt-game_t0,best_score);
<a name="l106"></a>}
<a name="l107"></a>
<a name="l108"></a></span><span class=cF1>U0</span><span class=cF0> CheckBugs(</span><span class=cF9>CTask</span><span class=cF0> *task)
<a name="l109"></a>{
<a name="l110"></a> </span><span class=cF9>I64</span><span class=cF0> i,x,y,
<a name="l111"></a> h=</span><span class=cF5>MaxI64</span><span class=cF0>(1,task-&gt;pix_width-2*BORDER),
<a name="l112"></a> v=</span><span class=cF5>MaxI64</span><span class=cF0>(1,task-&gt;pix_height-2*BORDER);
<a name="l113"></a> </span><span class=cF1>if</span><span class=cF0> (eat_timeout &amp;&amp; eat_timeout-</span><span class=cF5>tS</span><span class=cF0>&lt;0.75*EAT_TIME) </span><span class=cF7>{</span><span class=cF0>
<a name="l114"></a> </span><span class=cF5>Suspend</span><span class=cF0>(task-&gt;song_task,</span><span class=cF3>FALSE</span><span class=cF0>);
<a name="l115"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>tS</span><span class=cF0>&gt;=eat_timeout)
<a name="l116"></a> eat_timeout=0;
<a name="l117"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l118"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;BUGS_NUM;i++)
<a name="l119"></a> </span><span class=cF1>if</span><span class=cF0> (!bugs_dead[i]) </span><span class=cF7>{</span><span class=cF0>
<a name="l120"></a> x=(bugs_x[i]+frame_x)%h+BORDER;
<a name="l121"></a> y=bugs_y[i]%v+BORDER;
<a name="l122"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>AbsI64</span><span class=cF7>(</span><span class=cF0>x-bat_x</span><span class=cF7>)</span><span class=cF0>&lt;BAT_BOX &amp;&amp; </span><span class=cF5>AbsI64</span><span class=cF7>(</span><span class=cF0>y-bat_y</span><span class=cF7>)</span><span class=cF0>&lt;BAT_BOX) {
<a name="l123"></a> bugs_dead[i]=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l124"></a> eat_timeout=</span><span class=cF5>tS</span><span class=cF0>+EAT_TIME;
<a name="l125"></a> </span><span class=cF5>Snd</span><span class=cF0>(74);
<a name="l126"></a> </span><span class=cF5>Suspend</span><span class=cF0>(task-&gt;song_task);
<a name="l127"></a> bug_cnt--;
<a name="l128"></a> }
<a name="l129"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l130"></a> </span><span class=cF1>if</span><span class=cF0> (!game_tf &amp;&amp; !bug_cnt) </span><span class=cF7>{</span><span class=cF0>
<a name="l131"></a> game_tf=</span><span class=cF5>tS</span><span class=cF0>;
<a name="l132"></a> </span><span class=cF5>Suspend</span><span class=cF0>(task-&gt;song_task);
<a name="l133"></a> </span><span class=cF5>Snd</span><span class=cF0>;
<a name="l134"></a> </span><span class=cF1>if</span><span class=cF0> (game_tf-game_t0&lt;best_score)
<a name="l135"></a> best_score=game_tf-game_t0;
<a name="l136"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l137"></a> frame_x-=0.1;
<a name="l138"></a> </span><span class=cF1>if</span><span class=cF0> (frame_x&lt;0)
<a name="l139"></a> frame_x+=h;
<a name="l140"></a>}
<a name="l141"></a>
<a name="l142"></a></span><span class=cF1>U0</span><span class=cF0> Init()
<a name="l143"></a>{
<a name="l144"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l145"></a> limit_flood_fill_dc=</span><span class=cF5>DCNew</span><span class=cF0>(32,40);
<a name="l146"></a> flap_down=flap_up=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l147"></a> flap_phase=0;
<a name="l148"></a> bat_x=</span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_width&gt;&gt;3;
<a name="l149"></a> bat_y=0;
<a name="l150"></a> frame_x=0;
<a name="l151"></a> bug_cnt=BUGS_NUM;
<a name="l152"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;BUGS_NUM;i++) </span><span class=cF7>{</span><span class=cF0>
<a name="l153"></a> bugs_dead[i]=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l154"></a> bugs_x[i]=</span><span class=cF5>RandU16</span><span class=cF0>;
<a name="l155"></a> bugs_y[i]=</span><span class=cF5>RandU16</span><span class=cF0>;
<a name="l156"></a> bugs_glow_phase[i]=GLOW_PERIOD*</span><span class=cF5>Rand</span><span class=cF0>;
<a name="l157"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l158"></a> </span><span class=cF5>Suspend</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>-&gt;song_task,</span><span class=cF3>FALSE</span><span class=cF0>);
<a name="l159"></a> flap_time=eat_timeout=0;
<a name="l160"></a> delta_phase=game_tf=0;
<a name="l161"></a> game_t0=</span><span class=cF5>tS</span><span class=cF0>;
<a name="l162"></a>}
<a name="l163"></a>
<a name="l164"></a></span><span class=cF1>U0</span><span class=cF0> SongTask(</span><span class=cF9>I64</span><span class=cF0>)
<a name="l165"></a>{</span><span class=cF2>//Song by Terry A. Davis</span><span class=cF0>
<a name="l166"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;task_end_cb=&amp;</span><span class=cF5>SndTaskEndCB</span><span class=cF0>;
<a name="l167"></a> </span><span class=cF5>MusicSettingsRst</span><span class=cF0>;
<a name="l168"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l169"></a> </span><span class=cF5>Play</span><span class=cF0>(</span><span class=cF6>&quot;4eB5E4B5C4B5EsEFqE4eB5E4B5C4B5EsEF&quot;</span><span class=cF0>);
<a name="l170"></a> </span><span class=cF5>Play</span><span class=cF0>(</span><span class=cF6>&quot;5qE4eA5D4ABA5DsDCqD4eB5E4B5C4B&quot;</span><span class=cF0>);
<a name="l171"></a> </span><span class=cF5>Play</span><span class=cF0>(</span><span class=cF6>&quot;5EsEDqE&quot;</span><span class=cF0>);
<a name="l172"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l173"></a>}
<a name="l174"></a>
<a name="l175"></a></span><span class=cF1>U0</span><span class=cF0> AnimateTask(</span><span class=cF9>I64</span><span class=cF0>)
<a name="l176"></a>{
<a name="l177"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l178"></a> </span><span class=cF1>if</span><span class=cF0> (flap_down) {
<a name="l179"></a> flap_down=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l180"></a> delta_phase=-0.005*</span><span class=cF5>Min</span><span class=cF0>(1.0,</span><span class=cF7>(</span><span class=cF5>tS</span><span class=cF0>-flap_time</span><span class=cF7>)</span><span class=cF0>/FLAP_TIME);
<a name="l181"></a> flap_time=</span><span class=cF5>tS</span><span class=cF0>;
<a name="l182"></a> } </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (flap_up) {
<a name="l183"></a> flap_up=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l184"></a> delta_phase= 0.005;
<a name="l185"></a> }
<a name="l186"></a> </span><span class=cF1>if</span><span class=cF0> (delta_phase&lt;0) {
<a name="l187"></a> bat_y+=75*delta_phase;
<a name="l188"></a> delta_phase+=0.000015;
<a name="l189"></a> } </span><span class=cF1>else</span><span class=cF0>
<a name="l190"></a> bat_y+=0.15;
<a name="l191"></a> bat_y=</span><span class=cF5>Clamp</span><span class=cF0>(bat_y,BORDER,</span><span class=cF5>Fs</span><span class=cF0>-&gt;parent_task-&gt;pix_height-BORDER);
<a name="l192"></a> flap_phase=</span><span class=cF5>Clamp</span><span class=cF0>(flap_phase+delta_phase,0.0,1.0);
<a name="l193"></a> CheckBugs(</span><span class=cF5>Fs</span><span class=cF0>-&gt;parent_task);
<a name="l194"></a> </span><span class=cF5>Sleep</span><span class=cF0>(1);
<a name="l195"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l196"></a>}
<a name="l197"></a>
<a name="l198"></a></span><span class=cF1>U0</span><span class=cF0> CleanUp()
<a name="l199"></a>{
<a name="l200"></a> </span><span class=cF5>DCDel</span><span class=cF0>(limit_flood_fill_dc);
<a name="l201"></a>}
<a name="l202"></a>
<a name="l203"></a></span><span class=cF1>U0</span><span class=cF0> FlapBat()
<a name="l204"></a>{
<a name="l205"></a> </span><span class=cF1>Bool</span><span class=cF0> rst_space=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l206"></a> </span><span class=cF9>I64</span><span class=cF0> arg1,arg2;
<a name="l207"></a>
<a name="l208"></a> </span><span class=cF5>MenuPush</span><span class=cF0>(
<a name="l209"></a> </span><span class=cF6>&quot;File {&quot;</span><span class=cF0>
<a name="l210"></a> </span><span class=cF6>&quot; Abort(,CH_SHIFT_ESC);&quot;</span><span class=cF0>
<a name="l211"></a> </span><span class=cF6>&quot; Exit(,CH_ESC);&quot;</span><span class=cF0>
<a name="l212"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l213"></a> </span><span class=cF6>&quot;Play {&quot;</span><span class=cF0>
<a name="l214"></a> </span><span class=cF6>&quot; Restart(,'\n');&quot;</span><span class=cF0>
<a name="l215"></a> </span><span class=cF6>&quot; Flap(,CH_SPACE);&quot;</span><span class=cF0>
<a name="l216"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l217"></a> );
<a name="l218"></a>
<a name="l219"></a> </span><span class=cF5>PopUpOk</span><span class=cF0>(</span><span class=cF6>&quot;Use $GREEN$&lt;SPACE&gt;$FG$ to flap.\nHold down to glide.&quot;</span><span class=cF0>);
<a name="l220"></a>
<a name="l221"></a> </span><span class=cF5>SettingsPush</span><span class=cF0>; </span><span class=cF2>//See </span><a href="/Wb/Adam/TaskSettings.HC.HTML#l3"><span class=cF4>SettingsPush</span></a><span class=cF0>
<a name="l222"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;text_attr=</span><span class=cF3>LTGRAY</span><span class=cF0>&lt;&lt;4+</span><span class=cF3>WHITE</span><span class=cF0>;
<a name="l223"></a> </span><span class=cF5>WinBorder</span><span class=cF0>(</span><span class=cF3>ON</span><span class=cF0>);
<a name="l224"></a> </span><span class=cF5>WinHorz</span><span class=cF0>(1,</span><span class=cF3>TEXT_COLS</span><span class=cF0>/2);
<a name="l225"></a> </span><span class=cF5>WinVert</span><span class=cF0>(2,</span><span class=cF3>TEXT_ROWS</span><span class=cF0>/2);
<a name="l226"></a> </span><span class=cF5>DocCursor</span><span class=cF0>;
<a name="l227"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
<a name="l228"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;song_task=</span><span class=cF5>Spawn</span><span class=cF0>(&amp;SongTask,</span><span class=cF3>NULL</span><span class=cF0>,</span><span class=cF6>&quot;Song&quot;</span><span class=cF0>,,</span><span class=cF5>Fs</span><span class=cF0>);
<a name="l229"></a> Init;
<a name="l230"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;animate_task=</span><span class=cF5>Spawn</span><span class=cF0>(&amp;AnimateTask,</span><span class=cF3>NULL</span><span class=cF0>,</span><span class=cF6>&quot;Animate&quot;</span><span class=cF0>,,</span><span class=cF5>Fs</span><span class=cF0>);
<a name="l231"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;draw_it=&amp;</span><span class=cF5>DrawIt</span><span class=cF0>;
<a name="l232"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l233"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) {
<a name="l234"></a> </span><span class=cF1>switch</span><span class=cF0> (</span><span class=cF5>GetMsg</span><span class=cF7>(</span><span class=cF0>&amp;arg1,&amp;arg2,1&lt;&lt;</span><span class=cF3>MSG_KEY_DOWN</span><span class=cF0>+1&lt;&lt;</span><span class=cF3>MSG_KEY_UP</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l235"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_KEY_DOWN</span><span class=cF0>:
<a name="l236"></a> </span><span class=cF1>switch</span><span class=cF0> (arg1) {
<a name="l237"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SPACE</span><span class=cF0>:
<a name="l238"></a> </span><span class=cF1>if</span><span class=cF0> (rst_space) </span><span class=cF7>{</span><span class=cF0>
<a name="l239"></a> flap_down=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l240"></a> rst_space=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l241"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l242"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l243"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\n'</span><span class=cF0>:
<a name="l244"></a> CleanUp;
<a name="l245"></a> Init;
<a name="l246"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l247"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0>:
<a name="l248"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_ESC</span><span class=cF0>:
<a name="l249"></a> </span><span class=cF1>goto</span><span class=cF0> bl_done;
<a name="l250"></a> }
<a name="l251"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l252"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_KEY_UP</span><span class=cF0>:
<a name="l253"></a> </span><span class=cF1>switch</span><span class=cF0> (arg1) {
<a name="l254"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SPACE</span><span class=cF0>:
<a name="l255"></a> flap_up=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l256"></a> rst_space=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l257"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l258"></a> }
<a name="l259"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l260"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l261"></a> }
<a name="l262"></a>bl_done:
<a name="l263"></a> </span><span class=cF5>GetMsg</span><span class=cF0>(,,1&lt;&lt;</span><span class=cF3>MSG_KEY_UP</span><span class=cF0>);
<a name="l264"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>catch</span><span class=cF0>
<a name="l265"></a> </span><span class=cF5>PutExcept</span><span class=cF0>;
<a name="l266"></a> </span><span class=cF5>SettingsPop</span><span class=cF0>;
<a name="l267"></a> CleanUp;
<a name="l268"></a> </span><span class=cF5>MenuPop</span><span class=cF0>;
<a name="l269"></a> </span><span class=cF5>RegWrite</span><span class=cF0>(</span><span class=cF6>&quot;TempleOS/FlapBat&quot;</span><span class=cF0>,</span><span class=cF6>&quot;F64 best_score=%5.4f;\n&quot;</span><span class=cF0>,best_score);
<a name="l270"></a>}
<a name="l271"></a>
<a name="l272"></a>FlapBat;
</span></pre></body>
</html>