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

431 lines
30 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=cF2>/*Sprites were created with &lt;CTRL-r&gt;</span><span class=cF0>
<a name="l2"></a></span><span class=cF2>and can be edited by moving the</span><span class=cF0>
<a name="l3"></a></span><span class=cF2>cursor on top and pressing &lt;CTRL-r&gt;.</span><span class=cF0>
<a name="l4"></a>
<a name="l5"></a></span><span class=cF2>&lt;CTRL-t&gt; to see the num of the sprite</span><span class=cF0>
<a name="l6"></a></span><span class=cF2>and &lt;CTRL-t&gt; again to get back. Nums</span><span class=cF0>
<a name="l7"></a></span><span class=cF2>are assigned by the editor.</span><span class=cF0>
<a name="l8"></a></span><span class=cF2>*/</span><span class=cF0>
<a name="l9"></a>
<a name="l10"></a>
<a name="l11"></a>
<a name="l12"></a>
<a name="l13"></a>
<a name="l14"></a>
<a name="l15"></a>
<a name="l16"></a> </span><span class=cFA>&lt;1&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l17"></a>
<a name="l18"></a>
<a name="l19"></a>
<a name="l20"></a>
<a name="l21"></a>
<a name="l22"></a>
<a name="l23"></a>
<a name="l24"></a> </span><span class=cFA>&lt;2&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l25"></a>
<a name="l26"></a>
<a name="l27"></a>
<a name="l28"></a>
<a name="l29"></a>
<a name="l30"></a>
<a name="l31"></a>
<a name="l32"></a>
<a name="l33"></a>
<a name="l34"></a>
<a name="l35"></a>
<a name="l36"></a>
<a name="l37"></a> </span><span class=cFA>&lt;3&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l38"></a>
<a name="l39"></a>
<a name="l40"></a>
<a name="l41"></a> </span><span class=cFA>&lt;4&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l42"></a>
<a name="l43"></a>
<a name="l44"></a>
<a name="l45"></a>
<a name="l46"></a>
<a name="l47"></a>
<a name="l48"></a>
<a name="l49"></a> </span><span class=cFA>&lt;5&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l50"></a>
<a name="l51"></a>
<a name="l52"></a>
<a name="l53"></a> </span><span class=cFA>&lt;6&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l54"></a>
<a name="l55"></a></span><span class=cF2>//See </span><a href="/Wb/Doc/Credits.DD.HTML#l1"><span class=cF4>::/Doc/Credits.DD</span></a><span class=cF2>.</span><span class=cF0>
<a name="l56"></a>
<a name="l57"></a>
<a name="l58"></a>
<a name="l59"></a> </span><span class=cFA>&lt;7&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l60"></a>
<a name="l61"></a>
<a name="l62"></a>
<a name="l63"></a>
<a name="l64"></a>
<a name="l65"></a>
<a name="l66"></a> </span><span class=cFA>&lt;8&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l67"></a>
<a name="l68"></a>
<a name="l69"></a>
<a name="l70"></a>
<a name="l71"></a>
<a name="l72"></a>
<a name="l73"></a>
<a name="l74"></a>
<a name="l75"></a>
<a name="l76"></a>
<a name="l77"></a>
<a name="l78"></a>
<a name="l79"></a>
<a name="l80"></a>
<a name="l81"></a>
<a name="l82"></a>
<a name="l83"></a>
<a name="l84"></a>
<a name="l85"></a>
<a name="l86"></a>
<a name="l87"></a>
<a name="l88"></a>
<a name="l89"></a>
<a name="l90"></a>
<a name="l91"></a>
<a name="l92"></a>
<a name="l93"></a>
<a name="l94"></a>
<a name="l95"></a>
<a name="l96"></a>
<a name="l97"></a>
<a name="l98"></a>
<a name="l99"></a>
<a name="l100"></a>
<a name="l101"></a>
<a name="l102"></a>
<a name="l103"></a>
<a name="l104"></a>
<a name="l105"></a>
<a name="l106"></a>
<a name="l107"></a>
<a name="l108"></a>
<a name="l109"></a>
<a name="l110"></a>
<a name="l111"></a>
<a name="l112"></a>
<a name="l113"></a>
<a name="l114"></a>
<a name="l115"></a>
<a name="l116"></a>
<a name="l117"></a>
<a name="l118"></a>
<a name="l119"></a>
<a name="l120"></a>
<a name="l121"></a>
<a name="l122"></a>
<a name="l123"></a>
<a name="l124"></a>
<a name="l125"></a>
<a name="l126"></a>
<a name="l127"></a>
<a name="l128"></a>
<a name="l129"></a>
<a name="l130"></a>
<a name="l131"></a>
<a name="l132"></a>
<a name="l133"></a>
<a name="l134"></a>
<a name="l135"></a>
<a name="l136"></a>
<a name="l137"></a>
<a name="l138"></a>
<a name="l139"></a> </span><span class=cFA>&lt;9&gt;/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l140"></a>
<a name="l141"></a></span><span class=cF5>RegDft</span><span class=cF0>(</span><span class=cF6>&quot;TempleOS/BlackDiamond&quot;</span><span class=cF0>,</span><span class=cF6>&quot;I64 best_score=9999;\n&quot;</span><span class=cF0>);
<a name="l142"></a></span><span class=cF5>RegExe</span><span class=cF0>(</span><span class=cF6>&quot;TempleOS/BlackDiamond&quot;</span><span class=cF0>);
<a name="l143"></a>
<a name="l144"></a>#</span><span class=cF1>define</span><span class=cF0> MAP_HEIGHT 3000
<a name="l145"></a>#</span><span class=cF1>define</span><span class=cF0> OBJS_NUM 128
<a name="l146"></a>
<a name="l147"></a></span><span class=cF9>I64</span><span class=cF0> x,y,scrn_top_y,penalty,chair_lift_num;
<a name="l148"></a></span><span class=cF9>I64</span><span class=cF0> obj_x[OBJS_NUM],obj_y[OBJS_NUM],obj_types[OBJS_NUM],
<a name="l149"></a> obj_saved_x[OBJS_NUM],obj_saved_y[OBJS_NUM];
<a name="l150"></a></span><span class=cF1>Bool</span><span class=cF0> game_over;
<a name="l151"></a>
<a name="l152"></a>#</span><span class=cF1>define</span><span class=cF0> T_TREE 0
<a name="l153"></a>#</span><span class=cF1>define</span><span class=cF0> T_LITTLE_ROCK 1
<a name="l154"></a>#</span><span class=cF1>define</span><span class=cF0> T_BIG_ROCK 2
<a name="l155"></a>#</span><span class=cF1>define</span><span class=cF0> T_WOLF 3
<a name="l156"></a>#</span><span class=cF1>define</span><span class=cF0> T_CHAIR_LIFT 4
<a name="l157"></a></span><span class=cF1>U8</span><span class=cF0> *imgs[5]={</span><span class=cFA>&lt;3&gt;</span><span class=cF0>,</span><span class=cFA>&lt;4&gt;</span><span class=cF0>,</span><span class=cFA>&lt;5&gt;</span><span class=cF0>,</span><span class=cFA>&lt;6&gt;</span><span class=cF0>,</span><span class=cFA>&lt;9&gt;</span><span class=cF0>};
<a name="l158"></a>
<a name="l159"></a>#</span><span class=cF1>define</span><span class=cF0> DC_WOLF_WIDTH 48
<a name="l160"></a>#</span><span class=cF1>define</span><span class=cF0> DC_WOLF_HEIGHT 38
<a name="l161"></a></span><span class=cF1>U0</span><span class=cF0> DrawRunningWolf(</span><span class=cF9>CDC</span><span class=cF0> *dc,</span><span class=cF9>I64</span><span class=cF0> i)
<a name="l162"></a>{</span><span class=cF2>//Draw wolf on small DC so bottom gets clipped looking like sunk into snow.</span><span class=cF0>
<a name="l163"></a></span><span class=cF2>//Then, copy onto main DC.</span><span class=cF0>
<a name="l164"></a> </span><span class=cF1>U8</span><span class=cF0> *tmps;
<a name="l165"></a> </span><span class=cF9>CDC</span><span class=cF0> *dc_wolf=</span><span class=cF5>DCNew</span><span class=cF0>(DC_WOLF_WIDTH,DC_WOLF_HEIGHT);
<a name="l166"></a> </span><span class=cF5>DCFill</span><span class=cF0>(dc_wolf);
<a name="l167"></a> </span><span class=cF1>if</span><span class=cF0> (x&lt;obj_x[i]) </span><span class=cF7>{</span><span class=cF0>
<a name="l168"></a> dc_wolf-&gt;flags|=</span><span class=cF3>DCF_SYMMETRY</span><span class=cF0>|</span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF0>|</span><span class=cF3>DCF_JUST_MIRROR</span><span class=cF0>;
<a name="l169"></a> </span><span class=cF5>DCSymmetrySet</span><span class=cF0>(dc_wolf,DC_WOLF_WIDTH/2,0,DC_WOLF_WIDTH/2,1);
<a name="l170"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l171"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>tS</span><span class=cF0>%1.0&lt;0.5)
<a name="l172"></a> tmps=</span><span class=cFA>&lt;6&gt;</span><span class=cF0>;
<a name="l173"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l174"></a> tmps=</span><span class=cFA>&lt;7&gt;</span><span class=cF0>;
<a name="l175"></a> </span><span class=cF5>Sprite3ZB</span><span class=cF0>(dc_wolf,DC_WOLF_WIDTH/2,0.85*DC_WOLF_HEIGHT,
<a name="l176"></a> 0,tmps,0.4*</span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>7*</span><span class=cF5>tS</span><span class=cF7>)</span><span class=cF0>);
<a name="l177"></a> </span><span class=cF5>GrBlot</span><span class=cF0>(dc,obj_x[i]-DC_WOLF_WIDTH/2,
<a name="l178"></a> obj_y[i]-scrn_top_y-0.85*DC_WOLF_HEIGHT,dc_wolf);
<a name="l179"></a> </span><span class=cF5>DCDel</span><span class=cF0>(dc_wolf);
<a name="l180"></a> </span><span class=cF1>if</span><span class=cF0> (0&lt;=</span><span class=cF7>(</span><span class=cF0>obj_y[i]-scrn_top_y</span><span class=cF7>)</span><span class=cF0>&lt;</span><span class=cF3>GR_HEIGHT</span><span class=cF0>)
<a name="l181"></a> obj_x[i]+=3*</span><span class=cF5>SignI64</span><span class=cF0>(x-obj_x[i]);
<a name="l182"></a>}
<a name="l183"></a>
<a name="l184"></a></span><span class=cF1>U0</span><span class=cF0> DrawMan(</span><span class=cF9>CDC</span><span class=cF0> *dc)
<a name="l185"></a>{
<a name="l186"></a> </span><span class=cF1>if</span><span class=cF0>(dc-&gt;collision_cnt)
<a name="l187"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc,x,y-scrn_top_y,0,</span><span class=cFA>&lt;2&gt;</span><span class=cF0>); </span><span class=cF2>//Red man</span><span class=cF0>
<a name="l188"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l189"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc,x,y-scrn_top_y,0,</span><span class=cFA>&lt;1&gt;</span><span class=cF0>); </span><span class=cF2>//Normal man</span><span class=cF0>
<a name="l190"></a>}
<a name="l191"></a>
<a name="l192"></a>#</span><span class=cF1>define</span><span class=cF0> WIRE_HEIGHT 595
<a name="l193"></a>#</span><span class=cF1>define</span><span class=cF0> WIRE_WIDTH 121
<a name="l194"></a>#</span><span class=cF1>define</span><span class=cF0> WIRE_DIP 800
<a name="l195"></a>#</span><span class=cF1>define</span><span class=cF0> PULLY_WIDTH 13
<a name="l196"></a></span><span class=cF1>U0</span><span class=cF0> DrawUpperChairLift(</span><span class=cF9>CDC</span><span class=cF0> *dc)
<a name="l197"></a>{
<a name="l198"></a> </span><span class=cF9>I64</span><span class=cF0> i=chair_lift_num,x,x1,y=obj_y[i]-scrn_top_y-WIRE_HEIGHT,y1;
<a name="l199"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc,obj_x[i],y+13,0,</span><span class=cFA>&lt;8&gt;</span><span class=cF0>);
<a name="l200"></a> dc-&gt;thick=2;
<a name="l201"></a> </span><span class=cF1>for</span><span class=cF0> (x=-WIRE_WIDTH/2;x&lt;</span><span class=cF3>GR_WIDTH</span><span class=cF0>+WIRE_WIDTH/2;x+=2) </span><span class=cF7>{</span><span class=cF0> </span><span class=cF2>//Pen width is 2, step 2.</span><span class=cF0>
<a name="l202"></a> x1=x-obj_x[i];
<a name="l203"></a> y1=y-WIRE_DIP/2+</span><span class=cF5>Cosh</span><span class=cF0>(</span><span class=cF5>Ln</span><span class=cF7>(</span><span class=cF0>WIRE_DIP</span><span class=cF7>)</span><span class=cF0>+</span><span class=cF7>(</span><span class=cF5>Abs</span><span class=cF0>(x1)-PULLY_WIDTH</span><span class=cF7>)</span><span class=cF0>/10000.0)+0.1*x1;
<a name="l204"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>-PULLY_WIDTH&lt;x1&lt;PULLY_WIDTH</span><span class=cF7>)</span><span class=cF0>) {
<a name="l205"></a> </span><span class=cF5>GrPlot3</span><span class=cF0>(dc,x-WIRE_WIDTH/2,y1,0);
<a name="l206"></a> </span><span class=cF5>GrPlot3</span><span class=cF0>(dc,x+WIRE_WIDTH/2,y1,0);
<a name="l207"></a> }
<a name="l208"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l209"></a> dc-&gt;thick=1;
<a name="l210"></a>}
<a name="l211"></a>
<a name="l212"></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> *,</span><span class=cF9>CDC</span><span class=cF0> *dc)
<a name="l213"></a>{
<a name="l214"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l215"></a> </span><span class=cF1>Bool</span><span class=cF0> man_drawn=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l216"></a>
<a name="l217"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;OBJS_NUM;i++)
<a name="l218"></a> </span><span class=cF1>if</span><span class=cF0> (obj_y[i]-32&lt;=y&lt;=obj_y[i]) </span><span class=cF7>{</span><span class=cF0>
<a name="l219"></a> </span><span class=cF1>if</span><span class=cF0> (obj_types[i]==T_WOLF &amp;&amp; </span><span class=cF5>AbsI64</span><span class=cF7>(</span><span class=cF0>x-obj_x[i]</span><span class=cF7>)</span><span class=cF0>&gt;3)
<a name="l220"></a> DrawRunningWolf(dc,i);
<a name="l221"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l222"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc,obj_x[i],obj_y[i]-scrn_top_y,0,imgs[obj_types[i]]);
<a name="l223"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l224"></a>
<a name="l225"></a> dc-&gt;collision_cnt=0;
<a name="l226"></a> dc-&gt;color=</span><span class=cF3>ROP_COLLISION</span><span class=cF0>;
<a name="l227"></a> dc-&gt;bkcolor=</span><span class=cF3>WHITE</span><span class=cF0>;
<a name="l228"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc,x,y-scrn_top_y,0,</span><span class=cFA>&lt;1&gt;</span><span class=cF0>);
<a name="l229"></a> </span><span class=cF1>if</span><span class=cF0> (!game_over) </span><span class=cF7>{</span><span class=cF0>
<a name="l230"></a> </span><span class=cF1>if</span><span class=cF0>(dc-&gt;collision_cnt) {
<a name="l231"></a> </span><span class=cF5>Snd</span><span class=cF0>(58);
<a name="l232"></a> penalty++; </span><span class=cF2>//Time is irregular. Scoring is imperfect. 30fps more or less.</span><span class=cF0>
<a name="l233"></a> } </span><span class=cF1>else</span><span class=cF0>
<a name="l234"></a> </span><span class=cF5>Snd</span><span class=cF0>;
<a name="l235"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l236"></a>
<a name="l237"></a> dc-&gt;color=</span><span class=cF3>ROP_EQU</span><span class=cF0>;
<a name="l238"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;OBJS_NUM;i++) </span><span class=cF7>{</span><span class=cF0>
<a name="l239"></a> </span><span class=cF1>if</span><span class=cF0> (!man_drawn &amp;&amp; obj_y[i]&gt;=y) {
<a name="l240"></a> DrawMan(dc);
<a name="l241"></a> man_drawn=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l242"></a> }
<a name="l243"></a> </span><span class=cF1>if</span><span class=cF0> (obj_types[i]==T_WOLF &amp;&amp; </span><span class=cF5>AbsI64</span><span class=cF7>(</span><span class=cF0>x-obj_x[i]</span><span class=cF7>)</span><span class=cF0>&gt;3)
<a name="l244"></a> DrawRunningWolf(dc,i);
<a name="l245"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l246"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc,obj_x[i],obj_y[i]-scrn_top_y,0,imgs[obj_types[i]]);
<a name="l247"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l248"></a> </span><span class=cF1>if</span><span class=cF0> (!man_drawn)
<a name="l249"></a> DrawMan(dc);
<a name="l250"></a> DrawUpperChairLift(dc);
<a name="l251"></a>
<a name="l252"></a> dc-&gt;color=</span><span class=cF3>BLACK</span><span class=cF0>;
<a name="l253"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc,0,0,</span><span class=cF6>&quot;Penalty:%d Best:%d&quot;</span><span class=cF0>,penalty,best_score);
<a name="l254"></a> </span><span class=cF1>if</span><span class=cF0> (game_over &amp;&amp; </span><span class=cF5>Blink</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l255"></a> dc-&gt;color=</span><span class=cF3>RED</span><span class=cF0>;
<a name="l256"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc,</span><span class=cF7>(</span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_width-9*</span><span class=cF3>FONT_WIDTH</span><span class=cF7>)</span><span class=cF0>/2,
<a name="l257"></a> </span><span class=cF7>(</span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_height-</span><span class=cF3>FONT_HEIGHT</span><span class=cF7>)</span><span class=cF0>/2,</span><span class=cF6>&quot;Game Over&quot;</span><span class=cF0>);
<a name="l258"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l259"></a>}
<a name="l260"></a>
<a name="l261"></a></span><span class=cF9>I64</span><span class=cF0> Compare(</span><span class=cF9>I64</span><span class=cF0> e1,</span><span class=cF9>I64</span><span class=cF0> e2)
<a name="l262"></a>{
<a name="l263"></a> </span><span class=cF1>return</span><span class=cF0> e1-e2;
<a name="l264"></a>}
<a name="l265"></a>
<a name="l266"></a></span><span class=cF1>U0</span><span class=cF0> Init()
<a name="l267"></a>{
<a name="l268"></a> </span><span class=cF9>I64</span><span class=cF0> i,j;
<a name="l269"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;OBJS_NUM;i++) </span><span class=cF7>{</span><span class=cF0>
<a name="l270"></a> obj_saved_y[i]=</span><span class=cF5>RandU32</span><span class=cF0>%MAP_HEIGHT;
<a name="l271"></a> obj_saved_x[i]=</span><span class=cF5>RandU32</span><span class=cF0>%</span><span class=cF3>GR_WIDTH</span><span class=cF0>;
<a name="l272"></a> j=</span><span class=cF5>RandU16</span><span class=cF0>;
<a name="l273"></a> </span><span class=cF1>if</span><span class=cF0> (j&amp;7)
<a name="l274"></a> obj_types[i]=T_TREE;
<a name="l275"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (j&amp;31)
<a name="l276"></a> obj_types[i]=T_LITTLE_ROCK;
<a name="l277"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (j&amp;63)
<a name="l278"></a> obj_types[i]=T_BIG_ROCK;
<a name="l279"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l280"></a> obj_types[i]=T_WOLF;
<a name="l281"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l282"></a> </span><span class=cF5>QSortI64</span><span class=cF0>(obj_saved_y,OBJS_NUM,&amp;Compare); </span><span class=cF2>//Break associations. Doesn't matter.</span><span class=cF0>
<a name="l283"></a>
<a name="l284"></a> chair_lift_num=</span><span class=cF5>RandU16</span><span class=cF0>%OBJS_NUM;
<a name="l285"></a> obj_types[chair_lift_num]=T_CHAIR_LIFT;
<a name="l286"></a>}
<a name="l287"></a>
<a name="l288"></a></span><span class=cF1>U0</span><span class=cF0> BlackDiamond()
<a name="l289"></a>{
<a name="l290"></a> </span><span class=cF9>I64</span><span class=cF0> ch,sc;
<a name="l291"></a>
<a name="l292"></a> </span><span class=cF5>MenuPush</span><span class=cF0>(
<a name="l293"></a> </span><span class=cF6>&quot;File {&quot;</span><span class=cF0>
<a name="l294"></a> </span><span class=cF6>&quot; New(,'\n');&quot;</span><span class=cF0>
<a name="l295"></a> </span><span class=cF6>&quot; Restart(,CH_SPACE);&quot;</span><span class=cF0>
<a name="l296"></a> </span><span class=cF6>&quot; Abort(,CH_SHIFT_ESC);&quot;</span><span class=cF0>
<a name="l297"></a> </span><span class=cF6>&quot; Exit(,CH_ESC);&quot;</span><span class=cF0>
<a name="l298"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l299"></a> </span><span class=cF6>&quot;Play {&quot;</span><span class=cF0>
<a name="l300"></a> </span><span class=cF6>&quot; Up(,,SC_CURSOR_UP);&quot;</span><span class=cF0>
<a name="l301"></a> </span><span class=cF6>&quot; Down(,,SC_CURSOR_DOWN);&quot;</span><span class=cF0>
<a name="l302"></a> </span><span class=cF6>&quot; Left(,,SC_CURSOR_LEFT);&quot;</span><span class=cF0>
<a name="l303"></a> </span><span class=cF6>&quot; Right(,,SC_CURSOR_RIGHT);&quot;</span><span class=cF0>
<a name="l304"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l305"></a> );
<a name="l306"></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="l307"></a> </span><span class=cF5>AutoComplete</span><span class=cF0>;
<a name="l308"></a> </span><span class=cF5>WinBorder</span><span class=cF0>;
<a name="l309"></a> </span><span class=cF5>WinMax</span><span class=cF0>;
<a name="l310"></a> </span><span class=cF5>DocCursor</span><span class=cF0>;
<a name="l311"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
<a name="l312"></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="l313"></a>
<a name="l314"></a> Init;
<a name="l315"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l316"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) {
<a name="l317"></a>bd_restart:
<a name="l318"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(obj_x,obj_saved_x,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>obj_x</span><span class=cF7>)</span><span class=cF0>); </span><span class=cF2>//Wolves move. We must reset the</span><span class=cF0>
<a name="l319"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(obj_y,obj_saved_y,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>obj_y</span><span class=cF7>)</span><span class=cF0>); </span><span class=cF2>//wolves if running same game.</span><span class=cF0>
<a name="l320"></a>
<a name="l321"></a> game_over=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l322"></a> scrn_top_y=0;
<a name="l323"></a> x=</span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_width&gt;&gt;1; y=0;
<a name="l324"></a> penalty=0;
<a name="l325"></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="l326"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>ScanKey</span><span class=cF7>(</span><span class=cF0>&amp;ch,&amp;sc</span><span class=cF7>)</span><span class=cF0>) {
<a name="l327"></a> </span><span class=cF1>switch</span><span class=cF0> (ch) </span><span class=cF7>{</span><span class=cF0>
<a name="l328"></a> </span><span class=cF1>case</span><span class=cF0> 0:
<a name="l329"></a> </span><span class=cF1>if</span><span class=cF0> (!game_over)
<a name="l330"></a> </span><span class=cF1>switch</span><span class=cF0> (sc.u8[0]) {
<a name="l331"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_RIGHT</span><span class=cF0>:
<a name="l332"></a> x+=10;
<a name="l333"></a> </span><span class=cF1>if</span><span class=cF0> (x&gt;=</span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_width) x-=</span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_width;
<a name="l334"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l335"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_LEFT</span><span class=cF0>:
<a name="l336"></a> x-=10;
<a name="l337"></a> </span><span class=cF1>if</span><span class=cF0> (x&lt;0) x+=</span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_width;
<a name="l338"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l339"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_UP</span><span class=cF0>:
<a name="l340"></a> y-=10;
<a name="l341"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l342"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_DOWN</span><span class=cF0>:
<a name="l343"></a> y+=10;
<a name="l344"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l345"></a> }
<a name="l346"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l347"></a>
<a name="l348"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_ESC</span><span class=cF0>:
<a name="l349"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0>:
<a name="l350"></a> </span><span class=cF1>goto</span><span class=cF0> bd_done;
<a name="l351"></a>
<a name="l352"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\n'</span><span class=cF0>:
<a name="l353"></a> Init;
<a name="l354"></a> </span><span class=cF1>goto</span><span class=cF0> bd_restart;
<a name="l355"></a>
<a name="l356"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SPACE</span><span class=cF0>:
<a name="l357"></a> game_over=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l358"></a> </span><span class=cF1>while</span><span class=cF0> (scrn_top_y&gt;0||y&gt;0) {</span><span class=cF2>//Animate going back to top.</span><span class=cF0>
<a name="l359"></a> scrn_top_y=</span><span class=cF5>MaxI64</span><span class=cF0>(0,scrn_top_y-4);
<a name="l360"></a> y=</span><span class=cF5>MaxI64</span><span class=cF0>(0,y-4);
<a name="l361"></a> x+=</span><span class=cF5>SignI64</span><span class=cF0>(</span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_width&gt;&gt;1-x);
<a name="l362"></a> </span><span class=cF5>Sleep</span><span class=cF0>(1);
<a name="l363"></a> }
<a name="l364"></a> </span><span class=cF5>Snd</span><span class=cF0>;
<a name="l365"></a> </span><span class=cF1>goto</span><span class=cF0> bd_restart;
<a name="l366"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l367"></a></span><span class=cF2>//Don't want keystrokes building-up in the buf.</span><span class=cF0>
<a name="l368"></a> </span><span class=cF5>FlushMsgs</span><span class=cF0>;
<a name="l369"></a> }
<a name="l370"></a> </span><span class=cF1>if</span><span class=cF0> (!game_over) {
<a name="l371"></a> y+=2;
<a name="l372"></a> scrn_top_y++;
<a name="l373"></a> </span><span class=cF1>if</span><span class=cF0> (y-scrn_top_y&gt;</span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_height) </span><span class=cF7>{</span><span class=cF2>//Animate scrolling scrn.</span><span class=cF0>
<a name="l374"></a> </span><span class=cF1>while</span><span class=cF0> (y-scrn_top_y&gt;</span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_height&gt;&gt;1) {
<a name="l375"></a> scrn_top_y+=2;
<a name="l376"></a> </span><span class=cF5>Sleep</span><span class=cF0>(1);
<a name="l377"></a> }
<a name="l378"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l379"></a> </span><span class=cF1>if</span><span class=cF0> (y&gt;=MAP_HEIGHT) </span><span class=cF7>{</span><span class=cF0>
<a name="l380"></a> game_over=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l381"></a> </span><span class=cF5>Beep</span><span class=cF0>;
<a name="l382"></a> </span><span class=cF1>if</span><span class=cF0> (penalty&lt;=best_score) {
<a name="l383"></a> best_score=penalty;
<a name="l384"></a> </span><span class=cF5>Beep</span><span class=cF0>;
<a name="l385"></a> }
<a name="l386"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l387"></a> }
<a name="l388"></a> </span><span class=cF5>Sleep</span><span class=cF0>(10);
<a name="l389"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l390"></a> }
<a name="l391"></a>bd_done:
<a name="l392"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>catch</span><span class=cF0>
<a name="l393"></a> </span><span class=cF5>PutExcept</span><span class=cF0>;
<a name="l394"></a> </span><span class=cF5>SettingsPop</span><span class=cF0>;
<a name="l395"></a> </span><span class=cF5>MenuPop</span><span class=cF0>;
<a name="l396"></a> </span><span class=cF5>RegWrite</span><span class=cF0>(</span><span class=cF6>&quot;TempleOS/BlackDiamond&quot;</span><span class=cF0>,</span><span class=cF6>&quot;I64 best_score=%d;\n&quot;</span><span class=cF0>,best_score);
<a name="l397"></a>}
<a name="l398"></a>
<a name="l399"></a>BlackDiamond; </span><span class=cF2>//Start game when #included.</span><span class=cF0>
</span></pre></body>
</html>