mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-29 16:56:30 +00:00
dbf8647d59
Added top & right borders to RawDr. Improved spacing in some debug and compiler reporting. Fixed RawPutChar and EdLite tab width. Fixed Ui missing '0x' prefix syntax highlighter bug. Added 32BitPaint demo.
674 lines
69 KiB
HTML
Executable file
674 lines
69 KiB
HTML
Executable file
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
|
|
<meta name="generator" content="ZealOS V0.08">
|
|
<style type="text/css">
|
|
body {background-color:#000000;}
|
|
.cF0{color:#ffffff;background-color:#000000;}
|
|
.cF1{color:#3465a4;background-color:#000000;}
|
|
.cF2{color:#4e9a06;background-color:#000000;}
|
|
.cF3{color:#06989a;background-color:#000000;}
|
|
.cF4{color:#a24444;background-color:#000000;}
|
|
.cF5{color:#75507b;background-color:#000000;}
|
|
.cF6{color:#ce982f;background-color:#000000;}
|
|
.cF7{color:#bcc0b9;background-color:#000000;}
|
|
.cF8{color:#555753;background-color:#000000;}
|
|
.cF9{color:#729fcf;background-color:#000000;}
|
|
.cFA{color:#82bc49;background-color:#000000;}
|
|
.cFB{color:#34e2e2;background-color:#000000;}
|
|
.cFC{color:#ac3535;background-color:#000000;}
|
|
.cFD{color:#ad7fa8;background-color:#000000;}
|
|
.cFE{color:#fce94f;background-color:#000000;}
|
|
.cFF{color:#000000;background-color:#000000;}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<pre style="font-family:monospace;font-size:12pt">
|
|
<a name="l1"></a><span class=cF2>//Uses </span><a href="https://tomawezome.github.io/ZealOS/Demo/Lectures/FixedPoint.CC.html#l1"><span class=cF4>fixed-point</span></a><span class=cF2>.</span><span class=cF0>
|
|
<a name="l2"></a>
|
|
<a name="l3"></a></span><span class=cF5>RegDefault</span><span class=cF0>(</span><span class=cF6>"ZealOS/RawHide"</span><span class=cF0>, </span><span class=cF6>"F64 best_score=9999;\n"</span><span class=cF0>);
|
|
<a name="l4"></a></span><span class=cF5>RegExe</span><span class=cF0>(</span><span class=cF6>"ZealOS/RawHide"</span><span class=cF0>);
|
|
<a name="l5"></a>
|
|
<a name="l6"></a></span><span class=cF1>F64</span><span class=cF0> t0, tf;
|
|
<a name="l7"></a></span><span class=cF9>I64</span><span class=cF0> outside_count;
|
|
<a name="l8"></a>
|
|
<a name="l9"></a>#</span><span class=cF1>define</span><span class=cF0> MAP_WIDTH </span><span class=cFE>1000</span><span class=cF0>
|
|
<a name="l10"></a>#</span><span class=cF1>define</span><span class=cF0> MAP_HEIGHT </span><span class=cFE>1000</span><span class=cF0>
|
|
<a name="l11"></a>#</span><span class=cF1>define</span><span class=cF0> FENCE_WIDTH </span><span class=cFE>320</span><span class=cF0>
|
|
<a name="l12"></a>#</span><span class=cF1>define</span><span class=cF0> FENCE_HEIGHT </span><span class=cFE>200</span><span class=cF0>
|
|
<a name="l13"></a>#</span><span class=cF1>define</span><span class=cF0> MAP_BORDER </span><span class=cFE>3</span><span class=cF0>
|
|
<a name="l14"></a></span><span class=cF9>CDC</span><span class=cF0> *map_dc;
|
|
<a name="l15"></a>
|
|
<a name="l16"></a>#</span><span class=cF1>define</span><span class=cF0> GATE_WIDTH </span><span class=cFE>22</span><span class=cF0>
|
|
<a name="l17"></a>#</span><span class=cF1>define</span><span class=cF0> GATE_HEIGHT </span><span class=cFE>7</span><span class=cF0>
|
|
<a name="l18"></a></span><span class=cF1>F64</span><span class=cF0> gate_theta, gate_t;
|
|
<a name="l19"></a>
|
|
<a name="l20"></a>
|
|
<a name="l21"></a></span><span class=cFA>
|
|
<a name="l22"></a><1>/* Graphics Not Rendered in HTML */</span><span class=cF0> </span><span class=cFA><2>/* Graphics Not Rendered in HTML */</span><span class=cF0> </span><span class=cFA><3>/* Graphics Not Rendered in HTML */</span><span class=cF0>
|
|
<a name="l23"></a>
|
|
<a name="l24"></a></span><span class=cFA>
|
|
<a name="l25"></a><4>/* Graphics Not Rendered in HTML */</span><span class=cF0> </span><span class=cFA><5>/* Graphics Not Rendered in HTML */</span><span class=cF0> </span><span class=cFA><6>/* Graphics Not Rendered in HTML */</span><span class=cF0>
|
|
<a name="l26"></a>
|
|
<a name="l27"></a></span><span class=cFA>
|
|
<a name="l28"></a><7>/* Graphics Not Rendered in HTML */</span><span class=cF0> </span><span class=cFA><8>/* Graphics Not Rendered in HTML */</span><span class=cF0>
|
|
<a name="l29"></a>
|
|
<a name="l30"></a></span><span class=cFA>
|
|
<a name="l31"></a><9>/* Graphics Not Rendered in HTML */</span><span class=cF0>
|
|
<a name="l32"></a> </span><span class=cFA><10>/* Graphics Not Rendered in HTML */</span><span class=cF0>
|
|
<a name="l33"></a>
|
|
<a name="l34"></a>
|
|
<a name="l35"></a>
|
|
<a name="l36"></a>
|
|
<a name="l37"></a>
|
|
<a name="l38"></a>
|
|
<a name="l39"></a>
|
|
<a name="l40"></a>
|
|
<a name="l41"></a>#</span><span class=cF1>define</span><span class=cF0> ANIMAL_WIDTH </span><span class=cFE>20</span><span class=cF0>
|
|
<a name="l42"></a>#</span><span class=cF1>define</span><span class=cF0> ANIMAL_HEIGHT </span><span class=cFE>16</span><span class=cF0>
|
|
<a name="l43"></a>
|
|
<a name="l44"></a></span><span class=cF1>U8</span><span class=cF0> *cow_imgs[</span><span class=cFE>4</span><span class=cF0>] = {</span><span class=cFA><1></span><span class=cF0>, </span><span class=cFA><2></span><span class=cF0>, </span><span class=cFA><3></span><span class=cF0>, </span><span class=cFA><2></span><span class=cF0>},
|
|
<a name="l45"></a> *bull_imgs[</span><span class=cFE>4</span><span class=cF0>] = {</span><span class=cFA><4></span><span class=cF0>, </span><span class=cFA><5></span><span class=cF0>, </span><span class=cFA><6></span><span class=cF0>, </span><span class=cFA><5></span><span class=cF0>},
|
|
<a name="l46"></a> *horse_imgs[</span><span class=cFE>4</span><span class=cF0>] = {</span><span class=cFA><7></span><span class=cF0>, </span><span class=cFA><8></span><span class=cF0>, </span><span class=cFA><7></span><span class=cF0>, </span><span class=cFA><8></span><span class=cF0>};
|
|
<a name="l47"></a>
|
|
<a name="l48"></a>#</span><span class=cF1>define</span><span class=cF0> ANIMALS_NUM </span><span class=cFE>100</span><span class=cF0>
|
|
<a name="l49"></a>
|
|
<a name="l50"></a></span><span class=cF1>class</span><span class=cF0> Animal
|
|
<a name="l51"></a>{
|
|
<a name="l52"></a> </span><span class=cF9>I64</span><span class=cF0> num, x, y, dx, dy;
|
|
<a name="l53"></a> </span><span class=cF1>U8</span><span class=cF0> **imgs;
|
|
<a name="l54"></a> </span><span class=cF9>U32</span><span class=cF0> buddy;
|
|
<a name="l55"></a> </span><span class=cF1>U8</span><span class=cF0> type, frame0;
|
|
<a name="l56"></a> </span><span class=cF1>Bool</span><span class=cF0> dead, pad;
|
|
<a name="l57"></a>} *a;
|
|
<a name="l58"></a>
|
|
<a name="l59"></a></span><span class=cF2>//************************************</span><span class=cF0>
|
|
<a name="l60"></a>#</span><span class=cF1>define</span><span class=cF0> WATERFALL_HEIGHT (MAP_HEIGHT / </span><span class=cFE>20</span><span class=cF0>)
|
|
<a name="l61"></a>#</span><span class=cF1>define</span><span class=cF0> WATERFALL_DROPS </span><span class=cFE>512</span><span class=cF0>
|
|
<a name="l62"></a>#</span><span class=cF1>define</span><span class=cF0> WATERFALL_ACCELERATION </span><span class=cFE>10</span><span class=cF0>
|
|
<a name="l63"></a></span><span class=cF9>I32</span><span class=cF0> *r_x, *r_width, *wfd_x;
|
|
<a name="l64"></a></span><span class=cF1>F64</span><span class=cF0> *wfd_t0, waterfall_tf;
|
|
<a name="l65"></a></span><span class=cF9>I64</span><span class=cF0> waterfall_x, waterfall_y, waterfall_width;
|
|
<a name="l66"></a>
|
|
<a name="l67"></a></span><span class=cF1>U0</span><span class=cF0> RiverNew()
|
|
<a name="l68"></a>{
|
|
<a name="l69"></a> r_x = </span><span class=cF5>MAlloc</span><span class=cF0>(MAP_HEIGHT * </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>I32</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l70"></a> r_width = </span><span class=cF5>MAlloc</span><span class=cF0>(MAP_HEIGHT * </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>I32</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l71"></a> wfd_x = </span><span class=cF5>MAlloc</span><span class=cF0>(WATERFALL_DROPS * </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>I32</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l72"></a> wfd_t0 = </span><span class=cF5>MAlloc</span><span class=cF0>(WATERFALL_DROPS * </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF1>F64</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l73"></a> waterfall_tf = </span><span class=cF5>Sqrt</span><span class=cF0>(</span><span class=cFE>2</span><span class=cF0> * WATERFALL_HEIGHT / WATERFALL_ACCELERATION);
|
|
<a name="l74"></a>}
|
|
<a name="l75"></a>
|
|
<a name="l76"></a></span><span class=cF1>U0</span><span class=cF0> RiverMake()
|
|
<a name="l77"></a>{
|
|
<a name="l78"></a> </span><span class=cF9>I64</span><span class=cF0> i, x = </span><span class=cFE>2</span><span class=cF0> * MAP_WIDTH << </span><span class=cFE>32</span><span class=cF0> / </span><span class=cFE>3</span><span class=cF0>, y, dx = </span><span class=cFE>0</span><span class=cF0>, w = </span><span class=cFE>15</span><span class=cF0> << </span><span class=cFE>32</span><span class=cF0>;
|
|
<a name="l79"></a>
|
|
<a name="l80"></a> waterfall_y = (MAP_HEIGHT - WATERFALL_HEIGHT) / </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF5>Rand</span><span class=cF0> + (MAP_HEIGHT - WATERFALL_HEIGHT) / </span><span class=cFE>4</span><span class=cF0>;
|
|
<a name="l81"></a> </span><span class=cF1>for</span><span class=cF0> (y = MAP_BORDER; y < MAP_HEIGHT-MAP_BORDER; y++)
|
|
<a name="l82"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l83"></a> r_x[y] = x.i32[</span><span class=cFE>1</span><span class=cF0>];
|
|
<a name="l84"></a> r_width[y] = w.i32[</span><span class=cFE>1</span><span class=cF0>];
|
|
<a name="l85"></a> </span><span class=cF1>if</span><span class=cF0> (waterfall_y - </span><span class=cFE>5</span><span class=cF0> < y < waterfall_y + WATERFALL_HEIGHT + </span><span class=cFE>5</span><span class=cF0>)
|
|
<a name="l86"></a> {
|
|
<a name="l87"></a> waterfall_width = r_width[y];
|
|
<a name="l88"></a> waterfall_x = r_x[y] - waterfall_width / </span><span class=cFE>2</span><span class=cF0>;
|
|
<a name="l89"></a> }
|
|
<a name="l90"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l91"></a> {
|
|
<a name="l92"></a> dx = </span><span class=cF5>ClampI64</span><span class=cF0>(dx + </span><span class=cF5>RandI32</span><span class=cF0> / </span><span class=cFE>64</span><span class=cF0>, -</span><span class=cF3>I32_MAX</span><span class=cF0>, </span><span class=cF3>I32_MAX</span><span class=cF0>) - </span><span class=cF3>I32_MAX</span><span class=cF0> / </span><span class=cFE>256</span><span class=cF0>;
|
|
<a name="l93"></a> w = </span><span class=cF5>ClampI64</span><span class=cF0>(w + </span><span class=cF5>RandI32</span><span class=cF0> * </span><span class=cFE>2</span><span class=cF0>, </span><span class=cFE>10</span><span class=cF0> * </span><span class=cF3>U32_MAX</span><span class=cF0>, </span><span class=cFE>150</span><span class=cF0> * </span><span class=cF3>U32_MAX</span><span class=cF0>);
|
|
<a name="l94"></a> x += dx;
|
|
<a name="l95"></a> }
|
|
<a name="l96"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l97"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < WATERFALL_DROPS; i++)
|
|
<a name="l98"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l99"></a> wfd_x[i] = </span><span class=cF5>Rand</span><span class=cF0> * waterfall_width + waterfall_x;
|
|
<a name="l100"></a> wfd_t0[i] = </span><span class=cF5>tS</span><span class=cF0> - </span><span class=cF5>Rand</span><span class=cF0> * waterfall_tf;
|
|
<a name="l101"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l102"></a>
|
|
<a name="l103"></a> </span><span class=cF2>//Plot waterfall cliff</span><span class=cF0>
|
|
<a name="l104"></a> </span><span class=cF5>Sprite3B</span><span class=cF0>(map_dc, waterfall_x, waterfall_y, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cFA><10></span><span class=cF0>);
|
|
<a name="l105"></a>
|
|
<a name="l106"></a> </span><span class=cF2>//Plot sand bar</span><span class=cF0>
|
|
<a name="l107"></a> x = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l108"></a> </span><span class=cF1>for</span><span class=cF0> (y = MAP_BORDER; y < MAP_HEIGHT - MAP_BORDER; y++)
|
|
<a name="l109"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l110"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>waterfall_y - </span><span class=cFE>9</span><span class=cF0> < y < waterfall_y + WATERFALL_HEIGHT + </span><span class=cFE>9</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l111"></a> {
|
|
<a name="l112"></a> map_dc->color = </span><span class=cF3>YELLOW</span><span class=cF0>;
|
|
<a name="l113"></a> map_dc->thick = r_width[y] + </span><span class=cFE>10</span><span class=cF0>;
|
|
<a name="l114"></a> </span><span class=cF5>GrPlot3</span><span class=cF0>(map_dc, r_x[y] + x.i32[</span><span class=cFE>1</span><span class=cF0>], y, </span><span class=cFE>0</span><span class=cF0>);
|
|
<a name="l115"></a> }
|
|
<a name="l116"></a> x = </span><span class=cF5>ClampI64</span><span class=cF0>(x+</span><span class=cF5>RandI32</span><span class=cF0>, -</span><span class=cFE>6</span><span class=cF0> * </span><span class=cF3>U32_MAX</span><span class=cF0>, </span><span class=cFE>6</span><span class=cF0> * </span><span class=cF3>U32_MAX</span><span class=cF0>);
|
|
<a name="l117"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l118"></a>
|
|
<a name="l119"></a> </span><span class=cF2>//Plot water</span><span class=cF0>
|
|
<a name="l120"></a> </span><span class=cF1>for</span><span class=cF0> (y = MAP_BORDER; y < MAP_HEIGHT - MAP_BORDER; y++)
|
|
<a name="l121"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l122"></a> map_dc->color = </span><span class=cF3>BLUE</span><span class=cF0>;
|
|
<a name="l123"></a> map_dc->thick = r_width[y];
|
|
<a name="l124"></a> </span><span class=cF5>GrPlot3</span><span class=cF0>(map_dc, r_x[y], y, </span><span class=cFE>0</span><span class=cF0>);
|
|
<a name="l125"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l126"></a>}
|
|
<a name="l127"></a>
|
|
<a name="l128"></a></span><span class=cF1>U0</span><span class=cF0> RiverDel()
|
|
<a name="l129"></a>{
|
|
<a name="l130"></a> </span><span class=cF5>Free</span><span class=cF0>(r_x);
|
|
<a name="l131"></a> </span><span class=cF5>Free</span><span class=cF0>(r_width);
|
|
<a name="l132"></a> </span><span class=cF5>Free</span><span class=cF0>(wfd_x);
|
|
<a name="l133"></a> </span><span class=cF5>Free</span><span class=cF0>(wfd_t0);
|
|
<a name="l134"></a>}
|
|
<a name="l135"></a>
|
|
<a name="l136"></a></span><span class=cF2>//************************************</span><span class=cF0>
|
|
<a name="l137"></a></span><span class=cF1>class</span><span class=cF0> RiverDrop
|
|
<a name="l138"></a>{
|
|
<a name="l139"></a> RiverDrop *next, *last;
|
|
<a name="l140"></a> </span><span class=cF9>I64</span><span class=cF0> y, dx, dy;
|
|
<a name="l141"></a>
|
|
<a name="l142"></a>} rd_head;
|
|
<a name="l143"></a></span><span class=cF1>Bool</span><span class=cF0> rd_lock;
|
|
<a name="l144"></a>
|
|
<a name="l145"></a></span><span class=cF1>U0</span><span class=cF0> RiverDropsDel()
|
|
<a name="l146"></a>{
|
|
<a name="l147"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&rd_lock, </span><span class=cFE>0</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l148"></a> </span><span class=cF5>Yield</span><span class=cF0>;
|
|
<a name="l149"></a> </span><span class=cF5>QueueDel</span><span class=cF0>(&rd_head, </span><span class=cF3>TRUE</span><span class=cF0>);
|
|
<a name="l150"></a> </span><span class=cF5>QueueInit</span><span class=cF0>(&rd_head);
|
|
<a name="l151"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&rd_lock, </span><span class=cFE>0</span><span class=cF0>);
|
|
<a name="l152"></a>}
|
|
<a name="l153"></a>
|
|
<a name="l154"></a></span><span class=cF1>U0</span><span class=cF0> RiverDropsNext(</span><span class=cF9>CTask</span><span class=cF0> *mem_task)
|
|
<a name="l155"></a>{
|
|
<a name="l156"></a> RiverDrop *tmpr, *tmpr1;
|
|
<a name="l157"></a>
|
|
<a name="l158"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&rd_lock, </span><span class=cFE>0</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l159"></a> </span><span class=cF5>Yield</span><span class=cF0>;
|
|
<a name="l160"></a> tmpr = rd_head.next;
|
|
<a name="l161"></a> </span><span class=cF1>while</span><span class=cF0> (tmpr != &rd_head)
|
|
<a name="l162"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l163"></a> tmpr1 = tmpr->next;
|
|
<a name="l164"></a> </span><span class=cF1>if</span><span class=cF0> (++tmpr->y >= MAP_HEIGHT - MAP_BORDER)
|
|
<a name="l165"></a> {
|
|
<a name="l166"></a> </span><span class=cF5>QueueRemove</span><span class=cF0>(tmpr);
|
|
<a name="l167"></a> </span><span class=cF5>Free</span><span class=cF0>(tmpr);
|
|
<a name="l168"></a> }
|
|
<a name="l169"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l170"></a> {
|
|
<a name="l171"></a> </span><span class=cF1>do</span><span class=cF0>
|
|
<a name="l172"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l173"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>RandU16</span><span class=cF0> & </span><span class=cFE>1</span><span class=cF0> && </span><span class=cF5>GrPeek</span><span class=cF7>(</span><span class=cF0>map_dc, r_x[tmpr->y] + tmpr->dx, tmpr->y + tmpr->dy</span><span class=cF7>)</span><span class=cF0> == </span><span class=cF3>BLUE</span><span class=cF0>)
|
|
<a name="l174"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l175"></a> tmpr->dx = </span><span class=cF5>ClampI64</span><span class=cF0>(tmpr->dx + </span><span class=cF5>RandU16</span><span class=cF0> % </span><span class=cFE>3</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0>, -r_width[tmpr->y] / </span><span class=cFE>2</span><span class=cF0>, r_width[tmpr->y] / </span><span class=cFE>2</span><span class=cF0>);
|
|
<a name="l176"></a> tmpr->dy = </span><span class=cF5>ClampI64</span><span class=cF0>(tmpr->dy + </span><span class=cF5>RandU16</span><span class=cF0> % </span><span class=cFE>3</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0>, -r_width[tmpr->y] / </span><span class=cFE>2</span><span class=cF0>, r_width[tmpr->y] / </span><span class=cFE>2</span><span class=cF0>);
|
|
<a name="l177"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l178"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>GrPeek</span><span class=cF7>(</span><span class=cF0>map_dc, r_x[tmpr->y] + tmpr->dx, tmpr->y + tmpr->dy</span><span class=cF7>)</span><span class=cF0> != </span><span class=cF3>BLUE</span><span class=cF0> &&
|
|
<a name="l179"></a> </span><span class=cF5>GrPeek</span><span class=cF7>(</span><span class=cF0>map_dc, r_x[tmpr->y], tmpr->y</span><span class=cF7>)</span><span class=cF0> == </span><span class=cF3>BLUE</span><span class=cF0>);</span><span class=cF2>//Might be reiniting</span><span class=cF0>
|
|
<a name="l180"></a> }
|
|
<a name="l181"></a> tmpr = tmpr1;
|
|
<a name="l182"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l183"></a> tmpr = </span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>RiverDrop</span><span class=cF7>)</span><span class=cF0>, mem_task);
|
|
<a name="l184"></a> tmpr->y = MAP_BORDER;
|
|
<a name="l185"></a> tmpr->dx = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l186"></a> tmpr->dy = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l187"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(tmpr, rd_head.last);
|
|
<a name="l188"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&rd_lock, </span><span class=cFE>0</span><span class=cF0>);
|
|
<a name="l189"></a>}
|
|
<a name="l190"></a>
|
|
<a name="l191"></a></span><span class=cF1>U0</span><span class=cF0> RiverDropsDraw(</span><span class=cF9>CDC</span><span class=cF0> *dc, </span><span class=cF9>I64</span><span class=cF0> cx, </span><span class=cF9>I64</span><span class=cF0> cy)
|
|
<a name="l192"></a>{
|
|
<a name="l193"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
|
<a name="l194"></a> </span><span class=cF1>F64</span><span class=cF0> t = </span><span class=cF5>tS</span><span class=cF0>;
|
|
<a name="l195"></a> RiverDrop *tmpr;
|
|
<a name="l196"></a>
|
|
<a name="l197"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>&rd_lock, </span><span class=cFE>0</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l198"></a> </span><span class=cF5>Yield</span><span class=cF0>;
|
|
<a name="l199"></a> tmpr = rd_head.next;
|
|
<a name="l200"></a> dc->color = </span><span class=cF3>LTBLUE</span><span class=cF0>;
|
|
<a name="l201"></a> </span><span class=cF1>while</span><span class=cF0> (tmpr != &rd_head)
|
|
<a name="l202"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l203"></a> </span><span class=cF5>GrPlot</span><span class=cF0>(dc, r_x[tmpr->y] + tmpr->dx-cx, tmpr->y + tmpr->dy-cy);
|
|
<a name="l204"></a> tmpr = tmpr->next;
|
|
<a name="l205"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l206"></a> </span><span class=cF5>LBtr</span><span class=cF0>(&rd_lock, </span><span class=cFE>0</span><span class=cF0>);
|
|
<a name="l207"></a>
|
|
<a name="l208"></a> dc->color = </span><span class=cF3>WHITE</span><span class=cF0>;
|
|
<a name="l209"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < WATERFALL_DROPS; i++)
|
|
<a name="l210"></a> </span><span class=cF5>GrPlot</span><span class=cF0>(dc, wfd_x[i] - cx,
|
|
<a name="l211"></a> waterfall_y + </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0> * WATERFALL_ACCELERATION * </span><span class=cF5>Sqr</span><span class=cF7>(</span><span class=cF0>waterfall_tf * </span><span class=cF5>Saw</span><span class=cF0>(t - wfd_t0[i], waterfall_tf)</span><span class=cF7>)</span><span class=cF0> - cy);
|
|
<a name="l212"></a>}
|
|
<a name="l213"></a>
|
|
<a name="l214"></a></span><span class=cF2>//************************************</span><span class=cF0>
|
|
<a name="l215"></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="l216"></a>{
|
|
<a name="l217"></a> </span><span class=cF1>static</span><span class=cF0> </span><span class=cF9>I64</span><span class=cF0> last_pos_x = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l218"></a> </span><span class=cF1>static</span><span class=cF0> </span><span class=cF1>Bool</span><span class=cF0> left = </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l219"></a> </span><span class=cF1>F64</span><span class=cF0> t;
|
|
<a name="l220"></a> </span><span class=cF9>I64</span><span class=cF0> i, frame=</span><span class=cFE>4</span><span class=cF0> * </span><span class=cF5>tS</span><span class=cF0>,
|
|
<a name="l221"></a> cx = (MAP_WIDTH - task->pix_width) / </span><span class=cFE>2</span><span class=cF0>,
|
|
<a name="l222"></a> cy = (MAP_HEIGHT - task->pix_height) / </span><span class=cFE>2</span><span class=cF0>;
|
|
<a name="l223"></a>
|
|
<a name="l224"></a> </span><span class=cF1>if</span><span class=cF0> (task->scroll_x + cx < </span><span class=cFE>0</span><span class=cF0>)
|
|
<a name="l225"></a> task->scroll_x = -cx;
|
|
<a name="l226"></a>
|
|
<a name="l227"></a> </span><span class=cF1>if</span><span class=cF0> (task->scroll_x + cx > MAP_WIDTH - task->pix_width)
|
|
<a name="l228"></a> task->scroll_x = MAP_WIDTH - task->pix_width - cx;
|
|
<a name="l229"></a>
|
|
<a name="l230"></a> </span><span class=cF1>if</span><span class=cF0> (task->scroll_y + cy < </span><span class=cFE>0</span><span class=cF0>)
|
|
<a name="l231"></a> task->scroll_y = -cy;
|
|
<a name="l232"></a>
|
|
<a name="l233"></a> </span><span class=cF1>if</span><span class=cF0> (task->scroll_y + cy > MAP_HEIGHT - task->pix_height)
|
|
<a name="l234"></a> task->scroll_y = MAP_HEIGHT - task->pix_height - cy;
|
|
<a name="l235"></a>
|
|
<a name="l236"></a> map_dc->flags |= </span><span class=cF3>DCF_NO_TRANSPARENTS</span><span class=cF0>;
|
|
<a name="l237"></a> </span><span class=cF5>GrBlot</span><span class=cF0>(dc, -cx, -cy, map_dc);
|
|
<a name="l238"></a>
|
|
<a name="l239"></a> RiverDropsDraw(dc, cx, cy);
|
|
<a name="l240"></a>
|
|
<a name="l241"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < ANIMALS_NUM; i++)
|
|
<a name="l242"></a> </span><span class=cF1>if</span><span class=cF0> (!a[i].dead)
|
|
<a name="l243"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l244"></a> </span><span class=cF1>if</span><span class=cF0> (a[i].dx < </span><span class=cFE>0</span><span class=cF0>)
|
|
<a name="l245"></a> {
|
|
<a name="l246"></a> dc->flags |= </span><span class=cF3>DCF_JUST_MIRROR</span><span class=cF0> | </span><span class=cF3>DCF_SYMMETRY</span><span class=cF0>;
|
|
<a name="l247"></a> </span><span class=cF5>DCSymmetrySet</span><span class=cF0>(dc, a[i].x.i32[</span><span class=cFE>1</span><span class=cF0>] - cx, </span><span class=cFE>0</span><span class=cF0>, a[i].x.i32[</span><span class=cFE>1</span><span class=cF0>] - cx, </span><span class=cFE>1</span><span class=cF0>);
|
|
<a name="l248"></a> }
|
|
<a name="l249"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc, a[i].x.i32[</span><span class=cFE>1</span><span class=cF0>] - cx, a[i].y.i32[</span><span class=cFE>1</span><span class=cF0>] - cy, </span><span class=cFE>0</span><span class=cF0>, a[i].imgs[</span><span class=cF7>(</span><span class=cF0>frame + a[i].frame0</span><span class=cF7>)</span><span class=cF0> & </span><span class=cFE>3</span><span class=cF0>]);
|
|
<a name="l250"></a> dc->flags &= ~(</span><span class=cF3>DCF_JUST_MIRROR</span><span class=cF0>|</span><span class=cF3>DCF_SYMMETRY</span><span class=cF0>);
|
|
<a name="l251"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l252"></a>
|
|
<a name="l253"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>mouse</span><span class=cF0>.pos.x - last_pos_x > </span><span class=cFE>0</span><span class=cF0>)
|
|
<a name="l254"></a> left = </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l255"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>mouse</span><span class=cF0>.pos.x - last_pos_x < </span><span class=cFE>0</span><span class=cF0>)
|
|
<a name="l256"></a> left = </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l257"></a> </span><span class=cF1>if</span><span class=cF0> (left)
|
|
<a name="l258"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l259"></a> dc->flags |= </span><span class=cF3>DCF_JUST_MIRROR</span><span class=cF0> | </span><span class=cF3>DCF_SYMMETRY</span><span class=cF0>;
|
|
<a name="l260"></a> </span><span class=cF5>DCSymmetrySet</span><span class=cF0>(dc, </span><span class=cFB>mouse</span><span class=cF0>.pos.x - task->pix_left - task->scroll_x, </span><span class=cFE>0</span><span class=cF0>,
|
|
<a name="l261"></a> </span><span class=cFB>mouse</span><span class=cF0>.pos.x - task->pix_left - task->scroll_x, </span><span class=cFE>1</span><span class=cF0>);
|
|
<a name="l262"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l263"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc, </span><span class=cFB>mouse</span><span class=cF0>.pos.x - task->pix_left - task->scroll_x,
|
|
<a name="l264"></a> </span><span class=cFB>mouse</span><span class=cF0>.pos.y - task->pix_top - task->scroll_y, </span><span class=cFE>0</span><span class=cF0>, horse_imgs[frame & </span><span class=cFE>3</span><span class=cF0>]);
|
|
<a name="l265"></a> dc->flags &= ~(</span><span class=cF3>DCF_JUST_MIRROR</span><span class=cF0>|</span><span class=cF3>DCF_SYMMETRY</span><span class=cF0>);
|
|
<a name="l266"></a> last_pos_x = </span><span class=cFB>mouse</span><span class=cF0>.pos.x;
|
|
<a name="l267"></a>
|
|
<a name="l268"></a> </span><span class=cF1>if</span><span class=cF0> (tf)
|
|
<a name="l269"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l270"></a> dc->color = </span><span class=cF3>RED</span><span class=cF0>;
|
|
<a name="l271"></a> t = tf - t0;
|
|
<a name="l272"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Blink</span><span class=cF0>)
|
|
<a name="l273"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, </span><span class=cF7>(</span><span class=cF0>task->pix_width - </span><span class=cF3>FONT_WIDTH</span><span class=cF0> * </span><span class=cFE>14</span><span class=cF7>)</span><span class=cF0> >> </span><span class=cFE>1</span><span class=cF0> - task->scroll_x,
|
|
<a name="l274"></a> </span><span class=cF7>(</span><span class=cF0>task->pix_height - </span><span class=cF3>FONT_HEIGHT</span><span class=cF7>)</span><span class=cF0> >> </span><span class=cFE>1</span><span class=cF0> - task->scroll_y,
|
|
<a name="l275"></a> </span><span class=cF6>"Game Completed"</span><span class=cF0>);
|
|
<a name="l276"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l277"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l278"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l279"></a> dc->color = </span><span class=cF3>BLACK</span><span class=cF0>;
|
|
<a name="l280"></a> t = </span><span class=cF5>tS</span><span class=cF0> - t0;
|
|
<a name="l281"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l282"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, -task->scroll_x, -task->scroll_y, </span><span class=cF6>"Outside:%03d Time:%7.2fs Best:%7.2fs"</span><span class=cF0>, outside_count, t, best_score);
|
|
<a name="l283"></a>}
|
|
<a name="l284"></a>
|
|
<a name="l285"></a></span><span class=cF1>U0</span><span class=cF0> BuddySel(</span><span class=cF9>I64</span><span class=cF0> i)
|
|
<a name="l286"></a>{
|
|
<a name="l287"></a> </span><span class=cF9>I64</span><span class=cF0> b, best_b = i, score, best_score = </span><span class=cF3>I64_MAX</span><span class=cF0>;
|
|
<a name="l288"></a>
|
|
<a name="l289"></a> </span><span class=cF1>for</span><span class=cF0> (b = </span><span class=cFE>0</span><span class=cF0>; b < ANIMALS_NUM; b++)
|
|
<a name="l290"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l291"></a> </span><span class=cF1>if</span><span class=cF0> (b != i && !a[b].dead)
|
|
<a name="l292"></a> {
|
|
<a name="l293"></a> score = </span><span class=cF5>RandU32</span><span class=cF0> % (</span><span class=cFE>512</span><span class=cF0> * </span><span class=cFE>512</span><span class=cF0>) + </span><span class=cF5>SqrI64</span><span class=cF0>(a[b].x.i32[</span><span class=cFE>1</span><span class=cF0>] - a[i].x.i32[</span><span class=cFE>1</span><span class=cF0>]) + </span><span class=cF5>SqrI64</span><span class=cF0>(a[b].y.i32[</span><span class=cFE>1</span><span class=cF0>] - a[i].y.i32[</span><span class=cFE>1</span><span class=cF0>]);
|
|
<a name="l294"></a> </span><span class=cF1>if</span><span class=cF0> (score < best_score)
|
|
<a name="l295"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l296"></a> best_score = score;
|
|
<a name="l297"></a> best_b = b;
|
|
<a name="l298"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l299"></a> }
|
|
<a name="l300"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l301"></a> a[i].buddy = best_b;
|
|
<a name="l302"></a>}
|
|
<a name="l303"></a>
|
|
<a name="l304"></a>
|
|
<a name="l305"></a></span><span class=cF1>U0</span><span class=cF0> RedrawGate()
|
|
<a name="l306"></a>{
|
|
<a name="l307"></a> </span><span class=cF1>F64</span><span class=cF0> tt = </span><span class=cF5>tS</span><span class=cF0> - gate_t;
|
|
<a name="l308"></a> </span><span class=cF9>I64</span><span class=cF0> x1 = FENCE_WIDTH - </span><span class=cFE>63</span><span class=cF0>, y1 = FENCE_HEIGHT - </span><span class=cFE>1</span><span class=cF0>, dx, dy;
|
|
<a name="l309"></a>
|
|
<a name="l310"></a> </span><span class=cF1>if</span><span class=cF0> (tt < </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0>)
|
|
<a name="l311"></a> gate_theta = </span><span class=cF5>Clamp</span><span class=cF0>(gate_theta + </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>02</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>);
|
|
<a name="l312"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (tt > </span><span class=cFE>5</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>)
|
|
<a name="l313"></a> gate_theta = </span><span class=cF5>Clamp</span><span class=cF0>(gate_theta - </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>02</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>);
|
|
<a name="l314"></a>
|
|
<a name="l315"></a> dx = GATE_WIDTH * </span><span class=cF5>Cos</span><span class=cF0>(gate_theta);
|
|
<a name="l316"></a> dy = -</span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>8</span><span class=cF0> * GATE_WIDTH * </span><span class=cF5>Sin</span><span class=cF0>(gate_theta);
|
|
<a name="l317"></a>
|
|
<a name="l318"></a> map_dc->color = </span><span class=cF3>LTGREEN</span><span class=cF0>;
|
|
<a name="l319"></a> </span><span class=cF5>GrRect</span><span class=cF0>(map_dc, x1, y1 - </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>8</span><span class=cF0> * GATE_WIDTH - GATE_HEIGHT, </span><span class=cFE>46</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>8</span><span class=cF0> * GATE_WIDTH + GATE_HEIGHT + </span><span class=cFE>3</span><span class=cF0>);
|
|
<a name="l320"></a>
|
|
<a name="l321"></a> map_dc->color = </span><span class=cF3>BLACK</span><span class=cF0>;
|
|
<a name="l322"></a>
|
|
<a name="l323"></a> </span><span class=cF5>GrLine</span><span class=cF0>(map_dc, x1, y1, x1 + dx, y1 + dy);
|
|
<a name="l324"></a> </span><span class=cF5>GrLine</span><span class=cF0>(map_dc, x1, y1, x1, y1 - GATE_HEIGHT);
|
|
<a name="l325"></a> </span><span class=cF5>GrLine</span><span class=cF0>(map_dc, x1 + dx, y1 + dy, x1 + dx, y1 + dy - GATE_HEIGHT);
|
|
<a name="l326"></a> </span><span class=cF5>GrLine</span><span class=cF0>(map_dc, x1, y1 - GATE_HEIGHT, x1 + dx, y1 + dy - GATE_HEIGHT);
|
|
<a name="l327"></a> </span><span class=cF5>GrLine</span><span class=cF0>(map_dc, x1, y1, x1 + dx, y1 + dy - GATE_HEIGHT);
|
|
<a name="l328"></a> </span><span class=cF5>GrLine</span><span class=cF0>(map_dc, x1, y1 - GATE_HEIGHT, x1 + dx, y1 + dy);
|
|
<a name="l329"></a>
|
|
<a name="l330"></a> </span><span class=cF5>GrLine</span><span class=cF0>(map_dc, x1 + </span><span class=cFE>45</span><span class=cF0>, y1, x1 + </span><span class=cFE>45</span><span class=cF0> - dx, y1 + dy);
|
|
<a name="l331"></a> </span><span class=cF5>GrLine</span><span class=cF0>(map_dc, x1 + </span><span class=cFE>45</span><span class=cF0>, y1, x1 + </span><span class=cFE>45</span><span class=cF0>, y1 - GATE_HEIGHT);
|
|
<a name="l332"></a> </span><span class=cF5>GrLine</span><span class=cF0>(map_dc, x1 + </span><span class=cFE>45</span><span class=cF0> - dx, y1 + dy, x1 + </span><span class=cFE>45</span><span class=cF0> - dx, y1 + dy - GATE_HEIGHT);
|
|
<a name="l333"></a> </span><span class=cF5>GrLine</span><span class=cF0>(map_dc, x1 + </span><span class=cFE>45</span><span class=cF0>, y1 - GATE_HEIGHT, x1 + </span><span class=cFE>45</span><span class=cF0> - dx, y1 + dy - GATE_HEIGHT);
|
|
<a name="l334"></a> </span><span class=cF5>GrLine</span><span class=cF0>(map_dc, x1 + </span><span class=cFE>45</span><span class=cF0>, y1, x1 + </span><span class=cFE>45</span><span class=cF0> - dx, y1 + dy - GATE_HEIGHT);
|
|
<a name="l335"></a> </span><span class=cF5>GrLine</span><span class=cF0>(map_dc, x1 + </span><span class=cFE>45</span><span class=cF0>, y1 - GATE_HEIGHT, x1 + </span><span class=cFE>45</span><span class=cF0> - dx, y1 + dy);
|
|
<a name="l336"></a>}
|
|
<a name="l337"></a>
|
|
<a name="l338"></a></span><span class=cF1>Bool</span><span class=cF0> CheckMap(</span><span class=cF9>I64</span><span class=cF0> x, </span><span class=cF9>I64</span><span class=cF0> y)
|
|
<a name="l339"></a>{
|
|
<a name="l340"></a> </span><span class=cF9>I64</span><span class=cF0> i, j, c;
|
|
<a name="l341"></a>
|
|
<a name="l342"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>SqrI64</span><span class=cF7>(</span><span class=cF0>x - (waterfall_x + waterfall_width / </span><span class=cFE>2</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0> >> </span><span class=cFE>1</span><span class=cF0> + </span><span class=cF5>SqrI64</span><span class=cF7>(</span><span class=cF0>y - (waterfall_y + WATERFALL_HEIGHT / </span><span class=cFE>2</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0> < </span><span class=cFE>2500</span><span class=cF0>)
|
|
<a name="l343"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l344"></a> </span><span class=cF1>for</span><span class=cF0> (j = -</span><span class=cFE>4</span><span class=cF0>; j <= </span><span class=cFE>2</span><span class=cF0>; j++)
|
|
<a name="l345"></a> </span><span class=cF1>for</span><span class=cF0> (i = -</span><span class=cFE>4</span><span class=cF0>; i <= </span><span class=cFE>4</span><span class=cF0>; i++)
|
|
<a name="l346"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l347"></a> c = </span><span class=cF5>GrPeek</span><span class=cF0>(map_dc, x + i, y + j);
|
|
<a name="l348"></a> </span><span class=cF1>if</span><span class=cF0> (c == </span><span class=cF3>LTGRAY</span><span class=cF0> || c == </span><span class=cF3>BLACK</span><span class=cF0>)
|
|
<a name="l349"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l350"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l351"></a>
|
|
<a name="l352"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l353"></a>}
|
|
<a name="l354"></a>
|
|
<a name="l355"></a></span><span class=cF1>U0</span><span class=cF0> AnimateTask(</span><span class=cF9>CTask</span><span class=cF0> *parent)
|
|
<a name="l356"></a>{
|
|
<a name="l357"></a> </span><span class=cF9>I64</span><span class=cF0> i, cx, cy, cursor_x, cursor_y, dd, ddx, ddy, count, max_speed = </span><span class=cF3>I64_MAX</span><span class=cF0>, updates = </span><span class=cFE>0</span><span class=cF0>, my_outside_count;
|
|
<a name="l358"></a> </span><span class=cF1>F64</span><span class=cF0> f, d, dx, dy, s, stress;
|
|
<a name="l359"></a> Animal *tmpa, *tmpa1;
|
|
<a name="l360"></a>
|
|
<a name="l361"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
|
|
<a name="l362"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l363"></a> max_speed = </span><span class=cF5>ClampU64</span><span class=cF0>(max_speed, </span><span class=cF3>U32_MAX</span><span class=cF0> / </span><span class=cFE>3</span><span class=cF0>, </span><span class=cFE>200</span><span class=cF0> * </span><span class=cF3>U32_MAX</span><span class=cF0>);
|
|
<a name="l364"></a> cx = (MAP_WIDTH - parent->pix_width) / </span><span class=cFE>2</span><span class=cF0>, cy = (MAP_HEIGHT - parent->pix_height) / </span><span class=cFE>2</span><span class=cF0>;
|
|
<a name="l365"></a> cursor_x = </span><span class=cFB>mouse</span><span class=cF0>.pos.x + cx - parent->pix_left - parent->scroll_x;
|
|
<a name="l366"></a> cursor_y = </span><span class=cFB>mouse</span><span class=cF0>.pos.y + cy - parent->pix_top - parent->scroll_y;
|
|
<a name="l367"></a> count = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l368"></a> stress = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l369"></a> my_outside_count = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l370"></a> </span><span class=cF1>if</span><span class=cF0> (cursor_x < FENCE_WIDTH && cursor_y < FENCE_HEIGHT)
|
|
<a name="l371"></a> gate_t = </span><span class=cF5>tS</span><span class=cF0>;
|
|
<a name="l372"></a> RedrawGate;
|
|
<a name="l373"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < ANIMALS_NUM; i++)
|
|
<a name="l374"></a> {
|
|
<a name="l375"></a> tmpa = &a[i];
|
|
<a name="l376"></a> </span><span class=cF1>if</span><span class=cF0> (!tmpa->dead)
|
|
<a name="l377"></a> </span><span class=cF7>{</span><span class=cF2>//Move away from horse</span><span class=cF0>
|
|
<a name="l378"></a> ddx = tmpa->x.i32[</span><span class=cFE>1</span><span class=cF0>]-cursor_x;
|
|
<a name="l379"></a> ddy = tmpa->y.i32[</span><span class=cFE>1</span><span class=cF0>]-cursor_y;
|
|
<a name="l380"></a> </span><span class=cF1>if</span><span class=cF0> (dd = </span><span class=cF5>SqrI64</span><span class=cF7>(</span><span class=cF0>ddx</span><span class=cF7>)</span><span class=cF0> + </span><span class=cF5>SqrI64</span><span class=cF7>(</span><span class=cF0>ddy</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l381"></a> {
|
|
<a name="l382"></a> d = </span><span class=cF5>Sqrt</span><span class=cF0>(dd);
|
|
<a name="l383"></a> dx = ddx / d;
|
|
<a name="l384"></a> dy = ddy / d;
|
|
<a name="l385"></a> f = </span><span class=cFE>5</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>e2 * </span><span class=cF3>U32_MAX</span><span class=cF0> / dd;
|
|
<a name="l386"></a> tmpa->dx += f * dx;
|
|
<a name="l387"></a> tmpa->dy += f * dy;
|
|
<a name="l388"></a> }
|
|
<a name="l389"></a>
|
|
<a name="l390"></a> </span><span class=cF2>//Resel buddy about every ANIMALS_NUM*10ms=5.12 seconds</span><span class=cF0>
|
|
<a name="l391"></a> tmpa1 = &a[tmpa->buddy];
|
|
<a name="l392"></a> </span><span class=cF1>if</span><span class=cF0> (tmpa1->dead || i == updates % ANIMALS_NUM)
|
|
<a name="l393"></a> {
|
|
<a name="l394"></a> BuddySel(i);
|
|
<a name="l395"></a> tmpa1 = &a[tmpa->buddy];
|
|
<a name="l396"></a> }
|
|
<a name="l397"></a>
|
|
<a name="l398"></a> </span><span class=cF2>//Move toward buddy</span><span class=cF0>
|
|
<a name="l399"></a> ddx = tmpa->x.i32[</span><span class=cFE>1</span><span class=cF0>] - tmpa1->x.i32[</span><span class=cFE>1</span><span class=cF0>];
|
|
<a name="l400"></a> ddy = tmpa->y.i32[</span><span class=cFE>1</span><span class=cF0>] - tmpa1->y.i32[</span><span class=cFE>1</span><span class=cF0>];
|
|
<a name="l401"></a> </span><span class=cF1>if</span><span class=cF0> (dd = </span><span class=cF5>SqrI64</span><span class=cF7>(</span><span class=cF0>ddx</span><span class=cF7>)</span><span class=cF0> + </span><span class=cF5>SqrI64</span><span class=cF7>(</span><span class=cF0>ddy</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l402"></a> {
|
|
<a name="l403"></a> d = </span><span class=cF5>Sqrt</span><span class=cF0>(dd);
|
|
<a name="l404"></a> s = d ` </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>25</span><span class=cF0> - </span><span class=cFE>80</span><span class=cF0>;
|
|
<a name="l405"></a> stress += </span><span class=cF5>Abs</span><span class=cF0>(s);
|
|
<a name="l406"></a> dx = ddx / d;
|
|
<a name="l407"></a> dy = ddy / d;
|
|
<a name="l408"></a> f = -</span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>001</span><span class=cF0> * s * </span><span class=cF3>U32_MAX</span><span class=cF0>;
|
|
<a name="l409"></a> tmpa->dx += f * dx;
|
|
<a name="l410"></a> tmpa->dy += f * dy;
|
|
<a name="l411"></a> }
|
|
<a name="l412"></a>
|
|
<a name="l413"></a> </span><span class=cF2>//Make velocity similar to buddy</span><span class=cF0>
|
|
<a name="l414"></a> tmpa->dx += </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>1</span><span class=cF0> * (tmpa1->dx - tmpa->dx);
|
|
<a name="l415"></a> tmpa->dy += </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>1</span><span class=cF0> * (tmpa1->dy - tmpa->dy);
|
|
<a name="l416"></a>
|
|
<a name="l417"></a> </span><span class=cF2>//Add random movement, limit speed and dampen speed</span><span class=cF0>
|
|
<a name="l418"></a> tmpa->dx = </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>995</span><span class=cF0> * </span><span class=cF5>ClampI64</span><span class=cF0>(tmpa->dx + </span><span class=cF5>RandI32</span><span class=cF0> / </span><span class=cFE>32</span><span class=cF0>, -max_speed, max_speed);
|
|
<a name="l419"></a> tmpa->dy = </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>995</span><span class=cF0> * </span><span class=cF5>ClampI64</span><span class=cF0>(tmpa->dy + </span><span class=cF5>RandI32</span><span class=cF0> / </span><span class=cFE>32</span><span class=cF0>, -max_speed, max_speed);
|
|
<a name="l420"></a>
|
|
<a name="l421"></a> </span><span class=cF2>//Slow in river</span><span class=cF0>
|
|
<a name="l422"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>GrPeek</span><span class=cF7>(</span><span class=cF0>map_dc, tmpa->x.i32[</span><span class=cFE>1</span><span class=cF0>], tmpa->y.i32[</span><span class=cFE>1</span><span class=cF0>]</span><span class=cF7>)</span><span class=cF0> != </span><span class=cF3>LTGREEN</span><span class=cF0>)
|
|
<a name="l423"></a> {
|
|
<a name="l424"></a> tmpa->dx /= </span><span class=cFE>2</span><span class=cF0>;
|
|
<a name="l425"></a> tmpa->dy /= </span><span class=cFE>2</span><span class=cF0>;
|
|
<a name="l426"></a> }
|
|
<a name="l427"></a>
|
|
<a name="l428"></a> </span><span class=cF1>if</span><span class=cF0> (CheckMap</span><span class=cF7>(</span><span class=cF0>(tmpa->x + tmpa->dx) >> </span><span class=cFE>32</span><span class=cF0>, (tmpa->y + tmpa->dy) >> </span><span class=cFE>32</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l429"></a> {
|
|
<a name="l430"></a> tmpa->x += tmpa->dx;
|
|
<a name="l431"></a> tmpa->y += tmpa->dy;
|
|
<a name="l432"></a> }
|
|
<a name="l433"></a>
|
|
<a name="l434"></a> </span><span class=cF2>//Keep on map</span><span class=cF0>
|
|
<a name="l435"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>MAP_BORDER + ANIMAL_WIDTH / </span><span class=cFE>2</span><span class=cF0> <= tmpa->x.i32[</span><span class=cFE>1</span><span class=cF0>] < MAP_WIDTH - MAP_BORDER - ANIMAL_WIDTH / </span><span class=cFE>2</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l436"></a> {
|
|
<a name="l437"></a> tmpa->x -= tmpa->dx;
|
|
<a name="l438"></a> tmpa->dx = -tmpa->dx;
|
|
<a name="l439"></a> }
|
|
<a name="l440"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>MAP_BORDER + ANIMAL_HEIGHT <= tmpa->y.i32[</span><span class=cFE>1</span><span class=cF0>] < MAP_HEIGHT - MAP_BORDER</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l441"></a> {
|
|
<a name="l442"></a> tmpa->y -= tmpa->dy;
|
|
<a name="l443"></a> tmpa->dy = -tmpa->dy;
|
|
<a name="l444"></a> }
|
|
<a name="l445"></a> count++;
|
|
<a name="l446"></a> </span><span class=cF1>if</span><span class=cF0> (tmpa->x >> </span><span class=cFE>32</span><span class=cF0> >= FENCE_WIDTH || tmpa->y >> </span><span class=cFE>32</span><span class=cF0> >= FENCE_HEIGHT)
|
|
<a name="l447"></a> my_outside_count++;
|
|
<a name="l448"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l449"></a> }
|
|
<a name="l450"></a> outside_count = my_outside_count;
|
|
<a name="l451"></a>
|
|
<a name="l452"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>updates & </span><span class=cFE>15</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l453"></a> RiverDropsNext(parent);
|
|
<a name="l454"></a>
|
|
<a name="l455"></a> </span><span class=cF1>if</span><span class=cF0> (!tf && !outside_count)
|
|
<a name="l456"></a> {
|
|
<a name="l457"></a> tf = </span><span class=cF5>tS</span><span class=cF0>;
|
|
<a name="l458"></a> </span><span class=cFB>music</span><span class=cF0>.mute = </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l459"></a> </span><span class=cF5>Sound</span><span class=cF0>(</span><span class=cFE>86</span><span class=cF0>);
|
|
<a name="l460"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>200</span><span class=cF0>);
|
|
<a name="l461"></a> </span><span class=cF5>Sound</span><span class=cF0>;
|
|
<a name="l462"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>100</span><span class=cF0>);
|
|
<a name="l463"></a> </span><span class=cF1>if</span><span class=cF0> (tf - t0 < best_score)
|
|
<a name="l464"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l465"></a> best_score = tf - t0;
|
|
<a name="l466"></a> </span><span class=cF5>Sound</span><span class=cF0>(</span><span class=cFE>86</span><span class=cF0>);
|
|
<a name="l467"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>200</span><span class=cF0>);
|
|
<a name="l468"></a> </span><span class=cF5>Sound</span><span class=cF0>;
|
|
<a name="l469"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>100</span><span class=cF0>);
|
|
<a name="l470"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l471"></a> </span><span class=cFB>music</span><span class=cF0>.mute = </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l472"></a> }
|
|
<a name="l473"></a>
|
|
<a name="l474"></a> updates++;
|
|
<a name="l475"></a>
|
|
<a name="l476"></a> </span><span class=cF1>if</span><span class=cF0> (count)
|
|
<a name="l477"></a> stress /= count;
|
|
<a name="l478"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l479"></a> stress = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l480"></a> </span><span class=cF1>if</span><span class=cF0> (stress > </span><span class=cFE>100</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>)
|
|
<a name="l481"></a> {
|
|
<a name="l482"></a> </span><span class=cF5>Yield</span><span class=cF0>;
|
|
<a name="l483"></a> max_speed = stress / </span><span class=cFE>5</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> * </span><span class=cF3>U32_MAX</span><span class=cF0>; </span><span class=cF2>//Converge faster at start-up</span><span class=cF0>
|
|
<a name="l484"></a> }
|
|
<a name="l485"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l486"></a> {
|
|
<a name="l487"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>10</span><span class=cF0>);
|
|
<a name="l488"></a> max_speed = </span><span class=cFE>0</span><span class=cF0>; </span><span class=cF2>//Will be set to normal max speed</span><span class=cF0>
|
|
<a name="l489"></a> }
|
|
<a name="l490"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l491"></a>}
|
|
<a name="l492"></a>
|
|
<a name="l493"></a></span><span class=cF1>U0</span><span class=cF0> SongTask(</span><span class=cF9>I64</span><span class=cF0>)
|
|
<a name="l494"></a>{</span><span class=cF2>//Randomly generated (by God :-)</span><span class=cF0>
|
|
<a name="l495"></a> </span><span class=cF5>Fs</span><span class=cF0>->task_end_cb = &</span><span class=cF5>SoundTaskEndCB</span><span class=cF0>;
|
|
<a name="l496"></a> </span><span class=cF5>MusicSettingsReset</span><span class=cF0>;
|
|
<a name="l497"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
|
|
<a name="l498"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l499"></a> </span><span class=cF5>Play</span><span class=cF0>(</span><span class=cF6>"5qC4etG5DC4B5DCECFqFC4sA5D4A5D4qB"</span><span class=cF0>);
|
|
<a name="l500"></a> </span><span class=cF5>Play</span><span class=cF0>(</span><span class=cF6>"5C4etG5DC4B5DCECFqFC4sA5D4A5D4qB"</span><span class=cF0>);
|
|
<a name="l501"></a> </span><span class=cF5>Play</span><span class=cF0>(</span><span class=cF6>"4sGAGA5qG4etG5GD4eBBqB5F4eBA5qE"</span><span class=cF0>);
|
|
<a name="l502"></a> </span><span class=cF5>Play</span><span class=cF0>(</span><span class=cF6>"4sGAGA5qG4etG5GD4eBBqB5F4eBA5qE"</span><span class=cF0>);
|
|
<a name="l503"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l504"></a>}
|
|
<a name="l505"></a>
|
|
<a name="l506"></a></span><span class=cF1>U0</span><span class=cF0> ReInit()
|
|
<a name="l507"></a>{
|
|
<a name="l508"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
|
<a name="l509"></a>
|
|
<a name="l510"></a> RiverDropsDel;
|
|
<a name="l511"></a> map_dc->color = </span><span class=cF3>LTGREEN</span><span class=cF0>;
|
|
<a name="l512"></a> </span><span class=cF5>GrRect</span><span class=cF0>(map_dc, </span><span class=cFE>2</span><span class=cF0>, </span><span class=cFE>2</span><span class=cF0>, MAP_WIDTH - </span><span class=cFE>4</span><span class=cF0>, MAP_HEIGHT - </span><span class=cFE>4</span><span class=cF0>);
|
|
<a name="l513"></a>
|
|
<a name="l514"></a> RiverMake;
|
|
<a name="l515"></a>
|
|
<a name="l516"></a> </span><span class=cF2>//Plot fence</span><span class=cF0>
|
|
<a name="l517"></a> </span><span class=cF1>for</span><span class=cF0> (i = FENCE_WIDTH; i > </span><span class=cFE>0</span><span class=cF0>; i -= </span><span class=cFE>16</span><span class=cF0>)
|
|
<a name="l518"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(map_dc, i, FENCE_HEIGHT, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cFA><9></span><span class=cF0>);
|
|
<a name="l519"></a> map_dc->thick = </span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l520"></a> map_dc->color = </span><span class=cF3>BROWN</span><span class=cF0>;
|
|
<a name="l521"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < FENCE_HEIGHT - </span><span class=cFE>16</span><span class=cF0>; i += </span><span class=cFE>16</span><span class=cF0>)
|
|
<a name="l522"></a> </span><span class=cF5>GrLine</span><span class=cF0>(map_dc, FENCE_WIDTH - </span><span class=cFE>1</span><span class=cF0>, i, FENCE_WIDTH - </span><span class=cFE>1</span><span class=cF0>, i + </span><span class=cFE>7</span><span class=cF0>);
|
|
<a name="l523"></a> map_dc->color = </span><span class=cF3>LTGRAY</span><span class=cF0>;
|
|
<a name="l524"></a> </span><span class=cF5>GrLine</span><span class=cF0>(map_dc, FENCE_WIDTH, </span><span class=cFE>0</span><span class=cF0>, FENCE_WIDTH, FENCE_HEIGHT - </span><span class=cFE>6</span><span class=cF0>);
|
|
<a name="l525"></a> RedrawGate;
|
|
<a name="l526"></a>
|
|
<a name="l527"></a> map_dc->thick = MAP_BORDER;
|
|
<a name="l528"></a> map_dc->color = </span><span class=cF3>RED</span><span class=cF0>;
|
|
<a name="l529"></a> </span><span class=cF5>GrBorder</span><span class=cF0>(map_dc, MAP_BORDER / </span><span class=cFE>2</span><span class=cF0>, MAP_BORDER / </span><span class=cFE>2</span><span class=cF0>, MAP_WIDTH - </span><span class=cF7>(</span><span class=cF0>MAP_BORDER + </span><span class=cFE>1</span><span class=cF7>)</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>, MAP_HEIGHT - </span><span class=cF7>(</span><span class=cF0>MAP_BORDER + </span><span class=cFE>1</span><span class=cF7>)</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>);
|
|
<a name="l530"></a>
|
|
<a name="l531"></a> </span><span class=cF1>for</span><span class=cF0> (i = MAP_BORDER; i <= MAP_HEIGHT - MAP_BORDER; i++)
|
|
<a name="l532"></a> RiverDropsNext(</span><span class=cF5>Fs</span><span class=cF0>);
|
|
<a name="l533"></a>
|
|
<a name="l534"></a> </span><span class=cF5>MemSet</span><span class=cF0>(a, </span><span class=cFE>0</span><span class=cF0>, ANIMALS_NUM * </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Animal</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l535"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < ANIMALS_NUM; i++)
|
|
<a name="l536"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l537"></a> a[i].num = i;
|
|
<a name="l538"></a> </span><span class=cF1>do</span><span class=cF0>
|
|
<a name="l539"></a> {
|
|
<a name="l540"></a> a[i].x = (</span><span class=cFE>64</span><span class=cF0> + </span><span class=cF5>RandU32</span><span class=cF0> % </span><span class=cF7>(</span><span class=cF0>MAP_WIDTH - </span><span class=cFE>128</span><span class=cF7>)</span><span class=cF0>) << </span><span class=cFE>32</span><span class=cF0>;
|
|
<a name="l541"></a> a[i].y = (</span><span class=cFE>64</span><span class=cF0> + </span><span class=cF5>RandU32</span><span class=cF0> % </span><span class=cF7>(</span><span class=cF0>MAP_WIDTH - </span><span class=cFE>128</span><span class=cF7>)</span><span class=cF0>) << </span><span class=cFE>32</span><span class=cF0>;
|
|
<a name="l542"></a> }
|
|
<a name="l543"></a> </span><span class=cF1>while</span><span class=cF0> (!CheckMap</span><span class=cF7>(</span><span class=cF0>a[i].x >> </span><span class=cFE>32</span><span class=cF0>, a[i].y >> </span><span class=cFE>32</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l544"></a>
|
|
<a name="l545"></a> </span><span class=cF1>if</span><span class=cF0> (i & </span><span class=cFE>1</span><span class=cF0>)
|
|
<a name="l546"></a> a[i].imgs = cow_imgs;
|
|
<a name="l547"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l548"></a> a[i].imgs = bull_imgs;
|
|
<a name="l549"></a> a[i].frame0 = </span><span class=cF5>RandU16</span><span class=cF0> & </span><span class=cFE>3</span><span class=cF0>;
|
|
<a name="l550"></a> BuddySel(i);
|
|
<a name="l551"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l552"></a> outside_count = ANIMALS_NUM;
|
|
<a name="l553"></a> gate_t = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l554"></a> gate_theta = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l555"></a> t0 = </span><span class=cF5>tS</span><span class=cF0>;
|
|
<a name="l556"></a> tf = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l557"></a>}
|
|
<a name="l558"></a>
|
|
<a name="l559"></a></span><span class=cF1>U0</span><span class=cF0> Init()
|
|
<a name="l560"></a>{
|
|
<a name="l561"></a> RiverNew;
|
|
<a name="l562"></a> rd_lock = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l563"></a> </span><span class=cF5>QueueInit</span><span class=cF0>(&rd_head);
|
|
<a name="l564"></a> map_dc = </span><span class=cF5>DCNew</span><span class=cF0>(MAP_WIDTH, MAP_HEIGHT);
|
|
<a name="l565"></a> a = </span><span class=cF5>MAlloc</span><span class=cF0>(ANIMALS_NUM * </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Animal</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l566"></a> ReInit;
|
|
<a name="l567"></a>}
|
|
<a name="l568"></a>
|
|
<a name="l569"></a></span><span class=cF1>U0</span><span class=cF0> CleanUp()
|
|
<a name="l570"></a>{
|
|
<a name="l571"></a> </span><span class=cF5>DCDel</span><span class=cF0>(map_dc);
|
|
<a name="l572"></a> </span><span class=cF5>Free</span><span class=cF0>(a);
|
|
<a name="l573"></a> RiverDropsDel;
|
|
<a name="l574"></a> RiverDel;
|
|
<a name="l575"></a>}
|
|
<a name="l576"></a>
|
|
<a name="l577"></a></span><span class=cF1>U0</span><span class=cF0> RawHide()
|
|
<a name="l578"></a>{
|
|
<a name="l579"></a> </span><span class=cF9>I64</span><span class=cF0> message_code, arg1, arg2;
|
|
<a name="l580"></a> </span><span class=cF5>SettingsPush</span><span class=cF0>; </span><span class=cF2>//See </span><a href="https://tomawezome.github.io/ZealOS/System/TaskSettings.CC.html#l3"><span class=cF4>SettingsPush</span></a><span class=cF0>
|
|
<a name="l581"></a> </span><span class=cF5>MenuPush</span><span class=cF0>(
|
|
<a name="l582"></a> </span><span class=cF6>"File {"</span><span class=cF0>
|
|
<a name="l583"></a> </span><span class=cF6>" Abort(,CH_SHIFT_ESC);"</span><span class=cF0>
|
|
<a name="l584"></a> </span><span class=cF6>" Exit(,CH_ESC);"</span><span class=cF0>
|
|
<a name="l585"></a> </span><span class=cF6>"}"</span><span class=cF0>
|
|
<a name="l586"></a> </span><span class=cF6>"Play {"</span><span class=cF0>
|
|
<a name="l587"></a> </span><span class=cF6>" Restart(,'\n');"</span><span class=cF0>
|
|
<a name="l588"></a> </span><span class=cF6>"}"</span><span class=cF0>
|
|
<a name="l589"></a> );
|
|
<a name="l590"></a> </span><span class=cF5>Fs</span><span class=cF0>->song_task = </span><span class=cF5>Spawn</span><span class=cF0>(&SongTask, </span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF6>"Song"</span><span class=cF0>,, </span><span class=cF5>Fs</span><span class=cF0>);
|
|
<a name="l591"></a>
|
|
<a name="l592"></a> </span><span class=cF5>PopUpOk</span><span class=cF0>(
|
|
<a name="l593"></a> </span><span class=cF6>"Coral the cattle.</span><span class=cF0> </span><span class=cF6>The coral is in the\n"</span><span class=cF0>
|
|
<a name="l594"></a> </span><span class=cF6>"upper-left corner if you scroll.\n\n"</span><span class=cF0>
|
|
<a name="l595"></a> </span><span class=cF6>"Keep holding the $GREEN$<CTRL>$FG$ key and\n"</span><span class=cF0>
|
|
<a name="l596"></a> </span><span class=cF6>"scroll with $GREEN${CTRL-Left Grab}$FG$."</span><span class=cF0>);
|
|
<a name="l597"></a>
|
|
<a name="l598"></a> </span><span class=cF5>Fs</span><span class=cF0>->win_inhibit = </span><span class=cF3>WIG_TASK_DEFAULT</span><span class=cF0> - </span><span class=cF3>WIF_SELF_FOCUS</span><span class=cF0> - </span><span class=cF3>WIF_SELF_BORDER</span><span class=cF0> - </span><span class=cF3>WIF_SELF_GRAB_SCROLL</span><span class=cF0> - </span><span class=cF3>WIF_FOCUS_TASK_MENU</span><span class=cF0>;
|
|
<a name="l599"></a> </span><span class=cF5>AutoComplete</span><span class=cF0>;
|
|
<a name="l600"></a> </span><span class=cF5>WinBorder</span><span class=cF0>;
|
|
<a name="l601"></a> </span><span class=cF5>WinMax</span><span class=cF0>;
|
|
<a name="l602"></a> </span><span class=cF5>DocCursor</span><span class=cF0>;
|
|
<a name="l603"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
|
|
<a name="l604"></a> Init;
|
|
<a name="l605"></a> </span><span class=cF5>Fs</span><span class=cF0>->animate_task = </span><span class=cF5>Spawn</span><span class=cF0>(&AnimateTask, </span><span class=cF5>Fs</span><span class=cF0>, </span><span class=cF6>"Animate"</span><span class=cF0>,, </span><span class=cF5>Fs</span><span class=cF0>);
|
|
<a name="l606"></a> </span><span class=cF5>Fs</span><span class=cF0>->draw_it = &</span><span class=cF5>DrawIt</span><span class=cF0>;
|
|
<a name="l607"></a> </span><span class=cF1>try</span><span class=cF0>
|
|
<a name="l608"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l609"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
|
|
<a name="l610"></a> {
|
|
<a name="l611"></a> message_code = </span><span class=cF5>MessageGet</span><span class=cF0>(&arg1, &arg2, </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>MESSAGE_KEY_DOWN</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>MESSAGE_MS_L_DOWN</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>MESSAGE_MS_R_DOWN</span><span class=cF0>);
|
|
<a name="l612"></a> </span><span class=cF1>switch</span><span class=cF0> (message_code)
|
|
<a name="l613"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l614"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MESSAGE_MS_L_DOWN</span><span class=cF0>: </span><span class=cF2>//Doesn't do anything, yet.</span><span class=cF0>
|
|
<a name="l615"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l616"></a>
|
|
<a name="l617"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MESSAGE_MS_R_DOWN</span><span class=cF0>: </span><span class=cF2>//Doesn't do anything, yet.</span><span class=cF0>
|
|
<a name="l618"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l619"></a>
|
|
<a name="l620"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MESSAGE_KEY_DOWN</span><span class=cF0>:
|
|
<a name="l621"></a> </span><span class=cF1>switch</span><span class=cF0> (arg1)
|
|
<a name="l622"></a> {
|
|
<a name="l623"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\n'</span><span class=cF0>:
|
|
<a name="l624"></a> ReInit;
|
|
<a name="l625"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l626"></a>
|
|
<a name="l627"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0>:
|
|
<a name="l628"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_ESC</span><span class=cF0>:
|
|
<a name="l629"></a> </span><span class=cF1>goto</span><span class=cF0> rh_done;
|
|
<a name="l630"></a> }
|
|
<a name="l631"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l632"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l633"></a> }
|
|
<a name="l634"></a>rh_done:
|
|
<a name="l635"></a> </span><span class=cF5>MessageGet</span><span class=cF0>(,, </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>MESSAGE_KEY_UP</span><span class=cF0>);
|
|
<a name="l636"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l637"></a> </span><span class=cF1>catch</span><span class=cF0>
|
|
<a name="l638"></a> </span><span class=cF5>PutExcept</span><span class=cF0>;
|
|
<a name="l639"></a> </span><span class=cF5>SettingsPop</span><span class=cF0>;
|
|
<a name="l640"></a> CleanUp;
|
|
<a name="l641"></a> </span><span class=cF5>MenuPop</span><span class=cF0>;
|
|
<a name="l642"></a> </span><span class=cF5>RegWrite</span><span class=cF0>(</span><span class=cF6>"ZealOS/RawHide"</span><span class=cF0>, </span><span class=cF6>"F64 best_score=%5.4f;\n"</span><span class=cF0>, best_score);
|
|
<a name="l643"></a>}
|
|
<a name="l644"></a>
|
|
<a name="l645"></a>RawHide;
|
|
</span></pre></body>
|
|
</html>
|