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

390 lines
31 KiB
HTML
Executable File

<!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">
.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/BomberGolf&quot;</span><span class=cF0>,</span><span class=cF6>&quot;I64 best_score=99999;\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/BomberGolf&quot;</span><span class=cF0>);
<a name="l3"></a>
<a name="l4"></a>
<a name="l5"></a>
<a name="l6"></a> </span><span class=cFA>&lt;1&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l7"></a>
<a name="l8"></a>
<a name="l9"></a>
<a name="l10"></a>
<a name="l11"></a> </span><span class=cFA>&lt;2&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l12"></a>
<a name="l13"></a>
<a name="l14"></a>
<a name="l15"></a> </span><span class=cFA>&lt;3&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l16"></a>
<a name="l17"></a>
<a name="l18"></a> </span><span class=cFA>&lt;4&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l19"></a>
<a name="l20"></a>
<a name="l21"></a> </span><span class=cFA>&lt;5&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l22"></a>
<a name="l23"></a>
<a name="l24"></a>
<a name="l25"></a> </span><span class=cFA>&lt;6&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l26"></a>
<a name="l27"></a>
<a name="l28"></a>
<a name="l29"></a>
<a name="l30"></a> </span><span class=cFA>&lt;7&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l31"></a>
<a name="l32"></a>
<a name="l33"></a>
<a name="l34"></a>
<a name="l35"></a> </span><span class=cFA>&lt;8&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l36"></a>
<a name="l37"></a>
<a name="l38"></a>
<a name="l39"></a>
<a name="l40"></a> </span><span class=cFA>&lt;9&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l41"></a>
<a name="l42"></a>
<a name="l43"></a>
<a name="l44"></a>
<a name="l45"></a> </span><span class=cFA>&lt;10&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l46"></a>
<a name="l47"></a>
<a name="l48"></a>#</span><span class=cF1>define</span><span class=cF0> MAP_WIDTH 600
<a name="l49"></a>#</span><span class=cF1>define</span><span class=cF0> MAP_HEIGHT 600
<a name="l50"></a>
<a name="l51"></a>#</span><span class=cF1>define</span><span class=cF0> TREES_NUM 64
<a name="l52"></a></span><span class=cF1>class</span><span class=cF0> Tree
<a name="l53"></a>{
<a name="l54"></a> </span><span class=cF9>I64</span><span class=cF0> x,y;
<a name="l55"></a>} trees[TREES_NUM];
<a name="l56"></a>
<a name="l57"></a>
<a name="l58"></a></span><span class=cF9>I64</span><span class=cF0> target_cnt,key_cnt;
<a name="l59"></a>
<a name="l60"></a>
<a name="l61"></a>#</span><span class=cF1>define</span><span class=cF0> TARGETS_NUM 10
<a name="l62"></a>
<a name="l63"></a>#</span><span class=cF1>define</span><span class=cF0> MDF_TANK 0
<a name="l64"></a>#</span><span class=cF1>define</span><span class=cF0> MDF_BUNKER 1
<a name="l65"></a>
<a name="l66"></a>#</span><span class=cF1>define</span><span class=cF0> TANK_V 10.0
<a name="l67"></a>
<a name="l68"></a></span><span class=cF1>class</span><span class=cF0> Target
<a name="l69"></a>{
<a name="l70"></a> </span><span class=cF1>F64</span><span class=cF0> x,y,theta;
<a name="l71"></a> </span><span class=cF1>U8</span><span class=cF0> *alive_img,*dead_img1,*dead_img2;
<a name="l72"></a> </span><span class=cF1>U8</span><span class=cF0> type;
<a name="l73"></a> </span><span class=cF1>Bool</span><span class=cF0> dead,pad[6];
<a name="l74"></a>} targets[TARGETS_NUM];
<a name="l75"></a>
<a name="l76"></a>#</span><span class=cF1>define</span><span class=cF0> FALL_TIME 3.00
<a name="l77"></a>#</span><span class=cF1>define</span><span class=cF0> EXPLODE_TIME 0.25
<a name="l78"></a></span><span class=cF1>class</span><span class=cF0> Bomb
<a name="l79"></a>{
<a name="l80"></a> Bomb *next,*last;
<a name="l81"></a> </span><span class=cF1>F64</span><span class=cF0> x,y,t;
<a name="l82"></a> </span><span class=cF1>Bool</span><span class=cF0> exploding;
<a name="l83"></a>} bomb_head;
<a name="l84"></a>
<a name="l85"></a></span><span class=cF1>F64</span><span class=cF0> v,x,y,
<a name="l86"></a> theta,thetaf; </span><span class=cF2>//thetaf is the final theta. theta is gradually changed until it reaches thetaf.</span><span class=cF0>
<a name="l87"></a>
<a name="l88"></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="l89"></a>{
<a name="l90"></a> </span><span class=cF9>I64</span><span class=cF0> i,j;
<a name="l91"></a> Bomb *tmpb;
<a name="l92"></a> Target *tmpt;
<a name="l93"></a> </span><span class=cF1>F64</span><span class=cF0> ts=</span><span class=cF5>tS</span><span class=cF0>,dx,dy;
<a name="l94"></a>
<a name="l95"></a> dc-&gt;color=</span><span class=cF3>ROPF_DITHER</span><span class=cF0>|</span><span class=cF3>BROWN</span><span class=cF0>&lt;&lt;16|</span><span class=cF3>YELLOW</span><span class=cF0>;
<a name="l96"></a> </span><span class=cF5>GrRect3</span><span class=cF0>(dc,0,0,0,dc-&gt;width,dc-&gt;height);
<a name="l97"></a>
<a name="l98"></a> dc-&gt;x=task-&gt;pix_width&gt;&gt;1;
<a name="l99"></a> dc-&gt;y=task-&gt;pix_height&gt;&gt;1;
<a name="l100"></a> dc-&gt;flags|=</span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF0>;
<a name="l101"></a> </span><span class=cF5>Mat4x4TranslationEqu</span><span class=cF0>(dc-&gt;r,x,y,0);
<a name="l102"></a> </span><span class=cF5>Mat4x4RotZ</span><span class=cF0>(dc-&gt;r,theta);
<a name="l103"></a> dc-&gt;color=</span><span class=cF3>BLACK</span><span class=cF0>;
<a name="l104"></a> </span><span class=cF5>GrBorder</span><span class=cF0>(dc,-MAP_WIDTH&gt;&gt;1,-MAP_HEIGHT&gt;&gt;1,MAP_WIDTH&gt;&gt;1,MAP_HEIGHT&gt;&gt;1);
<a name="l105"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;TARGETS_NUM;i++) </span><span class=cF7>{</span><span class=cF0>
<a name="l106"></a> tmpt=&amp;targets[i];
<a name="l107"></a> </span><span class=cF1>if</span><span class=cF0> (tmpt-&gt;dead) {
<a name="l108"></a> </span><span class=cF1>if</span><span class=cF0> (i&amp;1) </span><span class=cF7>{</span><span class=cF0>
<a name="l109"></a> dc-&gt;flags|=</span><span class=cF3>DCF_SYMMETRY</span><span class=cF0>|</span><span class=cF3>DCF_JUST_MIRROR</span><span class=cF0>;
<a name="l110"></a> </span><span class=cF5>DCSymmetry3Set</span><span class=cF0>(dc,tmpt-&gt;x,tmpt-&gt;y,0,tmpt-&gt;x,tmpt-&gt;y,1,
<a name="l111"></a> tmpt-&gt;x+1024*</span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>tmpt-&gt;theta</span><span class=cF7>)</span><span class=cF0>,tmpt-&gt;y+1024*</span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>tmpt-&gt;theta</span><span class=cF7>)</span><span class=cF0>,0);
<a name="l112"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l113"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Blink</span><span class=cF7>(</span><span class=cF0>15</span><span class=cF7>)</span><span class=cF0>)
<a name="l114"></a> </span><span class=cF5>Sprite3ZB</span><span class=cF0>(dc,tmpt-&gt;x,tmpt-&gt;y,0,tmpt-&gt;dead_img1,tmpt-&gt;theta);
<a name="l115"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l116"></a> </span><span class=cF5>Sprite3ZB</span><span class=cF0>(dc,tmpt-&gt;x,tmpt-&gt;y,0,tmpt-&gt;dead_img2,tmpt-&gt;theta);
<a name="l117"></a> dc-&gt;flags&amp;=~(</span><span class=cF3>DCF_SYMMETRY</span><span class=cF0>|</span><span class=cF3>DCF_JUST_MIRROR</span><span class=cF0>);
<a name="l118"></a> } </span><span class=cF1>else</span><span class=cF0>
<a name="l119"></a> </span><span class=cF5>Sprite3ZB</span><span class=cF0>(dc,tmpt-&gt;x,tmpt-&gt;y,0,tmpt-&gt;alive_img,tmpt-&gt;theta);
<a name="l120"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l121"></a>
<a name="l122"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;TREES_NUM;i++)
<a name="l123"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc,trees[i].x,trees[i].y,0,</span><span class=cFA>&lt;2&gt;</span><span class=cF0>);
<a name="l124"></a>
<a name="l125"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;TARGETS_NUM;i++) </span><span class=cF7>{</span><span class=cF0>
<a name="l126"></a> tmpt=&amp;targets[i];
<a name="l127"></a> </span><span class=cF1>if</span><span class=cF0> (tmpt-&gt;dead) {
<a name="l128"></a> </span><span class=cF1>for</span><span class=cF0> (j=0;j&lt;40;j++) </span><span class=cF7>{</span><span class=cF0>
<a name="l129"></a> dc-&gt;thick=4;
<a name="l130"></a> </span><span class=cF1>if</span><span class=cF0> (j&amp;1)
<a name="l131"></a> dc-&gt;color=</span><span class=cF3>ROPF_DITHER</span><span class=cF0>|</span><span class=cF3>LTGRAY</span><span class=cF0>&lt;&lt;16|</span><span class=cF3>BLACK</span><span class=cF0>;
<a name="l132"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l133"></a> dc-&gt;color=</span><span class=cF3>ROPF_DITHER</span><span class=cF0>|</span><span class=cF3>DKGRAY</span><span class=cF0>&lt;&lt;16|</span><span class=cF3>LTGRAY</span><span class=cF0>;
<a name="l134"></a> dx=15*</span><span class=cF5>Sin</span><span class=cF0>(ts/4+j&lt;&lt;6)+j&gt;&gt;2;
<a name="l135"></a> dy=10*</span><span class=cF5>FullTri</span><span class=cF0>(ts/3+j/2.0,20)+j&gt;&gt;2;
<a name="l136"></a> </span><span class=cF5>GrPlot3</span><span class=cF0>(dc,tmpt-&gt;x+5+dx+0.5*dy,tmpt-&gt;y+0.5*dx+dy,0);
<a name="l137"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l138"></a> }
<a name="l139"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l140"></a>
<a name="l141"></a> tmpb=bomb_head.next;
<a name="l142"></a> </span><span class=cF1>while</span><span class=cF0> (tmpb!=&amp;bomb_head) </span><span class=cF7>{</span><span class=cF0>
<a name="l143"></a> </span><span class=cF1>if</span><span class=cF0> (tmpb-&gt;t+FALL_TIME&lt;</span><span class=cF5>tS</span><span class=cF0>) {
<a name="l144"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Blink</span><span class=cF7>(</span><span class=cF0>10</span><span class=cF7>)</span><span class=cF0>)
<a name="l145"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc,tmpb-&gt;x,tmpb-&gt;y,0,</span><span class=cFA>&lt;9&gt;</span><span class=cF0>);
<a name="l146"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l147"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc,tmpb-&gt;x,tmpb-&gt;y,0,</span><span class=cFA>&lt;10&gt;</span><span class=cF0>);
<a name="l148"></a> }
<a name="l149"></a> tmpb=tmpb-&gt;next;
<a name="l150"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l151"></a>
<a name="l152"></a> dc-&gt;flags&amp;=~</span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF0>;
<a name="l153"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc,task-&gt;pix_width&gt;&gt;1,task-&gt;pix_height&gt;&gt;1,0,</span><span class=cFA>&lt;1&gt;</span><span class=cF0>);
<a name="l154"></a> dc-&gt;color=</span><span class=cF3>RED</span><span class=cF0>;
<a name="l155"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc,0,0,</span><span class=cF6>&quot;Targets:%02d</span><span class=cF0> </span><span class=cF6>KeyStrokes:%04d Best:%04d&quot;</span><span class=cF0>,
<a name="l156"></a> target_cnt,key_cnt,best_score);
<a name="l157"></a> </span><span class=cF1>if</span><span class=cF0> (!target_cnt &amp;&amp; </span><span class=cF5>Blink</span><span class=cF7>(</span><span class=cF0>4</span><span class=cF7>)</span><span class=cF0>)
<a name="l158"></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>&gt;&gt;1,
<a name="l159"></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>&gt;&gt;1-32,</span><span class=cF6>&quot;Game Completed&quot;</span><span class=cF0>);
<a name="l160"></a>}
<a name="l161"></a>
<a name="l162"></a></span><span class=cF1>U0</span><span class=cF0> BombHit(Bomb *tmpb)
<a name="l163"></a>{
<a name="l164"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l165"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;TARGETS_NUM;i++) </span><span class=cF7>{</span><span class=cF0>
<a name="l166"></a> </span><span class=cF1>if</span><span class=cF0> (!targets[i].dead &amp;&amp;
<a name="l167"></a> </span><span class=cF5>SqrI64</span><span class=cF7>(</span><span class=cF0>tmpb-&gt;x-targets[i].x</span><span class=cF7>)</span><span class=cF0>+</span><span class=cF5>SqrI64</span><span class=cF7>(</span><span class=cF0>tmpb-&gt;y-targets[i].y</span><span class=cF7>)</span><span class=cF0>&lt;20*20) {
<a name="l168"></a> targets[i].dead=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l169"></a> target_cnt--;
<a name="l170"></a> }
<a name="l171"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l172"></a> </span><span class=cF5>QueRem</span><span class=cF0>(tmpb);
<a name="l173"></a> </span><span class=cF5>Free</span><span class=cF0>(tmpb);
<a name="l174"></a>}
<a name="l175"></a>
<a name="l176"></a></span><span class=cF1>U0</span><span class=cF0> BombDrop(</span><span class=cF1>F64</span><span class=cF0> x,</span><span class=cF1>F64</span><span class=cF0> y)
<a name="l177"></a>{
<a name="l178"></a> Bomb *tmpb=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Bomb</span><span class=cF7>)</span><span class=cF0>);
<a name="l179"></a> tmpb-&gt;x=x;
<a name="l180"></a> tmpb-&gt;y=y;
<a name="l181"></a> tmpb-&gt;t=</span><span class=cF5>tS</span><span class=cF0>;
<a name="l182"></a> tmpb-&gt;exploding=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l183"></a> </span><span class=cF5>QueIns</span><span class=cF0>(tmpb,bomb_head.last);
<a name="l184"></a> </span><span class=cF5>Sweep</span><span class=cF0>(FALL_TIME*1000,74,62);
<a name="l185"></a>}
<a name="l186"></a>
<a name="l187"></a></span><span class=cF9>I64</span><span class=cF0> AnimateTask(</span><span class=cF9>CTask</span><span class=cF0> *)
<a name="l188"></a>{
<a name="l189"></a> </span><span class=cF1>F64</span><span class=cF0> last_t=</span><span class=cF5>tS</span><span class=cF0>,dt;
<a name="l190"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l191"></a> Bomb *tmpb,*tmpb1;
<a name="l192"></a> Target *tmpt;
<a name="l193"></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="l194"></a> dt=</span><span class=cF5>tS</span><span class=cF0>-last_t;
<a name="l195"></a> last_t=</span><span class=cF5>tS</span><span class=cF0>;
<a name="l196"></a>
<a name="l197"></a> </span><span class=cF1>if</span><span class=cF0> (bomb_head.next==&amp;bomb_head) {
<a name="l198"></a> </span><span class=cF1>if</span><span class=cF0> (target_cnt)
<a name="l199"></a> </span><span class=cF5>Snd</span><span class=cF0>(</span><span class=cF5>Freq2Ona</span><span class=cF7>(</span><span class=cF0>100+60*</span><span class=cF5>Clamp</span><span class=cF0>(0.1*</span><span class=cF7>(</span><span class=cF0>1.0+</span><span class=cF5>Abs</span><span class=cF0>(</span><span class=cF5>Wrap</span><span class=cF7>(</span><span class=cF0>thetaf-theta,-</span><span class=cF3>pi</span><span class=cF7>)</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0>`4.0,-3,3)</span><span class=cF7>)</span><span class=cF0>);
<a name="l200"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (key_cnt&lt;best_score) </span><span class=cF7>{</span><span class=cF0>
<a name="l201"></a> best_score=key_cnt;
<a name="l202"></a> </span><span class=cF5>Sleep</span><span class=cF0>(150); </span><span class=cF5>Snd</span><span class=cF0>(74);</span><span class=cF5>Sleep</span><span class=cF0>(150);</span><span class=cF5>Snd</span><span class=cF0>;
<a name="l203"></a> </span><span class=cF5>Sleep</span><span class=cF0>(150); </span><span class=cF5>Snd</span><span class=cF0>(74);</span><span class=cF5>Sleep</span><span class=cF0>(150);</span><span class=cF5>Snd</span><span class=cF0>;
<a name="l204"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
<a name="l205"></a> </span><span class=cF5>Snd</span><span class=cF0>;
<a name="l206"></a> }
<a name="l207"></a>
<a name="l208"></a> theta+=dt*(thetaf-theta);
<a name="l209"></a> x+=dt*v*</span><span class=cF5>Sin</span><span class=cF0>(theta);
<a name="l210"></a> y+=dt*v*</span><span class=cF5>Cos</span><span class=cF0>(theta);
<a name="l211"></a>
<a name="l212"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;TARGETS_NUM;i++) {
<a name="l213"></a> tmpt=&amp;targets[i];
<a name="l214"></a> </span><span class=cF1>if</span><span class=cF0> (!tmpt-&gt;dead &amp;&amp; tmpt-&gt;type==MDF_TANK) </span><span class=cF7>{</span><span class=cF0>
<a name="l215"></a> tmpt-&gt;x+=dt*TANK_V*</span><span class=cF5>Cos</span><span class=cF0>(tmpt-&gt;theta);
<a name="l216"></a> tmpt-&gt;y+=dt*TANK_V*</span><span class=cF5>Sin</span><span class=cF0>(tmpt-&gt;theta);
<a name="l217"></a> </span><span class=cF1>if</span><span class=cF0> (i&amp;1)
<a name="l218"></a> tmpt-&gt;theta+=dt*</span><span class=cF3>pi</span><span class=cF0>/16;
<a name="l219"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l220"></a> tmpt-&gt;theta-=dt*</span><span class=cF3>pi</span><span class=cF0>/16;
<a name="l221"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l222"></a> }
<a name="l223"></a>
<a name="l224"></a> tmpb=bomb_head.next;
<a name="l225"></a> </span><span class=cF1>while</span><span class=cF0> (tmpb!=&amp;bomb_head) {
<a name="l226"></a> tmpb1=tmpb-&gt;next;
<a name="l227"></a> </span><span class=cF1>if</span><span class=cF0> (tmpb-&gt;t+FALL_TIME+EXPLODE_TIME&lt;</span><span class=cF5>tS</span><span class=cF0>)
<a name="l228"></a> BombHit(tmpb);
<a name="l229"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (tmpb-&gt;t+FALL_TIME&lt;</span><span class=cF5>tS</span><span class=cF0> &amp;&amp; !tmpb-&gt;exploding) </span><span class=cF7>{</span><span class=cF0>
<a name="l230"></a> </span><span class=cF5>Noise</span><span class=cF0>(EXPLODE_TIME*1000,62,74);
<a name="l231"></a> tmpb-&gt;exploding=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l232"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l233"></a> tmpb=tmpb1;
<a name="l234"></a> }
<a name="l235"></a>
<a name="l236"></a> </span><span class=cF5>Sleep</span><span class=cF0>(10);
<a name="l237"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l238"></a> </span><span class=cF1>return</span><span class=cF0> 0;
<a name="l239"></a>}
<a name="l240"></a>
<a name="l241"></a></span><span class=cF1>U0</span><span class=cF0> Init()
<a name="l242"></a>{
<a name="l243"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l244"></a> Target *tmpt;
<a name="l245"></a>
<a name="l246"></a> v=20;
<a name="l247"></a> x=-MAP_WIDTH&gt;&gt;1;
<a name="l248"></a> y=-MAP_HEIGHT&gt;&gt;1;
<a name="l249"></a> thetaf=theta=1*</span><span class=cF3>pi</span><span class=cF0>/4;
<a name="l250"></a>
<a name="l251"></a> </span><span class=cF5>QueInit</span><span class=cF0>(&amp;bomb_head);
<a name="l252"></a>
<a name="l253"></a> </span><span class=cF5>MemSet</span><span class=cF0>(trees,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>trees</span><span class=cF7>)</span><span class=cF0>);
<a name="l254"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;TREES_NUM;i++) </span><span class=cF7>{</span><span class=cF0>
<a name="l255"></a> trees[i].x=</span><span class=cF5>RandU32</span><span class=cF0>%MAP_WIDTH -MAP_WIDTH &gt;&gt;1;
<a name="l256"></a> trees[i].y=</span><span class=cF5>RandU32</span><span class=cF0>%MAP_HEIGHT-MAP_HEIGHT&gt;&gt;1;
<a name="l257"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l258"></a>
<a name="l259"></a> </span><span class=cF5>MemSet</span><span class=cF0>(targets,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>targets</span><span class=cF7>)</span><span class=cF0>);
<a name="l260"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;TARGETS_NUM;i++) </span><span class=cF7>{</span><span class=cF0>
<a name="l261"></a> tmpt=&amp;targets[i];
<a name="l262"></a> tmpt-&gt;x=</span><span class=cF5>RandU32</span><span class=cF0>%MAP_WIDTH -MAP_WIDTH &gt;&gt;1;
<a name="l263"></a> tmpt-&gt;y=</span><span class=cF5>RandU32</span><span class=cF0>%MAP_HEIGHT-MAP_HEIGHT&gt;&gt;1;
<a name="l264"></a> </span><span class=cF1>if</span><span class=cF0> (i&lt;TARGETS_NUM/3) {
<a name="l265"></a> tmpt-&gt;type=MDF_BUNKER;
<a name="l266"></a> tmpt-&gt;theta=(</span><span class=cF5>RandU16</span><span class=cF0>&amp;3)*</span><span class=cF3>pi</span><span class=cF0>/2;
<a name="l267"></a> tmpt-&gt;alive_img=</span><span class=cFA>&lt;6&gt;</span><span class=cF0>;
<a name="l268"></a> tmpt-&gt;dead_img1=</span><span class=cFA>&lt;7&gt;</span><span class=cF0>;
<a name="l269"></a> tmpt-&gt;dead_img2=</span><span class=cFA>&lt;8&gt;</span><span class=cF0>;
<a name="l270"></a> } </span><span class=cF1>else</span><span class=cF0> {
<a name="l271"></a> tmpt-&gt;type=MDF_TANK;
<a name="l272"></a> tmpt-&gt;theta=</span><span class=cF5>Rand</span><span class=cF0>*2*</span><span class=cF3>pi</span><span class=cF0>;
<a name="l273"></a> tmpt-&gt;alive_img=</span><span class=cFA>&lt;3&gt;</span><span class=cF0>;
<a name="l274"></a> tmpt-&gt;dead_img1=</span><span class=cFA>&lt;4&gt;</span><span class=cF0>;
<a name="l275"></a> tmpt-&gt;dead_img2=</span><span class=cFA>&lt;5&gt;</span><span class=cF0>;
<a name="l276"></a> }
<a name="l277"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l278"></a> key_cnt=0;
<a name="l279"></a> target_cnt=TARGETS_NUM;
<a name="l280"></a>}
<a name="l281"></a>
<a name="l282"></a></span><span class=cF1>U0</span><span class=cF0> CleanUp()
<a name="l283"></a>{
<a name="l284"></a> </span><span class=cF5>QueDel</span><span class=cF0>(&amp;bomb_head,</span><span class=cF3>TRUE</span><span class=cF0>);
<a name="l285"></a>}
<a name="l286"></a>
<a name="l287"></a></span><span class=cF1>U0</span><span class=cF0> BomberGolf()
<a name="l288"></a>{
<a name="l289"></a> </span><span class=cF9>I64</span><span class=cF0> sc;
<a name="l290"></a> </span><span class=cF5>MenuPush</span><span class=cF0>(
<a name="l291"></a> </span><span class=cF6>&quot;File {&quot;</span><span class=cF0>
<a name="l292"></a> </span><span class=cF6>&quot; Abort(,CH_SHIFT_ESC);&quot;</span><span class=cF0>
<a name="l293"></a> </span><span class=cF6>&quot; Exit(,CH_ESC);&quot;</span><span class=cF0>
<a name="l294"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l295"></a> </span><span class=cF6>&quot;Play {&quot;</span><span class=cF0>
<a name="l296"></a> </span><span class=cF6>&quot; Restart(,'\n');&quot;</span><span class=cF0>
<a name="l297"></a> </span><span class=cF6>&quot; Faster(,,SC_CURSOR_UP);&quot;</span><span class=cF0>
<a name="l298"></a> </span><span class=cF6>&quot; Slower(,,SC_CURSOR_DOWN);&quot;</span><span class=cF0>
<a name="l299"></a> </span><span class=cF6>&quot; Left(,,SC_CURSOR_LEFT);&quot;</span><span class=cF0>
<a name="l300"></a> </span><span class=cF6>&quot; Right(,,SC_CURSOR_RIGHT);&quot;</span><span class=cF0>
<a name="l301"></a> </span><span class=cF6>&quot; Bomb(,CH_SPACE);&quot;</span><span class=cF0>
<a name="l302"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l303"></a> );
<a name="l304"></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="l305"></a> </span><span class=cF5>AutoComplete</span><span class=cF0>;
<a name="l306"></a> </span><span class=cF5>WinBorder</span><span class=cF0>;
<a name="l307"></a> </span><span class=cF5>WinMax</span><span class=cF0>;
<a name="l308"></a> </span><span class=cF5>DocCursor</span><span class=cF0>;
<a name="l309"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
<a name="l310"></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=cF5>Fs</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="l311"></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="l312"></a> Init;
<a name="l313"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l314"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l315"></a> </span><span class=cF1>switch</span><span class=cF0> (</span><span class=cF5>GetKey</span><span class=cF7>(</span><span class=cF0>&amp;sc</span><span class=cF7>)</span><span class=cF0>) {
<a name="l316"></a> </span><span class=cF1>case</span><span class=cF0> 0:
<a name="l317"></a> </span><span class=cF1>switch</span><span class=cF0> (sc.u8[0]) </span><span class=cF7>{</span><span class=cF0>
<a name="l318"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_UP</span><span class=cF0>:
<a name="l319"></a> v+=10;
<a name="l320"></a> </span><span class=cF1>if</span><span class=cF0> (v&gt;300) v=300;
<a name="l321"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l322"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_DOWN</span><span class=cF0>:
<a name="l323"></a> v-=10;
<a name="l324"></a> </span><span class=cF1>if</span><span class=cF0> (v&lt;20) v=20;
<a name="l325"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l326"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_LEFT</span><span class=cF0>:
<a name="l327"></a> key_cnt++;
<a name="l328"></a> thetaf+=1.0/(</span><span class=cF5>Abs</span><span class=cF7>(</span><span class=cF5>Wrap</span><span class=cF0>(thetaf-theta,-</span><span class=cF3>pi</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0>+2*</span><span class=cF3>pi</span><span class=cF0>);
<a name="l329"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l330"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_RIGHT</span><span class=cF0>:
<a name="l331"></a> key_cnt++;
<a name="l332"></a> thetaf-=1.0/(</span><span class=cF5>Abs</span><span class=cF7>(</span><span class=cF5>Wrap</span><span class=cF0>(thetaf-theta,-</span><span class=cF3>pi</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0>+2*</span><span class=cF3>pi</span><span class=cF0>);
<a name="l333"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l334"></a>
<a name="l335"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l336"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l337"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SPACE</span><span class=cF0>:
<a name="l338"></a> key_cnt++;
<a name="l339"></a> BombDrop(-x-0.8*FALL_TIME*v*</span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>theta</span><span class=cF7>)</span><span class=cF0>,-y-0.8*FALL_TIME*v*</span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>theta</span><span class=cF7>)</span><span class=cF0>);
<a name="l340"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l341"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\n'</span><span class=cF0>:
<a name="l342"></a> CleanUp;
<a name="l343"></a> Init;
<a name="l344"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l345"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_ESC</span><span class=cF0>:
<a name="l346"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0>:
<a name="l347"></a> </span><span class=cF1>goto</span><span class=cF0> bm_done;
<a name="l348"></a> }
<a name="l349"></a>bm_done:
<a name="l350"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>catch</span><span class=cF0>
<a name="l351"></a> </span><span class=cF5>PutExcept</span><span class=cF0>;
<a name="l352"></a> </span><span class=cF5>SettingsPop</span><span class=cF0>;
<a name="l353"></a> CleanUp;
<a name="l354"></a> </span><span class=cF5>MenuPop</span><span class=cF0>;
<a name="l355"></a> </span><span class=cF5>RegWrite</span><span class=cF0>(</span><span class=cF6>&quot;TempleOS/BomberGolf&quot;</span><span class=cF0>,</span><span class=cF6>&quot;I64 best_score=%d;\n&quot;</span><span class=cF0>,best_score);
<a name="l356"></a>}
<a name="l357"></a>
<a name="l358"></a>BomberGolf;
</span></pre></body>
</html>