624 lines
51 KiB
HTML
Executable File
624 lines
51 KiB
HTML
Executable File
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="generator" content="TempleOS V5.03">
|
|
<meta name="viewport" content="width=device-width">
|
|
<link rel="stylesheet" href="/style/templeos.css">
|
|
<script src="/script/templeos.js"></script>
|
|
<style type="text/css">
|
|
.cF0{color:#000000;background-color:#ffffff;}
|
|
.cF1{color:#0000aa;background-color:#ffffff;}
|
|
.cF2{color:#00aa00;background-color:#ffffff;}
|
|
.cF3{color:#00aaaa;background-color:#ffffff;}
|
|
.cF4{color:#aa0000;background-color:#ffffff;}
|
|
.cF5{color:#aa00aa;background-color:#ffffff;}
|
|
.cF6{color:#aa5500;background-color:#ffffff;}
|
|
.cF7{color:#aaaaaa;background-color:#ffffff;}
|
|
.cF8{color:#555555;background-color:#ffffff;}
|
|
.cF9{color:#5555ff;background-color:#ffffff;}
|
|
.cFA{color:#55ff55;background-color:#ffffff;}
|
|
.cFB{color:#55ffff;background-color:#ffffff;}
|
|
.cFC{color:#ff5555;background-color:#ffffff;}
|
|
.cFD{color:#ff55ff;background-color:#ffffff;}
|
|
.cFE{color:#ffff55;background-color:#ffffff;}
|
|
.cFF{color:#ffffff;background-color:#ffffff;}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<pre id="content">
|
|
<a name="l1"></a><span class=cF5>RegDft</span><span class=cF0>(</span><span class=cF6>"TempleOS/Wenceslas"</span><span class=cF0>,</span><span class=cF6>"F64 best_score=9999;\n"</span><span class=cF0>);
|
|
<a name="l2"></a></span><span class=cF5>RegExe</span><span class=cF0>(</span><span class=cF6>"TempleOS/Wenceslas"</span><span class=cF0>);
|
|
<a name="l3"></a>
|
|
<a name="l4"></a>#</span><span class=cF1>define</span><span class=cF0> BORDER 5
|
|
<a name="l5"></a>#</span><span class=cF1>define</span><span class=cF0> KING_STEP 6
|
|
<a name="l6"></a>
|
|
<a name="l7"></a>
|
|
<a name="l8"></a>
|
|
<a name="l9"></a>
|
|
<a name="l10"></a>
|
|
<a name="l11"></a> </span><span class=cFA><1>/* Graphics Not Rendered in HTML */</span><span class=cF0> </span><span class=cF2>//See </span><span class=cF9><u>::/Apps/GrModels</u></span><span class=cF2> for making 3D men.</span><span class=cF0>
|
|
<a name="l12"></a>
|
|
<a name="l13"></a>
|
|
<a name="l14"></a>
|
|
<a name="l15"></a>
|
|
<a name="l16"></a> </span><span class=cFA><2>/* 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> </span><span class=cFA><3>/* Graphics Not Rendered in HTML */</span><span class=cF0>
|
|
<a name="l21"></a>
|
|
<a name="l22"></a>
|
|
<a name="l23"></a>
|
|
<a name="l24"></a> </span><span class=cFA><4>/* 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> </span><span class=cFA><5>/* Graphics Not Rendered in HTML */</span><span class=cF0>
|
|
<a name="l29"></a>
|
|
<a name="l30"></a>
|
|
<a name="l31"></a>
|
|
<a name="l32"></a> </span><span class=cFA><6>/* 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>
|
|
<a name="l42"></a>
|
|
<a name="l43"></a>
|
|
<a name="l44"></a>
|
|
<a name="l45"></a> </span><span class=cFA><7>/* Graphics Not Rendered in HTML */</span><span class=cF0>
|
|
<a name="l46"></a>
|
|
<a name="l47"></a>
|
|
<a name="l48"></a>
|
|
<a name="l49"></a>
|
|
<a name="l50"></a> </span><span class=cFA><8>/* Graphics Not Rendered in HTML */</span><span class=cF0>
|
|
<a name="l51"></a>
|
|
<a name="l52"></a>
|
|
<a name="l53"></a>
|
|
<a name="l54"></a>
|
|
<a name="l55"></a>
|
|
<a name="l56"></a>
|
|
<a name="l57"></a> </span><span class=cFA><9>/* Graphics Not Rendered in HTML */</span><span class=cF0>
|
|
<a name="l58"></a>
|
|
<a name="l59"></a>
|
|
<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>
|
|
<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> </span><span class=cFA><10>/* Graphics Not Rendered in HTML */</span><span class=cF0>
|
|
<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> </span><span class=cFA><11>/* Graphics Not Rendered in HTML */</span><span class=cF0>
|
|
<a name="l84"></a>
|
|
<a name="l85"></a>
|
|
<a name="l86"></a></span><span class=cF1>U8</span><span class=cF0> *king_imgs[4]={</span><span class=cFA><2></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>};
|
|
<a name="l87"></a></span><span class=cF1>U8</span><span class=cF0> *peasant_imgs[4]={</span><span class=cFA><5></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>};
|
|
<a name="l88"></a>
|
|
<a name="l89"></a>
|
|
<a name="l90"></a>#</span><span class=cF1>define</span><span class=cF0> TREES_NUM 8
|
|
<a name="l91"></a></span><span class=cF1>class</span><span class=cF0> Tree
|
|
<a name="l92"></a>{
|
|
<a name="l93"></a> </span><span class=cF9>U16</span><span class=cF0> x,y;
|
|
<a name="l94"></a> </span><span class=cF9>I64</span><span class=cF0> fire_frame_idx;
|
|
<a name="l95"></a>} trees[TREES_NUM];
|
|
<a name="l96"></a>
|
|
<a name="l97"></a></span><span class=cF9>U64</span><span class=cF0> snow_x,snow_y,new_snow_mS;
|
|
<a name="l98"></a>#</span><span class=cF1>define</span><span class=cF0> SNOW_TILE_SIZE 128
|
|
<a name="l99"></a></span><span class=cF9>CDC</span><span class=cF0> *snow_tile;
|
|
<a name="l100"></a>
|
|
<a name="l101"></a></span><span class=cF9>I64</span><span class=cF0> king_x,king_y,king_mS,king_phase,
|
|
<a name="l102"></a> not_stopped_cnt;
|
|
<a name="l103"></a></span><span class=cF1>F64</span><span class=cF0> king_timeout,king_theta,t0,tf,door_open_t0;
|
|
<a name="l104"></a></span><span class=cF9>I64</span><span class=cF0> animate_mS,animate_phase;
|
|
<a name="l105"></a>
|
|
<a name="l106"></a>#</span><span class=cF1>define</span><span class=cF0> PEASANTS_NUM 10
|
|
<a name="l107"></a></span><span class=cF1>class</span><span class=cF0> Peasant
|
|
<a name="l108"></a>{
|
|
<a name="l109"></a> Peasant *next,*last;
|
|
<a name="l110"></a> </span><span class=cF1>F64</span><span class=cF0> x,y,theta,door_opened_t0;
|
|
<a name="l111"></a> </span><span class=cF1>Bool</span><span class=cF0> stopped;
|
|
<a name="l112"></a>} peasant_head;
|
|
<a name="l113"></a>
|
|
<a name="l114"></a></span><span class=cF1>class</span><span class=cF0> Step
|
|
<a name="l115"></a>{
|
|
<a name="l116"></a> Step *next,*last;
|
|
<a name="l117"></a> </span><span class=cF9>U16</span><span class=cF0> x,y;
|
|
<a name="l118"></a> </span><span class=cF1>F64</span><span class=cF0> t0;
|
|
<a name="l119"></a>} step_head,king_step_head;
|
|
<a name="l120"></a>
|
|
<a name="l121"></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="l122"></a>{
|
|
<a name="l123"></a> </span><span class=cF9>I64</span><span class=cF0> r[16],i,w=task->pix_width,h=task->pix_height,x,y;
|
|
<a name="l124"></a> </span><span class=cF1>U8</span><span class=cF0> *img,*tmps;
|
|
<a name="l125"></a> Step *tmpst;
|
|
<a name="l126"></a> Peasant *tmpp;
|
|
<a name="l127"></a> </span><span class=cF1>F64</span><span class=cF0> tt;
|
|
<a name="l128"></a>
|
|
<a name="l129"></a> dc->thick=1;
|
|
<a name="l130"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<TREES_NUM;i++) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l131"></a> </span><span class=cF1>if</span><span class=cF0> (trees[i].y<=h/2) {</span><span class=cF2>//Draw trees behind house</span><span class=cF0>
|
|
<a name="l132"></a> </span><span class=cF1>if</span><span class=cF0> (trees[i].fire_frame_idx) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l133"></a> </span><span class=cF1>if</span><span class=cF0> (trees[i].fire_frame_idx++&1)
|
|
<a name="l134"></a> img=</span><span class=cFA><8></span><span class=cF0>;
|
|
<a name="l135"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l136"></a> img=</span><span class=cFA><9></span><span class=cF0>;
|
|
<a name="l137"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l138"></a> img=</span><span class=cFA><7></span><span class=cF0>;
|
|
<a name="l139"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc,trees[i].x,trees[i].y,0,img);
|
|
<a name="l140"></a> }
|
|
<a name="l141"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l142"></a>
|
|
<a name="l143"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc,w/2,h/2,0,</span><span class=cFA><10></span><span class=cF0>);
|
|
<a name="l144"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>tS</span><span class=cF0><door_open_t0+1.0)
|
|
<a name="l145"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc,w/2,h/2,0,</span><span class=cFA><11></span><span class=cF0>);
|
|
<a name="l146"></a>
|
|
<a name="l147"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<TREES_NUM;i++) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l148"></a> </span><span class=cF1>if</span><span class=cF0> (trees[i].y>h/2) {</span><span class=cF2>//Draw trees in front of house</span><span class=cF0>
|
|
<a name="l149"></a> </span><span class=cF1>if</span><span class=cF0> (trees[i].fire_frame_idx) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l150"></a> </span><span class=cF1>if</span><span class=cF0> (trees[i].fire_frame_idx++&1)
|
|
<a name="l151"></a> img=</span><span class=cFA><8></span><span class=cF0>;
|
|
<a name="l152"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l153"></a> img=</span><span class=cFA><9></span><span class=cF0>;
|
|
<a name="l154"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l155"></a> img=</span><span class=cFA><7></span><span class=cF0>;
|
|
<a name="l156"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc,trees[i].x,trees[i].y,0,img);
|
|
<a name="l157"></a> }
|
|
<a name="l158"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l159"></a>
|
|
<a name="l160"></a> tmpst=step_head.next;
|
|
<a name="l161"></a> </span><span class=cF1>while</span><span class=cF0> (tmpst!=&step_head) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l162"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>tS</span><span class=cF0>-tmpst->t0<2.0)
|
|
<a name="l163"></a> dc->color=</span><span class=cF3>DKGRAY</span><span class=cF0>;
|
|
<a name="l164"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l165"></a> dc->color=</span><span class=cF3>LTGRAY</span><span class=cF0>;
|
|
<a name="l166"></a> dc->thick=4;
|
|
<a name="l167"></a> </span><span class=cF5>GrPlot3</span><span class=cF0>(dc,tmpst->x,tmpst->y,0);
|
|
<a name="l168"></a> tmpst=tmpst->next;
|
|
<a name="l169"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l170"></a>
|
|
<a name="l171"></a> </span><span class=cF5>DCDepthBufAlloc</span><span class=cF0>(dc);
|
|
<a name="l172"></a> dc->flags|=</span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF0>;
|
|
<a name="l173"></a> dc->thick=1;
|
|
<a name="l174"></a> tmpp=peasant_head.next;
|
|
<a name="l175"></a> </span><span class=cF1>while</span><span class=cF0> (tmpp!=&peasant_head) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l176"></a> </span><span class=cF5>Mat4x4IdentEqu</span><span class=cF0>(r);
|
|
<a name="l177"></a> </span><span class=cF5>Mat4x4RotY</span><span class=cF0>(r,tmpp->theta+</span><span class=cF3>pi</span><span class=cF0>/2);
|
|
<a name="l178"></a> </span><span class=cF5>Mat4x4RotX</span><span class=cF0>(r,</span><span class=cF3>pi</span><span class=cF0>/6);
|
|
<a name="l179"></a> </span><span class=cF1>if</span><span class=cF0> (tmpp->stopped)
|
|
<a name="l180"></a> </span><span class=cF5>Sprite3Mat4x4B</span><span class=cF0>(dc,tmpp->x,tmpp->y,</span><span class=cF3>GR_Z_ALL</span><span class=cF0>,peasant_imgs[0],r);
|
|
<a name="l181"></a> </span><span class=cF1>else</span><span class=cF0> {
|
|
<a name="l182"></a> tmps=</span><span class=cF5>SpriteInterpolate</span><span class=cF0>(</span><span class=cF5>Saw</span><span class=cF7>(</span><span class=cF0>animate_mS/250.0,1.0</span><span class=cF7>)</span><span class=cF0>,
|
|
<a name="l183"></a> peasant_imgs[ animate_phase &3],
|
|
<a name="l184"></a> peasant_imgs[</span><span class=cF7>(</span><span class=cF0>animate_phase+1</span><span class=cF7>)</span><span class=cF0>&3]);
|
|
<a name="l185"></a> </span><span class=cF5>Sprite3Mat4x4B</span><span class=cF0>(dc,tmpp->x,tmpp->y,</span><span class=cF3>GR_Z_ALL</span><span class=cF0>,tmps,r);
|
|
<a name="l186"></a> </span><span class=cF5>Free</span><span class=cF0>(tmps);
|
|
<a name="l187"></a> }
|
|
<a name="l188"></a> tmpp=tmpp->next;
|
|
<a name="l189"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l190"></a>
|
|
<a name="l191"></a> dc->thick=1;
|
|
<a name="l192"></a> </span><span class=cF5>Mat4x4IdentEqu</span><span class=cF0>(r);
|
|
<a name="l193"></a> </span><span class=cF5>Mat4x4RotY</span><span class=cF0>(r,king_theta+</span><span class=cF3>pi</span><span class=cF0>/2);
|
|
<a name="l194"></a> </span><span class=cF5>Mat4x4RotX</span><span class=cF0>(r,</span><span class=cF3>pi</span><span class=cF0>/6);
|
|
<a name="l195"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>tS</span><span class=cF0>>king_timeout)
|
|
<a name="l196"></a> </span><span class=cF5>Sprite3Mat4x4B</span><span class=cF0>(dc,king_x,king_y,</span><span class=cF3>GR_Z_ALL</span><span class=cF0>,king_imgs[0],r);
|
|
<a name="l197"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l198"></a> tmps=</span><span class=cF5>SpriteInterpolate</span><span class=cF0>(</span><span class=cF5>Saw</span><span class=cF7>(</span><span class=cF0>king_mS/250.0,1.0</span><span class=cF7>)</span><span class=cF0>,
|
|
<a name="l199"></a> king_imgs[ king_phase &3],
|
|
<a name="l200"></a> king_imgs[</span><span class=cF7>(</span><span class=cF0>king_phase+1</span><span class=cF7>)</span><span class=cF0>&3]);
|
|
<a name="l201"></a> </span><span class=cF5>Sprite3Mat4x4B</span><span class=cF0>(dc,king_x,king_y,</span><span class=cF3>GR_Z_ALL</span><span class=cF0>,tmps,r);
|
|
<a name="l202"></a> </span><span class=cF5>Free</span><span class=cF0>(tmps);
|
|
<a name="l203"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l204"></a>
|
|
<a name="l205"></a> dc->thick=1;
|
|
<a name="l206"></a> dc->color=</span><span class=cF3>ROP_MONO</span><span class=cF0>|</span><span class=cF3>WHITE</span><span class=cF0>;
|
|
<a name="l207"></a> </span><span class=cF1>for</span><span class=cF0> (y=snow_y%SNOW_TILE_SIZE-SNOW_TILE_SIZE;y<=h;y+=SNOW_TILE_SIZE)
|
|
<a name="l208"></a> </span><span class=cF1>for</span><span class=cF0> (x=snow_x%SNOW_TILE_SIZE-SNOW_TILE_SIZE;x<=w;x+=SNOW_TILE_SIZE)
|
|
<a name="l209"></a> </span><span class=cF5>GrBlot</span><span class=cF0>(dc,x,y,snow_tile);
|
|
<a name="l210"></a>
|
|
<a name="l211"></a> </span><span class=cF1>if</span><span class=cF0> (tf) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l212"></a> dc->color=</span><span class=cF3>LTRED</span><span class=cF0>;
|
|
<a name="l213"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Blink</span><span class=cF0>)
|
|
<a name="l214"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc,w/2-</span><span class=cF7>(</span><span class=cF3>FONT_WIDTH</span><span class=cF0>*14</span><span class=cF7>)</span><span class=cF0>/2,h/2+</span><span class=cF3>FONT_HEIGHT</span><span class=cF0>,</span><span class=cF6>"Game Completed"</span><span class=cF0>);
|
|
<a name="l215"></a> tt=tf;
|
|
<a name="l216"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l217"></a> tt=</span><span class=cF5>tS</span><span class=cF0>;
|
|
<a name="l218"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l219"></a> dc->color=</span><span class=cF3>LTBLUE</span><span class=cF0>;
|
|
<a name="l220"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc,0,0,</span><span class=cF6>"Freezing Peasants:%d Time:%3.2f Best:%3.2f"</span><span class=cF0>,
|
|
<a name="l221"></a> not_stopped_cnt,tt-t0,best_score);
|
|
<a name="l222"></a>}
|
|
<a name="l223"></a>
|
|
<a name="l224"></a></span><span class=cF1>U0</span><span class=cF0> StepNew(</span><span class=cF9>CTask</span><span class=cF0> *task,</span><span class=cF9>I64</span><span class=cF0> x,</span><span class=cF9>I64</span><span class=cF0> y,</span><span class=cF1>F64</span><span class=cF0> theta,</span><span class=cF1>Bool</span><span class=cF0> left_right,</span><span class=cF1>Bool</span><span class=cF0> king)
|
|
<a name="l225"></a>{
|
|
<a name="l226"></a> Step *tmps;
|
|
<a name="l227"></a>
|
|
<a name="l228"></a> </span><span class=cF1>if</span><span class=cF0> (king) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l229"></a> tmps=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Step</span><span class=cF7>)</span><span class=cF0>,task);
|
|
<a name="l230"></a> tmps->x=x;
|
|
<a name="l231"></a> tmps->y=y;
|
|
<a name="l232"></a> tmps->t0=</span><span class=cF5>tS</span><span class=cF0>;
|
|
<a name="l233"></a> </span><span class=cF5>QueIns</span><span class=cF0>(tmps,king_step_head.last);
|
|
<a name="l234"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l235"></a>
|
|
<a name="l236"></a> </span><span class=cF1>if</span><span class=cF0> (left_right) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l237"></a> tmps=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Step</span><span class=cF7>)</span><span class=cF0>,task);
|
|
<a name="l238"></a> tmps->x=x-3.5*</span><span class=cF5>Sin</span><span class=cF0>(theta)+2.0*</span><span class=cF5>Cos</span><span class=cF0>(theta);
|
|
<a name="l239"></a> tmps->y=y+3.5*</span><span class=cF5>Cos</span><span class=cF0>(theta)+2.0*</span><span class=cF5>Sin</span><span class=cF0>(theta);
|
|
<a name="l240"></a> tmps->t0=</span><span class=cF5>tS</span><span class=cF0>;
|
|
<a name="l241"></a> </span><span class=cF5>QueIns</span><span class=cF0>(tmps,step_head.last);
|
|
<a name="l242"></a> tmps=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Step</span><span class=cF7>)</span><span class=cF0>,task);
|
|
<a name="l243"></a> tmps->x=x-3.5*</span><span class=cF5>Sin</span><span class=cF0>(theta)+5.0*</span><span class=cF5>Cos</span><span class=cF0>(theta);
|
|
<a name="l244"></a> tmps->y=y+3.5*</span><span class=cF5>Cos</span><span class=cF0>(theta)+5.0*</span><span class=cF5>Sin</span><span class=cF0>(theta);
|
|
<a name="l245"></a> tmps->t0=</span><span class=cF5>tS</span><span class=cF0>;
|
|
<a name="l246"></a> </span><span class=cF5>QueIns</span><span class=cF0>(tmps,step_head.last);
|
|
<a name="l247"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l248"></a> tmps=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Step</span><span class=cF7>)</span><span class=cF0>,task);
|
|
<a name="l249"></a> tmps->x=x+3.5*</span><span class=cF5>Sin</span><span class=cF0>(theta)+0.0*</span><span class=cF5>Cos</span><span class=cF0>(theta);
|
|
<a name="l250"></a> tmps->y=y-3.5*</span><span class=cF5>Cos</span><span class=cF0>(theta)+0.0*</span><span class=cF5>Sin</span><span class=cF0>(theta);
|
|
<a name="l251"></a> tmps->t0=</span><span class=cF5>tS</span><span class=cF0>;
|
|
<a name="l252"></a> </span><span class=cF5>QueIns</span><span class=cF0>(tmps,step_head.last);
|
|
<a name="l253"></a> tmps=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Step</span><span class=cF7>)</span><span class=cF0>,task);
|
|
<a name="l254"></a> tmps->x=x+3.5*</span><span class=cF5>Sin</span><span class=cF0>(theta)+3.0*</span><span class=cF5>Cos</span><span class=cF0>(theta);
|
|
<a name="l255"></a> tmps->y=y-3.5*</span><span class=cF5>Cos</span><span class=cF0>(theta)+3.0*</span><span class=cF5>Sin</span><span class=cF0>(theta);
|
|
<a name="l256"></a> tmps->t0=</span><span class=cF5>tS</span><span class=cF0>;
|
|
<a name="l257"></a> </span><span class=cF5>QueIns</span><span class=cF0>(tmps,step_head.last);
|
|
<a name="l258"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l259"></a>}
|
|
<a name="l260"></a>
|
|
<a name="l261"></a></span><span class=cF1>U0</span><span class=cF0> Init()
|
|
<a name="l262"></a>{
|
|
<a name="l263"></a> </span><span class=cF9>I64</span><span class=cF0> i,min_x,max_x,min_y,max_y,
|
|
<a name="l264"></a> w=</span><span class=cF5>Fs</span><span class=cF0>->pix_width,h=</span><span class=cF5>Fs</span><span class=cF0>->pix_height;
|
|
<a name="l265"></a> Peasant *tmpp;
|
|
<a name="l266"></a>
|
|
<a name="l267"></a> snow_x=snow_y=0;
|
|
<a name="l268"></a> new_snow_mS=0;
|
|
<a name="l269"></a> snow_tile=</span><span class=cF5>DCNew</span><span class=cF0>(SNOW_TILE_SIZE,SNOW_TILE_SIZE);
|
|
<a name="l270"></a>
|
|
<a name="l271"></a> </span><span class=cF5>SpriteExtents</span><span class=cF0>(</span><span class=cFA><7></span><span class=cF0>,&min_x,&max_x,&min_y,&max_y);
|
|
<a name="l272"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<TREES_NUM;i++) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l273"></a> trees[i].x=</span><span class=cF5>RandU16</span><span class=cF0>%(w-2*BORDER-</span><span class=cF7>(</span><span class=cF0>max_x-min_x+1</span><span class=cF7>)</span><span class=cF0>)+BORDER-min_x;
|
|
<a name="l274"></a> trees[i].y=</span><span class=cF5>RandU16</span><span class=cF0>%(h-2*BORDER-</span><span class=cF7>(</span><span class=cF0>max_y-min_y+1</span><span class=cF7>)</span><span class=cF0>)+BORDER-min_y;
|
|
<a name="l275"></a> trees[i].fire_frame_idx=0;
|
|
<a name="l276"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l277"></a>
|
|
<a name="l278"></a> </span><span class=cF5>QueInit</span><span class=cF0>(&step_head);
|
|
<a name="l279"></a> </span><span class=cF5>QueInit</span><span class=cF0>(&king_step_head);
|
|
<a name="l280"></a>
|
|
<a name="l281"></a> </span><span class=cF5>SpriteExtents</span><span class=cF0>(</span><span class=cFA><12></span><span class=cF0>,&min_x,&max_x,&min_y,&max_y);
|
|
<a name="l282"></a> </span><span class=cF5>QueInit</span><span class=cF0>(&peasant_head);
|
|
<a name="l283"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<PEASANTS_NUM;i++) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l284"></a> tmpp=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>Peasant</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l285"></a> tmpp->x=</span><span class=cF5>RandU16</span><span class=cF0>%(w-2*BORDER-</span><span class=cF7>(</span><span class=cF0>max_x-min_x+1</span><span class=cF7>)</span><span class=cF0>)+BORDER-min_x;
|
|
<a name="l286"></a> tmpp->y=</span><span class=cF5>RandU16</span><span class=cF0>%(h-2*BORDER-</span><span class=cF7>(</span><span class=cF0>max_y-min_y+1</span><span class=cF7>)</span><span class=cF0>)+BORDER-min_y;
|
|
<a name="l287"></a> tmpp->theta=</span><span class=cF3>pi</span><span class=cF0>*2*</span><span class=cF5>Rand</span><span class=cF0>;
|
|
<a name="l288"></a> tmpp->door_opened_t0=0;
|
|
<a name="l289"></a> tmpp->stopped=</span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l290"></a> </span><span class=cF5>QueIns</span><span class=cF0>(tmpp,peasant_head.last);
|
|
<a name="l291"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l292"></a> animate_phase=0;
|
|
<a name="l293"></a> animate_mS=0;
|
|
<a name="l294"></a> king_phase=0;
|
|
<a name="l295"></a> king_mS=0;
|
|
<a name="l296"></a> king_timeout=0;
|
|
<a name="l297"></a> king_x=w/2;
|
|
<a name="l298"></a> king_y=h/2;
|
|
<a name="l299"></a> king_theta=-</span><span class=cF3>pi</span><span class=cF0>/2;
|
|
<a name="l300"></a> door_open_t0=0;
|
|
<a name="l301"></a> t0=</span><span class=cF5>tS</span><span class=cF0>;
|
|
<a name="l302"></a> tf=0;
|
|
<a name="l303"></a>}
|
|
<a name="l304"></a>
|
|
<a name="l305"></a></span><span class=cF1>U0</span><span class=cF0> CleanUp()
|
|
<a name="l306"></a>{
|
|
<a name="l307"></a> </span><span class=cF5>DCDel</span><span class=cF0>(snow_tile);
|
|
<a name="l308"></a> </span><span class=cF5>QueDel</span><span class=cF0>(&peasant_head,</span><span class=cF3>TRUE</span><span class=cF0>);
|
|
<a name="l309"></a> </span><span class=cF5>QueDel</span><span class=cF0>(&step_head,</span><span class=cF3>TRUE</span><span class=cF0>);
|
|
<a name="l310"></a> </span><span class=cF5>QueDel</span><span class=cF0>(&king_step_head,</span><span class=cF3>TRUE</span><span class=cF0>);
|
|
<a name="l311"></a>}
|
|
<a name="l312"></a>
|
|
<a name="l313"></a></span><span class=cF1>U0</span><span class=cF0> Follow(</span><span class=cF9>CTask</span><span class=cF0> *,Peasant *tmpp)
|
|
<a name="l314"></a>{
|
|
<a name="l315"></a> Step *tmps=king_step_head.next;
|
|
<a name="l316"></a> </span><span class=cF1>F64</span><span class=cF0> d,best_d=</span><span class=cF3>F64_MAX</span><span class=cF0>;
|
|
<a name="l317"></a> </span><span class=cF1>while</span><span class=cF0> (tmps!=&king_step_head) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l318"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>d=</span><span class=cF5>Sqr</span><span class=cF0>(tmps->x-tmpp->x)+</span><span class=cF5>Sqr</span><span class=cF0>(tmps->y-tmpp->y)</span><span class=cF7>)</span><span class=cF0> &&
|
|
<a name="l319"></a> d<15*15) {
|
|
<a name="l320"></a> d+=1000*</span><span class=cF5>Sqr</span><span class=cF0>(</span><span class=cF5>tS</span><span class=cF0>-tmps->t0);
|
|
<a name="l321"></a> </span><span class=cF1>if</span><span class=cF0> (d<best_d) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l322"></a> best_d=d;
|
|
<a name="l323"></a> tmpp->theta=</span><span class=cF5>Arg</span><span class=cF0>(tmps->x-tmpp->x,tmps->y-tmpp->y);
|
|
<a name="l324"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l325"></a> }
|
|
<a name="l326"></a> tmps=tmps->next;
|
|
<a name="l327"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l328"></a>}
|
|
<a name="l329"></a>
|
|
<a name="l330"></a></span><span class=cF1>U0</span><span class=cF0> AnimateTask(</span><span class=cF9>I64</span><span class=cF0>)
|
|
<a name="l331"></a>{
|
|
<a name="l332"></a> Step *tmps,*tmps1;
|
|
<a name="l333"></a> Peasant *tmpp;
|
|
<a name="l334"></a> </span><span class=cF9>I64</span><span class=cF0> i,w,h;
|
|
<a name="l335"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l336"></a> w=</span><span class=cF5>Fs</span><span class=cF0>->parent_task->pix_width;
|
|
<a name="l337"></a> h=</span><span class=cF5>Fs</span><span class=cF0>->parent_task->pix_height;
|
|
<a name="l338"></a>
|
|
<a name="l339"></a> tmps=step_head.next;
|
|
<a name="l340"></a> </span><span class=cF1>while</span><span class=cF0> (tmps!=&step_head) {
|
|
<a name="l341"></a> tmps1=tmps->next;
|
|
<a name="l342"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>tS</span><span class=cF0>-tmps->t0>5.0) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l343"></a> </span><span class=cF5>QueRem</span><span class=cF0>(tmps);
|
|
<a name="l344"></a> </span><span class=cF5>Free</span><span class=cF0>(tmps);
|
|
<a name="l345"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l346"></a> tmps=tmps1;
|
|
<a name="l347"></a> }
|
|
<a name="l348"></a>
|
|
<a name="l349"></a> tmps=king_step_head.next;
|
|
<a name="l350"></a> </span><span class=cF1>while</span><span class=cF0> (tmps!=&king_step_head) {
|
|
<a name="l351"></a> tmps1=tmps->next;
|
|
<a name="l352"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>tS</span><span class=cF0>-tmps->t0>3.0) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l353"></a> </span><span class=cF5>QueRem</span><span class=cF0>(tmps);
|
|
<a name="l354"></a> </span><span class=cF5>Free</span><span class=cF0>(tmps);
|
|
<a name="l355"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l356"></a> tmps=tmps1;
|
|
<a name="l357"></a> }
|
|
<a name="l358"></a>
|
|
<a name="l359"></a> not_stopped_cnt=0;
|
|
<a name="l360"></a> tmpp=peasant_head.next;
|
|
<a name="l361"></a> </span><span class=cF1>while</span><span class=cF0> (tmpp!=&peasant_head) {
|
|
<a name="l362"></a> </span><span class=cF1>if</span><span class=cF0> (tmpp->stopped) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l363"></a> </span><span class=cF1>if</span><span class=cF0> (tmpp->door_opened_t0 && </span><span class=cF5>tS</span><span class=cF0>>tmpp->door_opened_t0+1.0) {
|
|
<a name="l364"></a> tmpp->door_opened_t0=0;
|
|
<a name="l365"></a> tmpp->y=tmpp->x=-9999;
|
|
<a name="l366"></a> }
|
|
<a name="l367"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l368"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Sqr</span><span class=cF7>(</span><span class=cF0>tmpp->x-w/2</span><span class=cF7>)</span><span class=cF0>+</span><span class=cF5>Sqr</span><span class=cF7>(</span><span class=cF0>tmpp->y-h/2</span><span class=cF7>)</span><span class=cF0><20*20) {
|
|
<a name="l369"></a> tmpp->stopped=</span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l370"></a> tmpp->door_opened_t0=door_open_t0=</span><span class=cF5>tS</span><span class=cF0>;
|
|
<a name="l371"></a> }
|
|
<a name="l372"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<TREES_NUM;i++) </span><span class=cF2>//Hang-out by fire</span><span class=cF0>
|
|
<a name="l373"></a> </span><span class=cF1>if</span><span class=cF0> (trees[i].fire_frame_idx &&
|
|
<a name="l374"></a> </span><span class=cF5>Sqr</span><span class=cF7>(</span><span class=cF0>tmpp->x-trees[i].x</span><span class=cF7>)</span><span class=cF0>+</span><span class=cF5>Sqr</span><span class=cF7>(</span><span class=cF0>tmpp->y-trees[i].y</span><span class=cF7>)</span><span class=cF0><20*20) {
|
|
<a name="l375"></a> tmpp->stopped=</span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l376"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l377"></a> }
|
|
<a name="l378"></a> </span><span class=cF1>if</span><span class=cF0> (!tmpp->stopped) {
|
|
<a name="l379"></a> Follow(</span><span class=cF5>Fs</span><span class=cF0>->parent_task,tmpp);
|
|
<a name="l380"></a> tmpp->x+=</span><span class=cF5>Cos</span><span class=cF0>(tmpp->theta)/100;
|
|
<a name="l381"></a> tmpp->y+=</span><span class=cF5>Sin</span><span class=cF0>(tmpp->theta)/100;
|
|
<a name="l382"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>BORDER/2<=tmpp->x<w-BORDER/2</span><span class=cF7>)</span><span class=cF0> ||
|
|
<a name="l383"></a> !</span><span class=cF7>(</span><span class=cF0>BORDER/2<=tmpp->y<h-BORDER/2</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l384"></a> tmpp->theta+=</span><span class=cF3>pi</span><span class=cF0>;
|
|
<a name="l385"></a> tmpp->x+=3*</span><span class=cF5>Cos</span><span class=cF0>(tmpp->theta)/100;
|
|
<a name="l386"></a> tmpp->y+=3*</span><span class=cF5>Sin</span><span class=cF0>(tmpp->theta)/100;
|
|
<a name="l387"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l388"></a> </span><span class=cF1>if</span><span class=cF0> (!animate_mS && animate_phase&1)
|
|
<a name="l389"></a> StepNew(</span><span class=cF5>Fs</span><span class=cF0>->parent_task,tmpp->x,tmpp->y,tmpp->theta,
|
|
<a name="l390"></a> animate_phase&2,</span><span class=cF3>FALSE</span><span class=cF0>);
|
|
<a name="l391"></a> not_stopped_cnt++;
|
|
<a name="l392"></a> }
|
|
<a name="l393"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l394"></a> tmpp=tmpp->next;
|
|
<a name="l395"></a> }
|
|
<a name="l396"></a> </span><span class=cF1>if</span><span class=cF0> (!not_stopped_cnt && !tf) {
|
|
<a name="l397"></a> tf=</span><span class=cF5>tS</span><span class=cF0>;
|
|
<a name="l398"></a> </span><span class=cFB>music</span><span class=cF0>.mute=</span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l399"></a> </span><span class=cF5>Snd</span><span class=cF0>(86);</span><span class=cF5>Sleep</span><span class=cF0>(200);</span><span class=cF5>Snd</span><span class=cF0>;</span><span class=cF5>Sleep</span><span class=cF0>(100);
|
|
<a name="l400"></a> </span><span class=cF1>if</span><span class=cF0> (tf-t0<best_score) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l401"></a> best_score=tf-t0;
|
|
<a name="l402"></a> </span><span class=cF5>Snd</span><span class=cF0>(86);</span><span class=cF5>Sleep</span><span class=cF0>(200);</span><span class=cF5>Snd</span><span class=cF0>;</span><span class=cF5>Sleep</span><span class=cF0>(100);
|
|
<a name="l403"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l404"></a> </span><span class=cFB>music</span><span class=cF0>.mute=</span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l405"></a> }
|
|
<a name="l406"></a>
|
|
<a name="l407"></a> snow_x+=</span><span class=cF5>RandU16</span><span class=cF0>%3-1;
|
|
<a name="l408"></a> snow_y+=1-</span><span class=cF5>SignI64</span><span class=cF0>(</span><span class=cF5>RandU16</span><span class=cF0>&3);
|
|
<a name="l409"></a> </span><span class=cF1>if</span><span class=cF0> (new_snow_mS++>8) {
|
|
<a name="l410"></a> new_snow_mS=0;
|
|
<a name="l411"></a> snow_tile->color=</span><span class=cF3>WHITE</span><span class=cF0>;
|
|
<a name="l412"></a> </span><span class=cF5>GrPlot</span><span class=cF0>(snow_tile,</span><span class=cF5>RandU16</span><span class=cF0>&</span><span class=cF7>(</span><span class=cF0>SNOW_TILE_SIZE-1</span><span class=cF7>)</span><span class=cF0>,</span><span class=cF5>RandU16</span><span class=cF0>&</span><span class=cF7>(</span><span class=cF0>SNOW_TILE_SIZE-1</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l413"></a> }
|
|
<a name="l414"></a>
|
|
<a name="l415"></a> </span><span class=cF5>Sleep</span><span class=cF0>(1);
|
|
<a name="l416"></a> </span><span class=cF1>if</span><span class=cF0> (animate_mS++>=250) {
|
|
<a name="l417"></a> animate_mS=0;
|
|
<a name="l418"></a> animate_phase=(animate_phase+1)&3;
|
|
<a name="l419"></a> }
|
|
<a name="l420"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>tS</span><span class=cF0><king_timeout) {
|
|
<a name="l421"></a> </span><span class=cF1>if</span><span class=cF0> (king_mS++>=250) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l422"></a> king_mS=0;
|
|
<a name="l423"></a> king_phase|=1;
|
|
<a name="l424"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l425"></a> }
|
|
<a name="l426"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l427"></a>}
|
|
<a name="l428"></a>
|
|
<a name="l429"></a></span><span class=cF1>U0</span><span class=cF0> BurnTrees()
|
|
<a name="l430"></a>{
|
|
<a name="l431"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
|
<a name="l432"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<TREES_NUM;i++)
|
|
<a name="l433"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Sqr</span><span class=cF7>(</span><span class=cF0>king_x-trees[i].x</span><span class=cF7>)</span><span class=cF0>+</span><span class=cF5>Sqr</span><span class=cF7>(</span><span class=cF0>king_y-trees[i].y</span><span class=cF7>)</span><span class=cF0><10*10)
|
|
<a name="l434"></a> trees[i].fire_frame_idx=1;
|
|
<a name="l435"></a>}
|
|
<a name="l436"></a>
|
|
<a name="l437"></a></span><span class=cF1>U0</span><span class=cF0> SongTask(</span><span class=cF9>I64</span><span class=cF0>)
|
|
<a name="l438"></a>{
|
|
<a name="l439"></a> </span><span class=cF5>Fs</span><span class=cF0>->task_end_cb=&</span><span class=cF5>SndTaskEndCB</span><span class=cF0>;
|
|
<a name="l440"></a> </span><span class=cF5>MusicSettingsRst</span><span class=cF0>;
|
|
<a name="l441"></a> </span><span class=cFB>music</span><span class=cF0>.tempo= 2.480;
|
|
<a name="l442"></a> </span><span class=cFB>music</span><span class=cF0>.stacatto_factor= 0.902;
|
|
<a name="l443"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l444"></a> </span><span class=cF5>Play</span><span class=cF0>(</span><span class=cF6>"5eCCCDCC4qGeAGAB5qCC"</span><span class=cF0>);
|
|
<a name="l445"></a> </span><span class=cF5>Play</span><span class=cF0>(</span><span class=cF6>"5eCCCDCC4qGeAGAB5qCC"</span><span class=cF0>);
|
|
<a name="l446"></a> </span><span class=cF5>Play</span><span class=cF0>(</span><span class=cF6>"5eGFEDEDqC4eAGAB5qCC"</span><span class=cF0>);
|
|
<a name="l447"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l448"></a>}
|
|
<a name="l449"></a>
|
|
<a name="l450"></a></span><span class=cF1>U0</span><span class=cF0> Wenceslas()
|
|
<a name="l451"></a>{
|
|
<a name="l452"></a> </span><span class=cF9>I64</span><span class=cF0> sc;
|
|
<a name="l453"></a>
|
|
<a name="l454"></a> </span><span class=cF5>MenuPush</span><span class=cF0>(
|
|
<a name="l455"></a> </span><span class=cF6>"File {"</span><span class=cF0>
|
|
<a name="l456"></a> </span><span class=cF6>" Abort(,CH_SHIFT_ESC);"</span><span class=cF0>
|
|
<a name="l457"></a> </span><span class=cF6>" Exit(,CH_ESC);"</span><span class=cF0>
|
|
<a name="l458"></a> </span><span class=cF6>"}"</span><span class=cF0>
|
|
<a name="l459"></a> </span><span class=cF6>"Play {"</span><span class=cF0>
|
|
<a name="l460"></a> </span><span class=cF6>" Restart(,'\n');"</span><span class=cF0>
|
|
<a name="l461"></a> </span><span class=cF6>" BurnTree(,CH_SPACE);"</span><span class=cF0>
|
|
<a name="l462"></a> </span><span class=cF6>" Up(,,SC_CURSOR_UP);"</span><span class=cF0>
|
|
<a name="l463"></a> </span><span class=cF6>" Down(,,SC_CURSOR_DOWN);"</span><span class=cF0>
|
|
<a name="l464"></a> </span><span class=cF6>" Left(,,SC_CURSOR_LEFT);"</span><span class=cF0>
|
|
<a name="l465"></a> </span><span class=cF6>" Right(,,SC_CURSOR_RIGHT);"</span><span class=cF0>
|
|
<a name="l466"></a> </span><span class=cF6>"}"</span><span class=cF0>
|
|
<a name="l467"></a> );
|
|
<a name="l468"></a>
|
|
<a name="l469"></a> </span><span class=cF5>SettingsPush</span><span class=cF0>; </span><span class=cF2>//See </span><a href="/Wb/Adam/TaskSettings.HC.HTML#l3"><span class=cF4>SettingsPush</span></a><span class=cF0>
|
|
<a name="l470"></a> </span><span class=cF5>AutoComplete</span><span class=cF0>;
|
|
<a name="l471"></a> </span><span class=cF5>WinBorder</span><span class=cF0>;
|
|
<a name="l472"></a> </span><span class=cF5>WinMax</span><span class=cF0>;
|
|
<a name="l473"></a> </span><span class=cF5>DocCursor</span><span class=cF0>;
|
|
<a name="l474"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
|
|
<a name="l475"></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="l476"></a>
|
|
<a name="l477"></a> </span><span class=cF5>PopUpOk</span><span class=cF0>(</span><span class=cF6>"</span><span class=cF0>
|
|
<a name="l478"></a></span><span class=cF6>Good King Wenceslas looked out</span><span class=cF0>
|
|
<a name="l479"></a></span><span class=cF6>On the feast of Stephen</span><span class=cF0>
|
|
<a name="l480"></a></span><span class=cF6>When the snow lay round about</span><span class=cF0>
|
|
<a name="l481"></a></span><span class=cF6>Deep and crisp and even</span><span class=cF0>
|
|
<a name="l482"></a></span><span class=cF6>Brightly shone the moon that night</span><span class=cF0>
|
|
<a name="l483"></a></span><span class=cF6>Though the frost was cruel</span><span class=cF0>
|
|
<a name="l484"></a></span><span class=cF6>When a poor man came in sight</span><span class=cF0>
|
|
<a name="l485"></a></span><span class=cF6>Gath'ring winter fuel</span><span class=cF0>
|
|
<a name="l486"></a>
|
|
<a name="l487"></a></span><span class=cF6>\"Hither, page, and stand by me</span><span class=cF0>
|
|
<a name="l488"></a></span><span class=cF6>If thou know'st it, telling</span><span class=cF0>
|
|
<a name="l489"></a></span><span class=cF6>Yonder peasant, who is he?</span><span class=cF0>
|
|
<a name="l490"></a></span><span class=cF6>Where and what his dwelling?\"</span><span class=cF0>
|
|
<a name="l491"></a></span><span class=cF6>\"Sire, he lives a good league hence</span><span class=cF0>
|
|
<a name="l492"></a></span><span class=cF6>Underneath the mountain</span><span class=cF0>
|
|
<a name="l493"></a></span><span class=cF6>Right against the forest fence</span><span class=cF0>
|
|
<a name="l494"></a></span><span class=cF6>By Saint Agnes' fountain.\"</span><span class=cF0>
|
|
<a name="l495"></a>
|
|
<a name="l496"></a></span><span class=cF6>\"Bring me flesh and bring me wine</span><span class=cF0>
|
|
<a name="l497"></a></span><span class=cF6>Bring me pine logs hither</span><span class=cF0>
|
|
<a name="l498"></a></span><span class=cF6>Thou and I will see him dine</span><span class=cF0>
|
|
<a name="l499"></a></span><span class=cF6>When we bear him thither.\"</span><span class=cF0>
|
|
<a name="l500"></a></span><span class=cF6>Page and monarch forth they went</span><span class=cF0>
|
|
<a name="l501"></a></span><span class=cF6>Forth they went together</span><span class=cF0>
|
|
<a name="l502"></a></span><span class=cF6>Through the rude wind's wild lament</span><span class=cF0>
|
|
<a name="l503"></a></span><span class=cF6>And the bitter weather</span><span class=cF0>
|
|
<a name="l504"></a>
|
|
<a name="l505"></a></span><span class=cF6>"</span><span class=cF0>);
|
|
<a name="l506"></a> </span><span class=cF5>PopUpOk</span><span class=cF0>(</span><span class=cF6>"</span><span class=cF0>
|
|
<a name="l507"></a></span><span class=cF6>\"Sire, the night is darker now</span><span class=cF0>
|
|
<a name="l508"></a></span><span class=cF6>And the wind blows stronger</span><span class=cF0>
|
|
<a name="l509"></a></span><span class=cF6>Fails my heart, I know not how,</span><span class=cF0>
|
|
<a name="l510"></a></span><span class=cF6>I can go no longer.\"</span><span class=cF0>
|
|
<a name="l511"></a></span><span class=cF6>\"Mark my footsteps, my good page</span><span class=cF0>
|
|
<a name="l512"></a></span><span class=cF6>Tread thou in them boldly</span><span class=cF0>
|
|
<a name="l513"></a></span><span class=cF6>Thou shalt find the winter's rage</span><span class=cF0>
|
|
<a name="l514"></a></span><span class=cF6>Freeze thy blood less coldly.\"</span><span class=cF0>
|
|
<a name="l515"></a>
|
|
<a name="l516"></a></span><span class=cF6>In his master's steps he trod</span><span class=cF0>
|
|
<a name="l517"></a></span><span class=cF6>Where the snow lay dinted</span><span class=cF0>
|
|
<a name="l518"></a></span><span class=cF6>Heat was in the very sod</span><span class=cF0>
|
|
<a name="l519"></a></span><span class=cF6>Which the Saint had printed</span><span class=cF0>
|
|
<a name="l520"></a></span><span class=cF6>Therefore, Christian men, be sure</span><span class=cF0>
|
|
<a name="l521"></a></span><span class=cF6>Wealth or rank possessing</span><span class=cF0>
|
|
<a name="l522"></a></span><span class=cF6>Ye who now will bless the poor</span><span class=cF0>
|
|
<a name="l523"></a></span><span class=cF6>Shall yourselves find blessing</span><span class=cF0>
|
|
<a name="l524"></a>
|
|
<a name="l525"></a></span><span class=cF6>"</span><span class=cF0>);
|
|
<a name="l526"></a> </span><span class=cF5>PopUpOk</span><span class=cF0>(</span><span class=cF6>"</span><span class=cF0>
|
|
<a name="l527"></a></span><span class=cF6>$PURPLE$$TX+CX,\"Winceslas Game\"$$FG$</span><span class=cF0>
|
|
<a name="l528"></a>
|
|
<a name="l529"></a></span><span class=cF6>Start fires by pressing $GREEN$<SPACE>$FG$</span><span class=cF0>
|
|
<a name="l530"></a></span><span class=cF6>on trees. (Yule logs)</span><span class=cF0>
|
|
<a name="l531"></a>
|
|
<a name="l532"></a></span><span class=cF6>Lead peasants to fires.</span><span class=cF0>
|
|
<a name="l533"></a></span><span class=cF6>"</span><span class=cF0>);
|
|
<a name="l534"></a>
|
|
<a name="l535"></a> Init;
|
|
<a name="l536"></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=cF3>NULL</span><span class=cF0>,</span><span class=cF6>"Animate"</span><span class=cF0>,,</span><span class=cF5>Fs</span><span class=cF0>);
|
|
<a name="l537"></a> </span><span class=cF5>Fs</span><span class=cF0>->draw_it=&</span><span class=cF5>DrawIt</span><span class=cF0>;
|
|
<a name="l538"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l539"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) {
|
|
<a name="l540"></a> </span><span class=cF1>switch</span><span class=cF0> (</span><span class=cF5>GetKey</span><span class=cF7>(</span><span class=cF0>&sc</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l541"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\n'</span><span class=cF0>:
|
|
<a name="l542"></a> CleanUp;
|
|
<a name="l543"></a> Init;
|
|
<a name="l544"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l545"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_ESC</span><span class=cF0>:
|
|
<a name="l546"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0>:
|
|
<a name="l547"></a> </span><span class=cF1>goto</span><span class=cF0> ws_done;
|
|
<a name="l548"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SPACE</span><span class=cF0>:
|
|
<a name="l549"></a> BurnTrees;
|
|
<a name="l550"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l551"></a> </span><span class=cF1>case</span><span class=cF0> 0:
|
|
<a name="l552"></a> </span><span class=cF1>switch</span><span class=cF0> (sc.u8[0]) {
|
|
<a name="l553"></a> </span><span class=cF1>start</span><span class=cF0>:
|
|
<a name="l554"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_RIGHT</span><span class=cF0>:
|
|
<a name="l555"></a> </span><span class=cF1>if</span><span class=cF0> (king_x+KING_STEP<</span><span class=cF5>Fs</span><span class=cF0>->pix_width-BORDER)
|
|
<a name="l556"></a> king_x+=KING_STEP;
|
|
<a name="l557"></a> king_theta=0;
|
|
<a name="l558"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l559"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_LEFT</span><span class=cF0>:
|
|
<a name="l560"></a> </span><span class=cF1>if</span><span class=cF0> (king_x-KING_STEP>=BORDER)
|
|
<a name="l561"></a> king_x-=KING_STEP;
|
|
<a name="l562"></a> king_theta=</span><span class=cF3>pi</span><span class=cF0>;
|
|
<a name="l563"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l564"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_DOWN</span><span class=cF0>:
|
|
<a name="l565"></a> </span><span class=cF1>if</span><span class=cF0> (king_y+KING_STEP<</span><span class=cF5>Fs</span><span class=cF0>->pix_height-BORDER)
|
|
<a name="l566"></a> king_y+=KING_STEP;
|
|
<a name="l567"></a> king_theta=-</span><span class=cF3>pi</span><span class=cF0>/2;
|
|
<a name="l568"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l569"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_UP</span><span class=cF0>:
|
|
<a name="l570"></a> </span><span class=cF1>if</span><span class=cF0> (king_y-KING_STEP>=BORDER)
|
|
<a name="l571"></a> king_y-=KING_STEP;
|
|
<a name="l572"></a> king_theta=</span><span class=cF3>pi</span><span class=cF0>/2;
|
|
<a name="l573"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l574"></a> </span><span class=cF1>end</span><span class=cF0>:
|
|
<a name="l575"></a> king_mS=0;
|
|
<a name="l576"></a> king_phase=(king_phase+2)&2;
|
|
<a name="l577"></a> StepNew(</span><span class=cF5>Fs</span><span class=cF0>,king_x,king_y,king_theta,king_phase&2,</span><span class=cF3>TRUE</span><span class=cF0>);
|
|
<a name="l578"></a> king_timeout=</span><span class=cF5>tS</span><span class=cF0>+0.5;
|
|
<a name="l579"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l580"></a> }
|
|
<a name="l581"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l582"></a> }
|
|
<a name="l583"></a>ws_done:
|
|
<a name="l584"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>catch</span><span class=cF0>
|
|
<a name="l585"></a> </span><span class=cF5>PutExcept</span><span class=cF0>;
|
|
<a name="l586"></a> </span><span class=cF5>SettingsPop</span><span class=cF0>;
|
|
<a name="l587"></a> CleanUp;
|
|
<a name="l588"></a> </span><span class=cF5>MenuPop</span><span class=cF0>;
|
|
<a name="l589"></a> </span><span class=cF5>RegWrite</span><span class=cF0>(</span><span class=cF6>"TempleOS/Wenceslas"</span><span class=cF0>,</span><span class=cF6>"F64 best_score=%5.4f;\n"</span><span class=cF0>,best_score);
|
|
<a name="l590"></a>}
|
|
<a name="l591"></a>
|
|
<a name="l592"></a>Wenceslas;
|
|
</span></pre></body>
|
|
</html>
|