ZealOS/docs/Demo/Games/BlackDiamond.CC.html
2021-09-21 23:45:45 -04:00

456 lines
37 KiB
HTML
Executable file

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
<meta name="generator" content="ZealOS V1.01">
<style type="text/css">
body {background-color:#fef1f0;}
.cF0{color:#000000;background-color:#fef1f0;}
.cF1{color:#0148a4;background-color:#fef1f0;}
.cF2{color:#3b7901;background-color:#fef1f0;}
.cF3{color:#057c7e;background-color:#fef1f0;}
.cF4{color:#bb2020;background-color:#fef1f0;}
.cF5{color:#9e42ae;background-color:#fef1f0;}
.cF6{color:#b57901;background-color:#fef1f0;}
.cF7{color:#b2b6af;background-color:#fef1f0;}
.cF8{color:#555753;background-color:#fef1f0;}
.cF9{color:#678fbb;background-color:#fef1f0;}
.cFA{color:#82bc49;background-color:#fef1f0;}
.cFB{color:#0097a2;background-color:#fef1f0;}
.cFC{color:#e26a6a;background-color:#fef1f0;}
.cFD{color:#c671bc;background-color:#fef1f0;}
.cFE{color:#c7ab00;background-color:#fef1f0;}
.cFF{color:#fef1f0;background-color:#fef1f0;}
</style>
</head>
<body>
<pre style="font-family:monospace;font-size:12pt">
<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="https://zeal-operating-system.github.io/ZealOS/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>RegDefault</span><span class=cF0>(</span><span class=cF6>&quot;ZealOS/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;ZealOS/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 </span><span class=cFE>3000</span><span class=cF0>
<a name="l145"></a>#</span><span class=cF1>define</span><span class=cF0> OBJS_NUM </span><span class=cFE>128</span><span class=cF0>
<a name="l146"></a>
<a name="l147"></a></span><span class=cF9>I64</span><span class=cF0> x, y, screen_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], obj_saved_x[OBJS_NUM], obj_saved_y[OBJS_NUM];
<a name="l149"></a></span><span class=cF1>Bool</span><span class=cF0> game_over;
<a name="l150"></a>
<a name="l151"></a>#</span><span class=cF1>define</span><span class=cF0> T_TREE </span><span class=cFE>0</span><span class=cF0>
<a name="l152"></a>#</span><span class=cF1>define</span><span class=cF0> T_LITTLE_ROCK </span><span class=cFE>1</span><span class=cF0>
<a name="l153"></a>#</span><span class=cF1>define</span><span class=cF0> T_BIG_ROCK </span><span class=cFE>2</span><span class=cF0>
<a name="l154"></a>#</span><span class=cF1>define</span><span class=cF0> T_WOLF </span><span class=cFE>3</span><span class=cF0>
<a name="l155"></a>#</span><span class=cF1>define</span><span class=cF0> T_CHAIR_LIFT </span><span class=cFE>4</span><span class=cF0>
<a name="l156"></a></span><span class=cF1>U8</span><span class=cF0> *imgs[</span><span class=cFE>5</span><span class=cF0>] = {</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="l157"></a>
<a name="l158"></a>#</span><span class=cF1>define</span><span class=cF0> DC_WOLF_WIDTH </span><span class=cFE>48</span><span class=cF0>
<a name="l159"></a>#</span><span class=cF1>define</span><span class=cF0> DC_WOLF_HEIGHT </span><span class=cFE>38</span><span class=cF0>
<a name="l160"></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="l161"></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="l162"></a></span><span class=cF2>//Then, copy onto main DC.</span><span class=cF0>
<a name="l163"></a> </span><span class=cF1>U8</span><span class=cF0> *tmps;
<a name="l164"></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="l165"></a>
<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])
<a name="l168"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l169"></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="l170"></a> </span><span class=cF5>DCSymmetrySet</span><span class=cF0>(dc_wolf, DC_WOLF_WIDTH / </span><span class=cFE>2</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>, DC_WOLF_WIDTH / </span><span class=cFE>2</span><span class=cF0>, </span><span class=cFE>1</span><span class=cF0>);
<a name="l171"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l172"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>tS</span><span class=cF0> % </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> &lt; </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0>)
<a name="l173"></a> tmps = </span><span class=cFA>&lt;6&gt;</span><span class=cF0>;
<a name="l174"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l175"></a> tmps = </span><span class=cFA>&lt;7&gt;</span><span class=cF0>;
<a name="l176"></a> </span><span class=cF5>Sprite3ZB</span><span class=cF0>(dc_wolf, DC_WOLF_WIDTH / </span><span class=cFE>2</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>85</span><span class=cF0> * DC_WOLF_HEIGHT, </span><span class=cFE>0</span><span class=cF0>, tmps, </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>4</span><span class=cF0> * </span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cFE>7</span><span class=cF0> * </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 / </span><span class=cFE>2</span><span class=cF0>, obj_y[i] - screen_top_y - </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>85</span><span class=cF0> * DC_WOLF_HEIGHT, dc_wolf);
<a name="l178"></a> </span><span class=cF5>DCDel</span><span class=cF0>(dc_wolf);
<a name="l179"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFE>0</span><span class=cF0> &lt;= </span><span class=cF7>(</span><span class=cF0>obj_y[i] - screen_top_y</span><span class=cF7>)</span><span class=cF0> &lt; </span><span class=cF3>GR_HEIGHT</span><span class=cF0>)
<a name="l180"></a> obj_x[i] += </span><span class=cFE>3</span><span class=cF0> * </span><span class=cF5>SignI64</span><span class=cF0>(x - obj_x[i]);
<a name="l181"></a>}
<a name="l182"></a>
<a name="l183"></a></span><span class=cF1>U0</span><span class=cF0> DrawMan(</span><span class=cF9>CDC</span><span class=cF0> *dc)
<a name="l184"></a>{
<a name="l185"></a> </span><span class=cF1>if</span><span class=cF0> (dc-&gt;collision_count)
<a name="l186"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc, x, y - screen_top_y, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cFA>&lt;2&gt;</span><span class=cF0>); </span><span class=cF2>//Red man</span><span class=cF0>
<a name="l187"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l188"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc, x, y - screen_top_y, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cFA>&lt;1&gt;</span><span class=cF0>); </span><span class=cF2>//Normal man</span><span class=cF0>
<a name="l189"></a>}
<a name="l190"></a>
<a name="l191"></a>#</span><span class=cF1>define</span><span class=cF0> WIRE_HEIGHT </span><span class=cFE>595</span><span class=cF0>
<a name="l192"></a>#</span><span class=cF1>define</span><span class=cF0> WIRE_WIDTH </span><span class=cFE>121</span><span class=cF0>
<a name="l193"></a>#</span><span class=cF1>define</span><span class=cF0> WIRE_DIP </span><span class=cFE>800</span><span class=cF0>
<a name="l194"></a>#</span><span class=cF1>define</span><span class=cF0> PULLY_WIDTH </span><span class=cFE>13</span><span class=cF0>
<a name="l195"></a></span><span class=cF1>U0</span><span class=cF0> DrawUpperChairLift(</span><span class=cF9>CDC</span><span class=cF0> *dc)
<a name="l196"></a>{
<a name="l197"></a> </span><span class=cF9>I64</span><span class=cF0> i = chair_lift_num, x, x1, y = obj_y[i] - screen_top_y - WIRE_HEIGHT, y1;
<a name="l198"></a>
<a name="l199"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc, obj_x[i], y + </span><span class=cFE>13</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cFA>&lt;8&gt;</span><span class=cF0>);
<a name="l200"></a> dc-&gt;thick = </span><span class=cFE>2</span><span class=cF0>;
<a name="l201"></a> </span><span class=cF1>for</span><span class=cF0> (x = -WIRE_WIDTH / </span><span class=cFE>2</span><span class=cF0>; x &lt; </span><span class=cF3>GR_WIDTH</span><span class=cF0> + WIRE_WIDTH / </span><span class=cFE>2</span><span class=cF0>; x += </span><span class=cFE>2</span><span class=cF0>)
<a name="l202"></a> </span><span class=cF7>{</span><span class=cF0> </span><span class=cF2>//Pen width is 2, step 2.</span><span class=cF0>
<a name="l203"></a> x1 = x - obj_x[i];
<a name="l204"></a> y1 = y - WIRE_DIP / </span><span class=cFE>2</span><span class=cF0> + </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> / </span><span class=cFE>10000</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>) + </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>1</span><span class=cF0> * x1;
<a name="l205"></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="l206"></a> {
<a name="l207"></a> </span><span class=cF5>GrPlot3</span><span class=cF0>(dc, x - WIRE_WIDTH / </span><span class=cFE>2</span><span class=cF0>, y1, </span><span class=cFE>0</span><span class=cF0>);
<a name="l208"></a> </span><span class=cF5>GrPlot3</span><span class=cF0>(dc, x + WIRE_WIDTH / </span><span class=cFE>2</span><span class=cF0>, y1, </span><span class=cFE>0</span><span class=cF0>);
<a name="l209"></a> }
<a name="l210"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l211"></a> dc-&gt;thick = </span><span class=cFE>1</span><span class=cF0>;
<a name="l212"></a>}
<a name="l213"></a>
<a name="l214"></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="l215"></a>{
<a name="l216"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l217"></a> </span><span class=cF1>Bool</span><span class=cF0> man_drawn = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l218"></a>
<a name="l219"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; OBJS_NUM; i++)
<a name="l220"></a> </span><span class=cF1>if</span><span class=cF0> (obj_y[i] - </span><span class=cFE>32</span><span class=cF0> &lt;= y &lt;= obj_y[i])
<a name="l221"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l222"></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; </span><span class=cFE>3</span><span class=cF0>)
<a name="l223"></a> DrawRunningWolf(dc, i);
<a name="l224"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l225"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc, obj_x[i], obj_y[i] - screen_top_y, </span><span class=cFE>0</span><span class=cF0>, imgs[obj_types[i]]);
<a name="l226"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l227"></a>
<a name="l228"></a> dc-&gt;collision_count = </span><span class=cFE>0</span><span class=cF0>;
<a name="l229"></a> dc-&gt;color = </span><span class=cF3>ROP_COLLISION</span><span class=cF0>;
<a name="l230"></a> dc-&gt;bkcolor = </span><span class=cF3>WHITE</span><span class=cF0>;
<a name="l231"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc, x, y - screen_top_y, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cFA>&lt;1&gt;</span><span class=cF0>);
<a name="l232"></a> </span><span class=cF1>if</span><span class=cF0> (!game_over)
<a name="l233"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l234"></a> </span><span class=cF1>if</span><span class=cF0> (dc-&gt;collision_count)
<a name="l235"></a> {
<a name="l236"></a> </span><span class=cF5>Sound</span><span class=cF0>(</span><span class=cFE>58</span><span class=cF0>);
<a name="l237"></a> penalty++; </span><span class=cF2>//Time is irregular. Scoring is imperfect. 60fps more or less.</span><span class=cF0>
<a name="l238"></a> }
<a name="l239"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l240"></a> </span><span class=cF5>Sound</span><span class=cF0>;
<a name="l241"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l242"></a>
<a name="l243"></a> dc-&gt;color = </span><span class=cF3>ROP_EQU</span><span class=cF0>;
<a name="l244"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; OBJS_NUM; i++)
<a name="l245"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l246"></a> </span><span class=cF1>if</span><span class=cF0> (!man_drawn &amp;&amp; obj_y[i] &gt;= y)
<a name="l247"></a> {
<a name="l248"></a> DrawMan(dc);
<a name="l249"></a> man_drawn = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l250"></a> }
<a name="l251"></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; </span><span class=cFE>3</span><span class=cF0>)
<a name="l252"></a> DrawRunningWolf(dc, i);
<a name="l253"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l254"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc, obj_x[i], obj_y[i] - screen_top_y, </span><span class=cFE>0</span><span class=cF0>, imgs[obj_types[i]]);
<a name="l255"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l256"></a> </span><span class=cF1>if</span><span class=cF0> (!man_drawn)
<a name="l257"></a> DrawMan(dc);
<a name="l258"></a> DrawUpperChairLift(dc);
<a name="l259"></a>
<a name="l260"></a> dc-&gt;color = </span><span class=cF3>BLACK</span><span class=cF0>;
<a name="l261"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cF6>&quot;Penalty:%d Best:%d&quot;</span><span class=cF0>, penalty, best_score);
<a name="l262"></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="l263"></a> dc-&gt;color = </span><span class=cF3>RED</span><span class=cF0>;
<a name="l264"></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 - </span><span class=cFE>9</span><span class=cF0> * </span><span class=cF3>FONT_WIDTH</span><span class=cF7>)</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>, </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> / </span><span class=cFE>2</span><span class=cF0>, </span><span class=cF6>&quot;Game Over&quot;</span><span class=cF0>);
<a name="l265"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l266"></a>}
<a name="l267"></a>
<a name="l268"></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="l269"></a>{
<a name="l270"></a> </span><span class=cF1>return</span><span class=cF0> e1 - e2;
<a name="l271"></a>}
<a name="l272"></a>
<a name="l273"></a></span><span class=cF1>U0</span><span class=cF0> Init()
<a name="l274"></a>{
<a name="l275"></a> </span><span class=cF9>I64</span><span class=cF0> i, j;
<a name="l276"></a>
<a name="l277"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; OBJS_NUM; i++)
<a name="l278"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l279"></a> obj_saved_y[i] = </span><span class=cF5>RandU32</span><span class=cF0> % MAP_HEIGHT;
<a name="l280"></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="l281"></a> j = </span><span class=cF5>RandU16</span><span class=cF0>;
<a name="l282"></a> </span><span class=cF1>if</span><span class=cF0> (j &amp; </span><span class=cFE>7</span><span class=cF0>)
<a name="l283"></a> obj_types[i] = T_TREE;
<a name="l284"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (j &amp; </span><span class=cFE>31</span><span class=cF0>)
<a name="l285"></a> obj_types[i] = T_LITTLE_ROCK;
<a name="l286"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (j &amp; </span><span class=cFE>63</span><span class=cF0>)
<a name="l287"></a> obj_types[i] = T_BIG_ROCK;
<a name="l288"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l289"></a> obj_types[i] = T_WOLF;
<a name="l290"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l291"></a> </span><span class=cF5>QuickSortI64</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="l292"></a>
<a name="l293"></a> chair_lift_num = </span><span class=cF5>RandU16</span><span class=cF0> % OBJS_NUM;
<a name="l294"></a> obj_types[chair_lift_num] = T_CHAIR_LIFT;
<a name="l295"></a>}
<a name="l296"></a>
<a name="l297"></a></span><span class=cF1>U0</span><span class=cF0> BlackDiamond()
<a name="l298"></a>{
<a name="l299"></a> </span><span class=cF9>I64</span><span class=cF0> ch, sc;
<a name="l300"></a>
<a name="l301"></a> </span><span class=cF5>MenuPush</span><span class=cF0>(
<a name="l302"></a> </span><span class=cF6>&quot;File {&quot;</span><span class=cF0>
<a name="l303"></a> </span><span class=cF6>&quot; New(,'\n');&quot;</span><span class=cF0>
<a name="l304"></a> </span><span class=cF6>&quot; Restart(,CH_SPACE);&quot;</span><span class=cF0>
<a name="l305"></a> </span><span class=cF6>&quot; Abort(,CH_SHIFT_ESC);&quot;</span><span class=cF0>
<a name="l306"></a> </span><span class=cF6>&quot; Exit(,CH_ESC);&quot;</span><span class=cF0>
<a name="l307"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l308"></a> </span><span class=cF6>&quot;Play {&quot;</span><span class=cF0>
<a name="l309"></a> </span><span class=cF6>&quot; Up(,,SC_CURSOR_UP);&quot;</span><span class=cF0>
<a name="l310"></a> </span><span class=cF6>&quot; Down(,,SC_CURSOR_DOWN);&quot;</span><span class=cF0>
<a name="l311"></a> </span><span class=cF6>&quot; Left(,,SC_CURSOR_LEFT);&quot;</span><span class=cF0>
<a name="l312"></a> </span><span class=cF6>&quot; Right(,,SC_CURSOR_RIGHT);&quot;</span><span class=cF0>
<a name="l313"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l314"></a> );
<a name="l315"></a> </span><span class=cF5>SettingsPush</span><span class=cF0>; </span><span class=cF2>//See </span><a href="https://zeal-operating-system.github.io/ZealOS/System/TaskSettings.CC.html#l3"><span class=cF4>SettingsPush</span></a><span class=cF0>
<a name="l316"></a> </span><span class=cF5>AutoComplete</span><span class=cF0>;
<a name="l317"></a> </span><span class=cF5>WinBorder</span><span class=cF0>;
<a name="l318"></a> </span><span class=cF5>WinMax</span><span class=cF0>;
<a name="l319"></a> </span><span class=cF5>DocCursor</span><span class=cF0>;
<a name="l320"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
<a name="l321"></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="l322"></a>
<a name="l323"></a> Init;
<a name="l324"></a> </span><span class=cF1>try</span><span class=cF0>
<a name="l325"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l326"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l327"></a> {
<a name="l328"></a>bd_restart:
<a name="l329"></a> </span><span class=cF5>MemCopy</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="l330"></a> </span><span class=cF5>MemCopy</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="l331"></a>
<a name="l332"></a> game_over = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l333"></a> screen_top_y = </span><span class=cFE>0</span><span class=cF0>;
<a name="l334"></a> x = </span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_width &gt;&gt; </span><span class=cFE>1</span><span class=cF0>;
<a name="l335"></a> y = </span><span class=cFE>0</span><span class=cF0>;
<a name="l336"></a> penalty = </span><span class=cFE>0</span><span class=cF0>;
<a name="l337"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l338"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l339"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>KeyScan</span><span class=cF7>(</span><span class=cF0>&amp;ch, &amp;sc</span><span class=cF7>)</span><span class=cF0>)
<a name="l340"></a> {
<a name="l341"></a> </span><span class=cF1>switch</span><span class=cF0> (ch)
<a name="l342"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l343"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>:
<a name="l344"></a> </span><span class=cF1>if</span><span class=cF0> (!game_over)
<a name="l345"></a> </span><span class=cF1>switch</span><span class=cF0> (sc.u8[</span><span class=cFE>0</span><span class=cF0>])
<a name="l346"></a> {
<a name="l347"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_RIGHT</span><span class=cF0>:
<a name="l348"></a> x += </span><span class=cFE>10</span><span class=cF0>;
<a name="l349"></a> </span><span class=cF1>if</span><span class=cF0> (x &gt;= </span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_width)
<a name="l350"></a> x -= </span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_width;
<a name="l351"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l352"></a>
<a name="l353"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_LEFT</span><span class=cF0>:
<a name="l354"></a> x -= </span><span class=cFE>10</span><span class=cF0>;
<a name="l355"></a> </span><span class=cF1>if</span><span class=cF0> (x &lt; </span><span class=cFE>0</span><span class=cF0>)
<a name="l356"></a> x += </span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_width;
<a name="l357"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l358"></a>
<a name="l359"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_UP</span><span class=cF0>:
<a name="l360"></a> y -= </span><span class=cFE>10</span><span class=cF0>;
<a name="l361"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l362"></a>
<a name="l363"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_DOWN</span><span class=cF0>:
<a name="l364"></a> y += </span><span class=cFE>10</span><span class=cF0>;
<a name="l365"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l366"></a> }
<a name="l367"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l368"></a>
<a name="l369"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_ESC</span><span class=cF0>:
<a name="l370"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0>:
<a name="l371"></a> </span><span class=cF1>goto</span><span class=cF0> bd_done;
<a name="l372"></a>
<a name="l373"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\n'</span><span class=cF0>:
<a name="l374"></a> Init;
<a name="l375"></a> </span><span class=cF1>goto</span><span class=cF0> bd_restart;
<a name="l376"></a>
<a name="l377"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SPACE</span><span class=cF0>:
<a name="l378"></a> game_over = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l379"></a> </span><span class=cF1>while</span><span class=cF0> (screen_top_y &gt; </span><span class=cFE>0</span><span class=cF0> || y &gt; </span><span class=cFE>0</span><span class=cF0>)
<a name="l380"></a> {</span><span class=cF2>//Animate going back to top.</span><span class=cF0>
<a name="l381"></a> screen_top_y = </span><span class=cF5>MaxI64</span><span class=cF0>(</span><span class=cFE>0</span><span class=cF0>, screen_top_y - </span><span class=cFE>4</span><span class=cF0>);
<a name="l382"></a> y = </span><span class=cF5>MaxI64</span><span class=cF0>(</span><span class=cFE>0</span><span class=cF0>, y - </span><span class=cFE>4</span><span class=cF0>);
<a name="l383"></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; </span><span class=cFE>1</span><span class=cF0> - x);
<a name="l384"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>1</span><span class=cF0>);
<a name="l385"></a> }
<a name="l386"></a> </span><span class=cF5>Sound</span><span class=cF0>;
<a name="l387"></a> </span><span class=cF1>goto</span><span class=cF0> bd_restart;
<a name="l388"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l389"></a></span><span class=cF2>//Don't want keystrokes building-up in the buf.</span><span class=cF0>
<a name="l390"></a> </span><span class=cF5>FlushMessages</span><span class=cF0>;
<a name="l391"></a> }
<a name="l392"></a> </span><span class=cF1>if</span><span class=cF0> (!game_over)
<a name="l393"></a> {
<a name="l394"></a> y += </span><span class=cFE>2</span><span class=cF0>;
<a name="l395"></a> screen_top_y++;
<a name="l396"></a> </span><span class=cF1>if</span><span class=cF0> (y - screen_top_y &gt; </span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_height)
<a name="l397"></a> </span><span class=cF7>{</span><span class=cF2>//Animate scrolling screen.</span><span class=cF0>
<a name="l398"></a> </span><span class=cF1>while</span><span class=cF0> (y - screen_top_y &gt; </span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_height &gt;&gt; </span><span class=cFE>1</span><span class=cF0>)
<a name="l399"></a> {
<a name="l400"></a> screen_top_y += </span><span class=cFE>2</span><span class=cF0>;
<a name="l401"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>1</span><span class=cF0>);
<a name="l402"></a> }
<a name="l403"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l404"></a> </span><span class=cF1>if</span><span class=cF0> (y &gt;= MAP_HEIGHT)
<a name="l405"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l406"></a> game_over = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l407"></a> </span><span class=cF5>Beep</span><span class=cF0>;
<a name="l408"></a> </span><span class=cF1>if</span><span class=cF0> (penalty &lt;= best_score)
<a name="l409"></a> {
<a name="l410"></a> best_score = penalty;
<a name="l411"></a> </span><span class=cF5>Beep</span><span class=cF0>;
<a name="l412"></a> }
<a name="l413"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l414"></a> }
<a name="l415"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>10</span><span class=cF0>);
<a name="l416"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l417"></a> }
<a name="l418"></a>bd_done:
<a name="l419"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l420"></a> </span><span class=cF1>catch</span><span class=cF0>
<a name="l421"></a> </span><span class=cF5>PutExcept</span><span class=cF0>;
<a name="l422"></a> </span><span class=cF5>SettingsPop</span><span class=cF0>;
<a name="l423"></a> </span><span class=cF5>MenuPop</span><span class=cF0>;
<a name="l424"></a> </span><span class=cF5>RegWrite</span><span class=cF0>(</span><span class=cF6>&quot;ZealOS/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="l425"></a>}
<a name="l426"></a>
<a name="l427"></a>BlackDiamond; </span><span class=cF2>//Start game when #included.</span><span class=cF0>
</span></pre></body>
</html>