628 lines
48 KiB
HTML
Executable File
628 lines
48 KiB
HTML
Executable File
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="generator" content="TempleOS V5.03">
|
|
<meta name="viewport" content="width=device-width">
|
|
<link rel="stylesheet" href="/style/templeos.css">
|
|
<script src="/script/templeos.js"></script>
|
|
<style type="text/css">
|
|
.cF0{color:#000000;background-color:#ffffff;}
|
|
.cF1{color:#0000aa;background-color:#ffffff;}
|
|
.cF2{color:#00aa00;background-color:#ffffff;}
|
|
.cF3{color:#00aaaa;background-color:#ffffff;}
|
|
.cF4{color:#aa0000;background-color:#ffffff;}
|
|
.cF5{color:#aa00aa;background-color:#ffffff;}
|
|
.cF6{color:#aa5500;background-color:#ffffff;}
|
|
.cF7{color:#aaaaaa;background-color:#ffffff;}
|
|
.cF8{color:#555555;background-color:#ffffff;}
|
|
.cF9{color:#5555ff;background-color:#ffffff;}
|
|
.cFA{color:#55ff55;background-color:#ffffff;}
|
|
.cFB{color:#55ffff;background-color:#ffffff;}
|
|
.cFC{color:#ff5555;background-color:#ffffff;}
|
|
.cFD{color:#ff55ff;background-color:#ffffff;}
|
|
.cFE{color:#ffff55;background-color:#ffffff;}
|
|
.cFF{color:#ffffff;background-color:#ffffff;}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<pre id="content">
|
|
<a name="l1"></a><span class=cF2>//Uses </span><a href="/Wb/Demo/Lectures/FixedPoint.HC.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>RegDft</span><span class=cF0>(</span><span class=cF6>"TempleOS/CastleFrankenstein"</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>"TempleOS/CastleFrankenstein"</span><span class=cF0>);
|
|
<a name="l5"></a>
|
|
<a name="l6"></a></span><span class=cF2>//Set snap to 4 and width to 4</span><span class=cF0>
|
|
<a name="l7"></a></span><span class=cF2>//if you edit this map.</span><span class=cF0>
|
|
<a name="l8"></a>
|
|
<a name="l9"></a></span><span class=cF2>//Don't forget to change the</span><span class=cF0>
|
|
<a name="l10"></a></span><span class=cF2>//starting pos.</span><span class=cF0>
|
|
<a name="l11"></a>#</span><span class=cF1>define</span><span class=cF0> MAN_START_X 0
|
|
<a name="l12"></a>#</span><span class=cF1>define</span><span class=cF0> MAN_START_Y 4.5
|
|
<a name="l13"></a></span><span class=cFA>
|
|
<a name="l14"></a><1>/* Graphics Not Rendered in HTML */</span><span class=cF0>
|
|
<a name="l15"></a>
|
|
<a name="l16"></a>
|
|
<a name="l17"></a>
|
|
<a name="l18"></a>
|
|
<a name="l19"></a>
|
|
<a name="l20"></a>
|
|
<a name="l21"></a>
|
|
<a name="l22"></a>
|
|
<a name="l23"></a>
|
|
<a name="l24"></a>
|
|
<a name="l25"></a>
|
|
<a name="l26"></a>
|
|
<a name="l27"></a>
|
|
<a name="l28"></a>
|
|
<a name="l29"></a>#</span><span class=cF1>define</span><span class=cF0> MONSTER_SCALE 2.0
|
|
<a name="l30"></a>
|
|
<a name="l31"></a> </span><span class=cFA><2>/* Graphics Not Rendered in HTML */</span><span class=cF0>
|
|
<a name="l32"></a>
|
|
<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> </span><span class=cFA><3>/* Graphics Not Rendered in HTML */</span><span class=cF0>
|
|
<a name="l43"></a>
|
|
<a name="l44"></a>
|
|
<a name="l45"></a>
|
|
<a name="l46"></a>
|
|
<a name="l47"></a>
|
|
<a name="l48"></a>
|
|
<a name="l49"></a>
|
|
<a name="l50"></a>
|
|
<a name="l51"></a>
|
|
<a name="l52"></a> </span><span class=cFA><4>/* Graphics Not Rendered in HTML */</span><span class=cF0>
|
|
<a name="l53"></a>
|
|
<a name="l54"></a>
|
|
<a name="l55"></a>
|
|
<a name="l56"></a>
|
|
<a name="l57"></a>
|
|
<a name="l58"></a>
|
|
<a name="l59"></a>
|
|
<a name="l60"></a>#</span><span class=cF1>define</span><span class=cF0> PLANT_SCALE 2.0
|
|
<a name="l61"></a>
|
|
<a name="l62"></a>
|
|
<a name="l63"></a>
|
|
<a name="l64"></a> </span><span class=cFA><5>/* Graphics Not Rendered in HTML */</span><span class=cF0>
|
|
<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>
|
|
<a name="l77"></a>
|
|
<a name="l78"></a> </span><span class=cFA><6>/* Graphics Not Rendered in HTML */</span><span class=cF0>
|
|
<a name="l79"></a>
|
|
<a name="l80"></a>
|
|
<a name="l81"></a>
|
|
<a name="l82"></a>
|
|
<a name="l83"></a>
|
|
<a name="l84"></a>
|
|
<a name="l85"></a>
|
|
<a name="l86"></a>#</span><span class=cF1>define</span><span class=cF0> SCRN_SCALE 512
|
|
<a name="l87"></a>#</span><span class=cF1>define</span><span class=cF0> PLOT_GRID_WIDTH 24
|
|
<a name="l88"></a>#</span><span class=cF1>define</span><span class=cF0> PLOT_GRID_HEIGHT 24
|
|
<a name="l89"></a>#</span><span class=cF1>define</span><span class=cF0> MAN_HEIGHT 125
|
|
<a name="l90"></a>
|
|
<a name="l91"></a>#</span><span class=cF1>define</span><span class=cF0> MAP_SCALE 4
|
|
<a name="l92"></a></span><span class=cF9>I64</span><span class=cF0> map_width,map_height;
|
|
<a name="l93"></a></span><span class=cF1>U8</span><span class=cF0> *map=</span><span class=cF3>NULL</span><span class=cF0>,
|
|
<a name="l94"></a>*panels_processed_bitmap=</span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l95"></a>
|
|
<a name="l96"></a></span><span class=cF9>I64</span><span class=cF0> man_xx,man_yy;
|
|
<a name="l97"></a></span><span class=cF1>F64</span><span class=cF0> man_theta;
|
|
<a name="l98"></a>
|
|
<a name="l99"></a></span><span class=cF1>F64</span><span class=cF0> t0,tf;
|
|
<a name="l100"></a>
|
|
<a name="l101"></a>#</span><span class=cF1>define</span><span class=cF0> MONSTERS_NUM 10
|
|
<a name="l102"></a></span><span class=cF9>I64</span><span class=cF0> monsters_left;
|
|
<a name="l103"></a></span><span class=cF1>class</span><span class=cF0> Monster
|
|
<a name="l104"></a>{
|
|
<a name="l105"></a> </span><span class=cF9>I64</span><span class=cF0> x,y;
|
|
<a name="l106"></a> </span><span class=cF1>Bool</span><span class=cF0> dead,pad[7];
|
|
<a name="l107"></a>} monsters[MONSTERS_NUM];
|
|
<a name="l108"></a>
|
|
<a name="l109"></a></span><span class=cF1>U0</span><span class=cF0> CFTransform(</span><span class=cF9>CDC</span><span class=cF0> *dc,</span><span class=cF9>I64</span><span class=cF0> *x,</span><span class=cF9>I64</span><span class=cF0> *y,</span><span class=cF9>I64</span><span class=cF0> *z)
|
|
<a name="l110"></a>{
|
|
<a name="l111"></a> </span><span class=cF9>I64</span><span class=cF0> zz;
|
|
<a name="l112"></a> </span><span class=cF5>Mat4x4MulXYZ</span><span class=cF0>(dc->r,x,y,z);
|
|
<a name="l113"></a> zz=SCRN_SCALE/3+*z;
|
|
<a name="l114"></a> </span><span class=cF1>if</span><span class=cF0> (zz<1) zz=1;
|
|
<a name="l115"></a> *x=SCRN_SCALE/2* *x/zz;
|
|
<a name="l116"></a> *y=SCRN_SCALE/2* (*y+MAN_HEIGHT)/zz;
|
|
<a name="l117"></a> *x+=dc->x;
|
|
<a name="l118"></a> *y+=dc->y;
|
|
<a name="l119"></a> *z+=dc->z;
|
|
<a name="l120"></a>}
|
|
<a name="l121"></a>
|
|
<a name="l122"></a>#</span><span class=cF1>define</span><span class=cF0> LOS_SCALE 4
|
|
<a name="l123"></a>
|
|
<a name="l124"></a></span><span class=cF1>Bool</span><span class=cF0> LOSPlot(</span><span class=cF1>U8</span><span class=cF0> *,</span><span class=cF9>I64</span><span class=cF0> x,</span><span class=cF9>I64</span><span class=cF0> y,</span><span class=cF9>I64</span><span class=cF0>)
|
|
<a name="l125"></a>{
|
|
<a name="l126"></a> </span><span class=cF1>if</span><span class=cF0> (!map[</span><span class=cF7>(</span><span class=cF0>y/LOS_SCALE</span><span class=cF7>)</span><span class=cF0>*map_width+</span><span class=cF7>(</span><span class=cF0>x/LOS_SCALE</span><span class=cF7>)</span><span class=cF0>])
|
|
<a name="l127"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l128"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l129"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l130"></a>}
|
|
<a name="l131"></a>
|
|
<a name="l132"></a></span><span class=cF1>Bool</span><span class=cF0> LOS(</span><span class=cF9>I64</span><span class=cF0> x1,</span><span class=cF9>I64</span><span class=cF0> y1,</span><span class=cF9>I64</span><span class=cF0> x2,</span><span class=cF9>I64</span><span class=cF0> y2)
|
|
<a name="l133"></a>{</span><span class=cF2>//Line of sight</span><span class=cF0>
|
|
<a name="l134"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>Line</span><span class=cF0>(</span><span class=cF3>NULL</span><span class=cF0>,x1*LOS_SCALE/SCRN_SCALE,y1*LOS_SCALE/SCRN_SCALE,0,
|
|
<a name="l135"></a> x2*LOS_SCALE/SCRN_SCALE,y2*LOS_SCALE/SCRN_SCALE,0,&LOSPlot);
|
|
<a name="l136"></a>}
|
|
<a name="l137"></a>
|
|
<a name="l138"></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="l139"></a>{
|
|
<a name="l140"></a> </span><span class=cF9>I64</span><span class=cF0> i,j,*r1,*r2,*r3,*s2w,xx,yy,zz,x,y,x1,y1,z1,
|
|
<a name="l141"></a> c,x1w,y1w,x1h,y1h,xh,yh,zh,
|
|
<a name="l142"></a> cx=task->pix_width/2,
|
|
<a name="l143"></a> cy=task->pix_height/2;
|
|
<a name="l144"></a> </span><span class=cF1>U8</span><span class=cF0> *tmps;
|
|
<a name="l145"></a> </span><span class=cF1>F64</span><span class=cF0> tt;
|
|
<a name="l146"></a> </span><span class=cF9>CD3I32</span><span class=cF0> poly[4];
|
|
<a name="l147"></a> Monster *tmpm;
|
|
<a name="l148"></a>
|
|
<a name="l149"></a> </span><span class=cF5>DCDepthBufAlloc</span><span class=cF0>(dc);
|
|
<a name="l150"></a> </span><span class=cF5>MemSet</span><span class=cF0>(panels_processed_bitmap,0,</span><span class=cF7>(</span><span class=cF0>map_width*map_height+7</span><span class=cF7>)</span><span class=cF0>>>3);
|
|
<a name="l151"></a>
|
|
<a name="l152"></a> </span><span class=cF2>//World to scrn</span><span class=cF0>
|
|
<a name="l153"></a> </span><span class=cF5>Mat4x4RotZ</span><span class=cF0>(dc->r,man_theta+</span><span class=cF3>pi</span><span class=cF0>/2);
|
|
<a name="l154"></a> </span><span class=cF5>Mat4x4RotX</span><span class=cF0>(dc->r,</span><span class=cF3>pi</span><span class=cF0>/2);
|
|
<a name="l155"></a> </span><span class=cF5>DCMat4x4Set</span><span class=cF0>(dc,dc->r);
|
|
<a name="l156"></a>
|
|
<a name="l157"></a> xh=-man_xx/SCRN_SCALE; yh=-man_yy/SCRN_SCALE; zh=0;
|
|
<a name="l158"></a> </span><span class=cF5>Mat4x4MulXYZ</span><span class=cF0>(dc->r,&xh,&yh,&zh);
|
|
<a name="l159"></a> </span><span class=cF5>Mat4x4TranslationEqu</span><span class=cF0>(dc->r,xh,yh,zh);
|
|
<a name="l160"></a>
|
|
<a name="l161"></a> </span><span class=cF2>//Scrn to world</span><span class=cF0>
|
|
<a name="l162"></a> s2w=</span><span class=cF5>Mat4x4IdentNew</span><span class=cF0>(task);
|
|
<a name="l163"></a> </span><span class=cF5>Mat4x4RotX</span><span class=cF0>(s2w,-</span><span class=cF3>pi</span><span class=cF0>/2);
|
|
<a name="l164"></a> </span><span class=cF5>Mat4x4RotZ</span><span class=cF0>(s2w,-man_theta-</span><span class=cF3>pi</span><span class=cF0>/2);
|
|
<a name="l165"></a> xh=0; yh=0; zh=SCRN_SCALE;
|
|
<a name="l166"></a> </span><span class=cF5>Mat4x4MulXYZ</span><span class=cF0>(s2w,&xh,&yh,&zh);
|
|
<a name="l167"></a>
|
|
<a name="l168"></a> </span><span class=cF2>//Rotate light source</span><span class=cF0>
|
|
<a name="l169"></a> xx=dc->ls.x; yy=dc->ls.y; zz=-dc->ls.z;
|
|
<a name="l170"></a> (*dc->transform)(dc,&xx,&yy,&zz);
|
|
<a name="l171"></a> dc->ls.x=xx; dc->ls.y=yy; dc->ls.z=zz;
|
|
<a name="l172"></a>
|
|
<a name="l173"></a> dc->flags|=</span><span class=cF3>DCF_TRANSFORMATION</span><span class=cF0>;
|
|
<a name="l174"></a> dc->transform=&CFTransform;
|
|
<a name="l175"></a> dc->x=cx;
|
|
<a name="l176"></a> dc->y=cy;
|
|
<a name="l177"></a> r1=</span><span class=cF5>Mat4x4IdentNew</span><span class=cF0>(task);
|
|
<a name="l178"></a> </span><span class=cF5>Mat4x4RotX</span><span class=cF0>(r1,-</span><span class=cF3>pi</span><span class=cF0>/2);
|
|
<a name="l179"></a> </span><span class=cF5>Mat4x4RotZ</span><span class=cF0>(r1,</span><span class=cF5>tS</span><span class=cF0>);
|
|
<a name="l180"></a> </span><span class=cF5>Mat4x4Scale</span><span class=cF0>(r1,MONSTER_SCALE);
|
|
<a name="l181"></a>
|
|
<a name="l182"></a> r2=</span><span class=cF5>Mat4x4IdentNew</span><span class=cF0>(task);
|
|
<a name="l183"></a> </span><span class=cF5>Mat4x4Scale</span><span class=cF0>(r2,MONSTER_SCALE);
|
|
<a name="l184"></a>
|
|
<a name="l185"></a> r3=</span><span class=cF5>Mat4x4IdentNew</span><span class=cF0>(task);
|
|
<a name="l186"></a> </span><span class=cF5>Mat4x4RotX</span><span class=cF0>(r3,-</span><span class=cF3>pi</span><span class=cF0>/2);
|
|
<a name="l187"></a> </span><span class=cF5>Mat4x4Scale</span><span class=cF0>(r3,PLANT_SCALE);
|
|
<a name="l188"></a>
|
|
<a name="l189"></a> </span><span class=cF5>Seed</span><span class=cF0>(1);
|
|
<a name="l190"></a> x1h=man_xx+yh*PLOT_GRID_WIDTH/2+xh*(PLOT_GRID_HEIGHT-1);
|
|
<a name="l191"></a> y1h=man_yy-xh*PLOT_GRID_WIDTH/2+yh*(PLOT_GRID_HEIGHT-1);
|
|
<a name="l192"></a> xh>>=1; yh>>=1;
|
|
<a name="l193"></a> </span><span class=cF1>for</span><span class=cF0> (j=0;j<PLOT_GRID_HEIGHT*2;j++) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l194"></a> x1w=x1h;
|
|
<a name="l195"></a> y1w=y1h;
|
|
<a name="l196"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<PLOT_GRID_WIDTH*4;i++) {
|
|
<a name="l197"></a> xx=x1w/SCRN_SCALE; yy=y1w/SCRN_SCALE;
|
|
<a name="l198"></a> x=xx*SCRN_SCALE-man_xx; y=yy*SCRN_SCALE-man_yy;
|
|
<a name="l199"></a> </span><span class=cF1>if</span><span class=cF0> (1<=xx<map_width-1 && 1<=yy<map_height-1 &&
|
|
<a name="l200"></a> !</span><span class=cF5>LBts</span><span class=cF7>(</span><span class=cF0>panels_processed_bitmap,yy*map_width+xx</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l201"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>c=map[yy*map_width+xx]</span><span class=cF7>)</span><span class=cF0> &&
|
|
<a name="l202"></a> LOS</span><span class=cF7>(</span><span class=cF0>xx*SCRN_SCALE+SCRN_SCALE/2,yy*SCRN_SCALE+SCRN_SCALE/2,
|
|
<a name="l203"></a> man_xx,man_yy</span><span class=cF7>)</span><span class=cF0>) {
|
|
<a name="l204"></a> </span><span class=cF1>if</span><span class=cF0> (c==</span><span class=cF3>YELLOW</span><span class=cF0>)
|
|
<a name="l205"></a> dc->color=</span><span class=cF3>DKGRAY</span><span class=cF0>;
|
|
<a name="l206"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l207"></a> dc->color=c;
|
|
<a name="l208"></a> poly[0].x=x;
|
|
<a name="l209"></a> poly[0].y=y;
|
|
<a name="l210"></a> poly[0].z=0;
|
|
<a name="l211"></a> poly[1].x=x+SCRN_SCALE;
|
|
<a name="l212"></a> poly[1].y=y;
|
|
<a name="l213"></a> poly[1].z=0;
|
|
<a name="l214"></a> poly[2].x=x+SCRN_SCALE;
|
|
<a name="l215"></a> poly[2].y=y+SCRN_SCALE;
|
|
<a name="l216"></a> poly[2].z=0;
|
|
<a name="l217"></a> poly[3].x=x;
|
|
<a name="l218"></a> poly[3].y=y+SCRN_SCALE;
|
|
<a name="l219"></a> poly[3].z=0;
|
|
<a name="l220"></a> </span><span class=cF5>GrFillPoly3</span><span class=cF0>(dc,4,poly);
|
|
<a name="l221"></a> </span><span class=cF1>if</span><span class=cF0> (c==</span><span class=cF3>GREEN</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l222"></a> x1=x+SCRN_SCALE/2;
|
|
<a name="l223"></a> y1=y+SCRN_SCALE/2;
|
|
<a name="l224"></a> z1=0;
|
|
<a name="l225"></a> </span><span class=cF5>DCTransform</span><span class=cF0>(dc,&x1,&y1,&z1);
|
|
<a name="l226"></a> </span><span class=cF1>if</span><span class=cF0> (z1>0)
|
|
<a name="l227"></a> </span><span class=cF5>Sprite3Mat4x4B</span><span class=cF0>(dc,x+SCRN_SCALE/2,y+SCRN_SCALE/2,0,</span><span class=cFA><5></span><span class=cF0>,r3);
|
|
<a name="l228"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (c==</span><span class=cF3>YELLOW</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l229"></a> x1=x+SCRN_SCALE/2;
|
|
<a name="l230"></a> y1=y+SCRN_SCALE/2;
|
|
<a name="l231"></a> z1=0;
|
|
<a name="l232"></a> </span><span class=cF5>DCTransform</span><span class=cF0>(dc,&x1,&y1,&z1);
|
|
<a name="l233"></a> </span><span class=cF1>if</span><span class=cF0> (z1>0)
|
|
<a name="l234"></a> </span><span class=cF5>Sprite3Mat4x4B</span><span class=cF0>(dc,x+SCRN_SCALE/2,y+SCRN_SCALE/2,0,</span><span class=cFA><6></span><span class=cF0>,r3);
|
|
<a name="l235"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l236"></a>
|
|
<a name="l237"></a> </span><span class=cF1>if</span><span class=cF0> (!map[</span><span class=cF7>(</span><span class=cF0>yy+1</span><span class=cF7>)</span><span class=cF0>*map_width+xx]) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l238"></a> dc->color=</span><span class=cF3>LTGRAY</span><span class=cF0>;
|
|
<a name="l239"></a> poly[0].x=x;
|
|
<a name="l240"></a> poly[0].y=y+SCRN_SCALE;
|
|
<a name="l241"></a> poly[0].z=0;
|
|
<a name="l242"></a> poly[1].x=x+SCRN_SCALE;
|
|
<a name="l243"></a> poly[1].y=y+SCRN_SCALE;
|
|
<a name="l244"></a> poly[1].z=0;
|
|
<a name="l245"></a> poly[2].x=x+SCRN_SCALE;
|
|
<a name="l246"></a> poly[2].y=y+SCRN_SCALE;
|
|
<a name="l247"></a> poly[2].z=SCRN_SCALE;
|
|
<a name="l248"></a> poly[3].x=x;
|
|
<a name="l249"></a> poly[3].y=y+SCRN_SCALE;
|
|
<a name="l250"></a> poly[3].z=SCRN_SCALE;
|
|
<a name="l251"></a> </span><span class=cF5>GrFillPoly3</span><span class=cF0>(dc,4,poly);
|
|
<a name="l252"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l253"></a> </span><span class=cF1>if</span><span class=cF0> (!map[yy*map_width+xx+1]) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l254"></a> dc->color=</span><span class=cF3>WHITE</span><span class=cF0>;
|
|
<a name="l255"></a> poly[0].x=x+SCRN_SCALE;
|
|
<a name="l256"></a> poly[0].y=y;
|
|
<a name="l257"></a> poly[0].z=0;
|
|
<a name="l258"></a> poly[1].x=x+SCRN_SCALE;
|
|
<a name="l259"></a> poly[1].y=y+SCRN_SCALE;
|
|
<a name="l260"></a> poly[1].z=0;
|
|
<a name="l261"></a> poly[2].x=x+SCRN_SCALE;
|
|
<a name="l262"></a> poly[2].y=y+SCRN_SCALE;
|
|
<a name="l263"></a> poly[2].z=SCRN_SCALE;
|
|
<a name="l264"></a> poly[3].x=x+SCRN_SCALE;
|
|
<a name="l265"></a> poly[3].y=y;
|
|
<a name="l266"></a> poly[3].z=SCRN_SCALE;
|
|
<a name="l267"></a> </span><span class=cF5>GrFillPoly3</span><span class=cF0>(dc,4,poly);
|
|
<a name="l268"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l269"></a> </span><span class=cF1>if</span><span class=cF0> (!map[</span><span class=cF7>(</span><span class=cF0>yy-1</span><span class=cF7>)</span><span class=cF0>*map_width+xx]) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l270"></a> dc->color=</span><span class=cF3>LTGRAY</span><span class=cF0>;
|
|
<a name="l271"></a> poly[0].x=x;
|
|
<a name="l272"></a> poly[0].y=y;
|
|
<a name="l273"></a> poly[0].z=0;
|
|
<a name="l274"></a> poly[1].x=x+SCRN_SCALE;
|
|
<a name="l275"></a> poly[1].y=y;
|
|
<a name="l276"></a> poly[1].z=0;
|
|
<a name="l277"></a> poly[2].x=x+SCRN_SCALE;
|
|
<a name="l278"></a> poly[2].y=y;
|
|
<a name="l279"></a> poly[2].z=SCRN_SCALE;
|
|
<a name="l280"></a> poly[3].x=x;
|
|
<a name="l281"></a> poly[3].y=y;
|
|
<a name="l282"></a> poly[3].z=SCRN_SCALE;
|
|
<a name="l283"></a> </span><span class=cF5>GrFillPoly3</span><span class=cF0>(dc,4,poly);
|
|
<a name="l284"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l285"></a> </span><span class=cF1>if</span><span class=cF0> (!map[yy*map_width+xx-1]) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l286"></a> dc->color=</span><span class=cF3>WHITE</span><span class=cF0>;
|
|
<a name="l287"></a> poly[0].x=x;
|
|
<a name="l288"></a> poly[0].y=y;
|
|
<a name="l289"></a> poly[0].z=0;
|
|
<a name="l290"></a> poly[1].x=x;
|
|
<a name="l291"></a> poly[1].y=y+SCRN_SCALE;
|
|
<a name="l292"></a> poly[1].z=0;
|
|
<a name="l293"></a> poly[2].x=x;
|
|
<a name="l294"></a> poly[2].y=y+SCRN_SCALE;
|
|
<a name="l295"></a> poly[2].z=SCRN_SCALE;
|
|
<a name="l296"></a> poly[3].x=x;
|
|
<a name="l297"></a> poly[3].y=y;
|
|
<a name="l298"></a> poly[3].z=SCRN_SCALE;
|
|
<a name="l299"></a> </span><span class=cF5>GrFillPoly3</span><span class=cF0>(dc,4,poly);
|
|
<a name="l300"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l301"></a> }
|
|
<a name="l302"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l303"></a> x1w-=yh;
|
|
<a name="l304"></a> y1w+=xh;
|
|
<a name="l305"></a> }
|
|
<a name="l306"></a> x1h-=xh;
|
|
<a name="l307"></a> y1h-=yh;
|
|
<a name="l308"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l309"></a>
|
|
<a name="l310"></a> </span><span class=cF2>//Draw Monsters</span><span class=cF0>
|
|
<a name="l311"></a> </span><span class=cF1>for</span><span class=cF0> (i=0,tmpm=monsters;i<MONSTERS_NUM;i++,tmpm++) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l312"></a> x=tmpm->x;
|
|
<a name="l313"></a> y=tmpm->y;
|
|
<a name="l314"></a> </span><span class=cF1>if</span><span class=cF0> (LOS</span><span class=cF7>(</span><span class=cF0>x,y,man_xx,man_yy</span><span class=cF7>)</span><span class=cF0>) {
|
|
<a name="l315"></a> x-=man_xx;
|
|
<a name="l316"></a> y-=man_yy;
|
|
<a name="l317"></a> xx=x;
|
|
<a name="l318"></a> yy=y;
|
|
<a name="l319"></a> zz=0;
|
|
<a name="l320"></a> </span><span class=cF5>DCTransform</span><span class=cF0>(dc,&xx,&yy,&zz);
|
|
<a name="l321"></a> </span><span class=cF1>if</span><span class=cF0> (zz>0) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l322"></a> </span><span class=cF1>if</span><span class=cF0> (tmpm->dead)
|
|
<a name="l323"></a> </span><span class=cF5>Sprite3Mat4x4B</span><span class=cF0>(dc,x,y,0,</span><span class=cFA><2></span><span class=cF0>,r2);
|
|
<a name="l324"></a> </span><span class=cF1>else</span><span class=cF0> {
|
|
<a name="l325"></a> tt=</span><span class=cF5>Tri</span><span class=cF0>(</span><span class=cF5>tS</span><span class=cF0>,1.0);
|
|
<a name="l326"></a> tmps=</span><span class=cF5>SpriteInterpolate</span><span class=cF0>(tt,</span><span class=cFA><3></span><span class=cF0>,</span><span class=cFA><4></span><span class=cF0>);
|
|
<a name="l327"></a> </span><span class=cF5>Sprite3Mat4x4B</span><span class=cF0>(dc,x,y,0,tmps,r1);
|
|
<a name="l328"></a> </span><span class=cF5>Free</span><span class=cF0>(tmps);
|
|
<a name="l329"></a> }
|
|
<a name="l330"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l331"></a> }
|
|
<a name="l332"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l333"></a> </span><span class=cF5>Free</span><span class=cF0>(r1);
|
|
<a name="l334"></a> </span><span class=cF5>Free</span><span class=cF0>(r2);
|
|
<a name="l335"></a> </span><span class=cF5>Free</span><span class=cF0>(r3);
|
|
<a name="l336"></a>
|
|
<a name="l337"></a> </span><span class=cF2>//Draw Map heads-up display, scaled 2 pixs</span><span class=cF0>
|
|
<a name="l338"></a> </span><span class=cF5>Free</span><span class=cF0>(dc->r);
|
|
<a name="l339"></a> </span><span class=cF5>DCMat4x4Set</span><span class=cF0>(dc,</span><span class=cF5>Mat4x4IdentNew</span><span class=cF7>(</span><span class=cF0>task</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l340"></a> dc->x=task->pix_width -2*map_width;
|
|
<a name="l341"></a> dc->y=task->pix_height-2*map_height;
|
|
<a name="l342"></a> dc->z=0;
|
|
<a name="l343"></a> dc->transform=&</span><span class=cF5>DCTransform</span><span class=cF0>;
|
|
<a name="l344"></a> dc->thick=2;
|
|
<a name="l345"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<map_height;i++)
|
|
<a name="l346"></a> </span><span class=cF1>for</span><span class=cF0> (j=0;j<map_width;j++) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l347"></a> dc->color=map[(map_height-1-i)*map_width+j];
|
|
<a name="l348"></a> </span><span class=cF5>GrPlot3</span><span class=cF0>(dc,2*j,2*i,0);
|
|
<a name="l349"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l350"></a>
|
|
<a name="l351"></a> </span><span class=cF2>//Draw Things on heads-up Map</span><span class=cF0>
|
|
<a name="l352"></a> dc->color=</span><span class=cF3>LTPURPLE</span><span class=cF0>;
|
|
<a name="l353"></a> </span><span class=cF1>for</span><span class=cF0> (i=0,tmpm=monsters;i<MONSTERS_NUM;i++,tmpm++)
|
|
<a name="l354"></a> </span><span class=cF1>if</span><span class=cF0> (!tmpm->dead)
|
|
<a name="l355"></a> </span><span class=cF5>GrPlot3</span><span class=cF0>(dc,2*</span><span class=cF7>(</span><span class=cF0>tmpm->x/SCRN_SCALE</span><span class=cF7>)</span><span class=cF0>,
|
|
<a name="l356"></a> 2*</span><span class=cF7>(</span><span class=cF0>map_height-1-tmpm->y/SCRN_SCALE</span><span class=cF7>)</span><span class=cF0>,0);
|
|
<a name="l357"></a> dc->color=</span><span class=cF3>LTCYAN</span><span class=cF0>;
|
|
<a name="l358"></a> </span><span class=cF5>GrPlot3</span><span class=cF0>(dc,2*</span><span class=cF7>(</span><span class=cF0>man_xx/SCRN_SCALE</span><span class=cF7>)</span><span class=cF0>,2*</span><span class=cF7>(</span><span class=cF0>map_height-1-man_yy/SCRN_SCALE</span><span class=cF7>)</span><span class=cF0>,0);
|
|
<a name="l359"></a>
|
|
<a name="l360"></a> </span><span class=cF1>if</span><span class=cF0> (tf) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l361"></a> dc->color=</span><span class=cF3>LTRED</span><span class=cF0>;
|
|
<a name="l362"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Blink</span><span class=cF0>)
|
|
<a name="l363"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc,cx-</span><span class=cF7>(</span><span class=cF3>FONT_WIDTH</span><span class=cF0>*14</span><span class=cF7>)</span><span class=cF0>/2,cy-</span><span class=cF3>FONT_HEIGHT</span><span class=cF0>/2,</span><span class=cF6>"Game Completed"</span><span class=cF0>);
|
|
<a name="l364"></a> tt=tf;
|
|
<a name="l365"></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="l366"></a> dc->color=</span><span class=cF3>LTGREEN</span><span class=cF0>;
|
|
<a name="l367"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc,cx-5,cy,cx+5,cy);
|
|
<a name="l368"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc,cx,cy-5,cx,cy+5);
|
|
<a name="l369"></a> tt=</span><span class=cF5>tS</span><span class=cF0>;
|
|
<a name="l370"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l371"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc,0,0,</span><span class=cF6>"Enemy:%d Time:%3.2f Best:%3.2f"</span><span class=cF0>,
|
|
<a name="l372"></a> monsters_left,tt-t0,best_score);
|
|
<a name="l373"></a> </span><span class=cF5>Free</span><span class=cF0>(s2w);
|
|
<a name="l374"></a> </span><span class=cF5>Seed</span><span class=cF0>(0);
|
|
<a name="l375"></a>}
|
|
<a name="l376"></a>
|
|
<a name="l377"></a></span><span class=cF1>U0</span><span class=cF0> Fire()
|
|
<a name="l378"></a>{
|
|
<a name="l379"></a> </span><span class=cF9>I64</span><span class=cF0> i,x,y;
|
|
<a name="l380"></a> </span><span class=cF1>F64</span><span class=cF0> d,dx,dy,xx=</span><span class=cF5>Cos</span><span class=cF0>(man_theta),yy=</span><span class=cF5>Sin</span><span class=cF0>(man_theta);
|
|
<a name="l381"></a> Monster *tmpm;
|
|
<a name="l382"></a>
|
|
<a name="l383"></a> </span><span class=cF5>Noise</span><span class=cF0>(100,53,74);
|
|
<a name="l384"></a> </span><span class=cF1>for</span><span class=cF0> (i=0,tmpm=monsters;i<MONSTERS_NUM;i++,tmpm++) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l385"></a> x=tmpm->x;
|
|
<a name="l386"></a> y=tmpm->y;
|
|
<a name="l387"></a> </span><span class=cF1>if</span><span class=cF0> (!tmpm->dead &&
|
|
<a name="l388"></a> LOS</span><span class=cF7>(</span><span class=cF0>x,y,man_xx,man_yy</span><span class=cF7>)</span><span class=cF0>) {
|
|
<a name="l389"></a> dx=x-man_xx;
|
|
<a name="l390"></a> dy=man_yy-y;
|
|
<a name="l391"></a> </span><span class=cF1>if</span><span class=cF0> (d=</span><span class=cF5>Sqrt</span><span class=cF7>(</span><span class=cF0>dx*dx+dy*dy</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l392"></a> dx/=d;
|
|
<a name="l393"></a> dy/=d;
|
|
<a name="l394"></a> </span><span class=cF1>if</span><span class=cF0> (dx*xx+dy*yy>0.995) {
|
|
<a name="l395"></a> tmpm->dead=</span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l396"></a> </span><span class=cF1>if</span><span class=cF0> (!--monsters_left) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l397"></a> tf=</span><span class=cF5>tS</span><span class=cF0>;
|
|
<a name="l398"></a> </span><span class=cF1>if</span><span class=cF0> (tf-t0<best_score)
|
|
<a name="l399"></a> best_score=tf-t0;
|
|
<a name="l400"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l401"></a> }
|
|
<a name="l402"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l403"></a> }
|
|
<a name="l404"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l405"></a>}
|
|
<a name="l406"></a>
|
|
<a name="l407"></a></span><span class=cF1>U0</span><span class=cF0> Init()
|
|
<a name="l408"></a>{
|
|
<a name="l409"></a> </span><span class=cF9>I64</span><span class=cF0> i,x,y;
|
|
<a name="l410"></a> </span><span class=cF9>CDC</span><span class=cF0> *dc;
|
|
<a name="l411"></a> Monster *tmpm;
|
|
<a name="l412"></a>
|
|
<a name="l413"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
|
|
<a name="l414"></a> </span><span class=cF6>"$BG,BLACK$%h*c"</span><span class=cF0>,</span><span class=cF3>TEXT_ROWS</span><span class=cF0>/2,</span><span class=cF6>'\n'</span><span class=cF0>;
|
|
<a name="l415"></a>
|
|
<a name="l416"></a> dc=</span><span class=cF5>Sprite2DC</span><span class=cF0>(</span><span class=cFA><1></span><span class=cF0>);
|
|
<a name="l417"></a> map_width =dc->width/MAP_SCALE+2;
|
|
<a name="l418"></a> map_height=dc->height/MAP_SCALE+2;
|
|
<a name="l419"></a> </span><span class=cF5>Free</span><span class=cF0>(map);
|
|
<a name="l420"></a> </span><span class=cF5>Free</span><span class=cF0>(panels_processed_bitmap);
|
|
<a name="l421"></a> map=</span><span class=cF5>CAlloc</span><span class=cF0>(map_width*map_height*</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF1>U8</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l422"></a> panels_processed_bitmap=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF7>(</span><span class=cF0>map_width*map_height+7</span><span class=cF7>)</span><span class=cF0>>>3);
|
|
<a name="l423"></a> </span><span class=cF1>for</span><span class=cF0> (y=0;y<map_height-2;y++)
|
|
<a name="l424"></a> </span><span class=cF1>for</span><span class=cF0> (x=0;x<map_width-2;x++)
|
|
<a name="l425"></a> map[(map_height-2-y)*map_width+x+1]=</span><span class=cF5>GrPeek</span><span class=cF0>(dc,x*MAP_SCALE,y*MAP_SCALE);
|
|
<a name="l426"></a> </span><span class=cF5>DCDel</span><span class=cF0>(dc);
|
|
<a name="l427"></a> man_xx=(1+MAN_START_X)*SCRN_SCALE;
|
|
<a name="l428"></a> man_yy=(map_height-1-MAN_START_Y)*SCRN_SCALE;
|
|
<a name="l429"></a> man_theta=0;
|
|
<a name="l430"></a>
|
|
<a name="l431"></a> </span><span class=cF1>for</span><span class=cF0> (i=0,tmpm=monsters;i<MONSTERS_NUM;i++,tmpm++) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l432"></a> tmpm->dead=</span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l433"></a> </span><span class=cF1>do</span><span class=cF0> {
|
|
<a name="l434"></a> tmpm->x=</span><span class=cF5>RandU64</span><span class=cF0>%(</span><span class=cF7>(</span><span class=cF0>map_width-2</span><span class=cF7>)</span><span class=cF0>*SCRN_SCALE)+SCRN_SCALE;
|
|
<a name="l435"></a> tmpm->y=</span><span class=cF5>RandU64</span><span class=cF0>%(</span><span class=cF7>(</span><span class=cF0>map_height-2</span><span class=cF7>)</span><span class=cF0>*SCRN_SCALE)+SCRN_SCALE;
|
|
<a name="l436"></a> } </span><span class=cF1>while</span><span class=cF0> (!map[</span><span class=cF7>(</span><span class=cF0>tmpm->y/SCRN_SCALE</span><span class=cF7>)</span><span class=cF0>*map_width+tmpm->x/SCRN_SCALE]);
|
|
<a name="l437"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l438"></a> monsters_left=MONSTERS_NUM;
|
|
<a name="l439"></a> tf=0;
|
|
<a name="l440"></a> t0=</span><span class=cF5>tS</span><span class=cF0>;
|
|
<a name="l441"></a>}
|
|
<a name="l442"></a>
|
|
<a name="l443"></a></span><span class=cF1>U0</span><span class=cF0> AnimateTask(</span><span class=cF9>I64</span><span class=cF0>)
|
|
<a name="l444"></a>{
|
|
<a name="l445"></a> </span><span class=cF9>I64</span><span class=cF0> i,x,y,dd;
|
|
<a name="l446"></a> Monster *tmpm;
|
|
<a name="l447"></a>
|
|
<a name="l448"></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="l449"></a> dd=0.25*SCRN_SCALE*</span><span class=cF5>Sin</span><span class=cF0>(</span><span class=cF5>tS</span><span class=cF0>/2);
|
|
<a name="l450"></a> </span><span class=cF1>for</span><span class=cF0> (i=0,tmpm=monsters;i<MONSTERS_NUM;i++,tmpm++)
|
|
<a name="l451"></a> </span><span class=cF1>if</span><span class=cF0> (!tmpm->dead) {
|
|
<a name="l452"></a> x=tmpm->x;
|
|
<a name="l453"></a> y=tmpm->y;
|
|
<a name="l454"></a> </span><span class=cF1>if</span><span class=cF0> (i&1)
|
|
<a name="l455"></a> x+=dd;
|
|
<a name="l456"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l457"></a> y+=dd;
|
|
<a name="l458"></a> </span><span class=cF1>if</span><span class=cF0> (0<=x<=map_width*SCRN_SCALE &&
|
|
<a name="l459"></a> 0<=y<=map_height*SCRN_SCALE &&
|
|
<a name="l460"></a> map[</span><span class=cF7>(</span><span class=cF0>y/SCRN_SCALE</span><span class=cF7>)</span><span class=cF0>*map_width+x/SCRN_SCALE]) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l461"></a> </span><span class=cF1>if</span><span class=cF0> (!map[</span><span class=cF7>(</span><span class=cF0>y/SCRN_SCALE</span><span class=cF7>)</span><span class=cF0>*map_width+x/SCRN_SCALE+1] &&
|
|
<a name="l462"></a> x-</span><span class=cF5>RoundI64</span><span class=cF7>(</span><span class=cF0>x,SCRN_SCALE</span><span class=cF7>)</span><span class=cF0>>SCRN_SCALE/2 ||
|
|
<a name="l463"></a> !map[</span><span class=cF7>(</span><span class=cF0>y/SCRN_SCALE</span><span class=cF7>)</span><span class=cF0>*map_width+x/SCRN_SCALE-1] &&
|
|
<a name="l464"></a> x-</span><span class=cF5>RoundI64</span><span class=cF7>(</span><span class=cF0>x,SCRN_SCALE</span><span class=cF7>)</span><span class=cF0><SCRN_SCALE/2)
|
|
<a name="l465"></a> x=</span><span class=cF5>RoundI64</span><span class=cF0>(x,SCRN_SCALE)+SCRN_SCALE/2;
|
|
<a name="l466"></a> </span><span class=cF1>if</span><span class=cF0> (!map[</span><span class=cF7>(</span><span class=cF0>y/SCRN_SCALE+1</span><span class=cF7>)</span><span class=cF0>*map_width+x/SCRN_SCALE] &&
|
|
<a name="l467"></a> y-</span><span class=cF5>RoundI64</span><span class=cF7>(</span><span class=cF0>y,SCRN_SCALE</span><span class=cF7>)</span><span class=cF0>>SCRN_SCALE/2 ||
|
|
<a name="l468"></a> !map[</span><span class=cF7>(</span><span class=cF0>y/SCRN_SCALE-1</span><span class=cF7>)</span><span class=cF0>*map_width+x/SCRN_SCALE] &&
|
|
<a name="l469"></a> y-</span><span class=cF5>RoundI64</span><span class=cF7>(</span><span class=cF0>y,SCRN_SCALE</span><span class=cF7>)</span><span class=cF0><SCRN_SCALE/2)
|
|
<a name="l470"></a> y=</span><span class=cF5>RoundI64</span><span class=cF0>(y,SCRN_SCALE)+SCRN_SCALE/2;
|
|
<a name="l471"></a> tmpm->x=x;
|
|
<a name="l472"></a> tmpm->y=y;
|
|
<a name="l473"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l474"></a> }
|
|
<a name="l475"></a> </span><span class=cF5>Sleep</span><span class=cF0>(20);
|
|
<a name="l476"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l477"></a>}
|
|
<a name="l478"></a>
|
|
<a name="l479"></a></span><span class=cF1>U0</span><span class=cF0> CleanUp()
|
|
<a name="l480"></a>{
|
|
<a name="l481"></a> </span><span class=cF5>Free</span><span class=cF0>(map);
|
|
<a name="l482"></a> </span><span class=cF5>Free</span><span class=cF0>(panels_processed_bitmap);
|
|
<a name="l483"></a> map=</span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l484"></a> panels_processed_bitmap=</span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l485"></a>}
|
|
<a name="l486"></a>
|
|
<a name="l487"></a></span><span class=cF1>U0</span><span class=cF0> SongTask(</span><span class=cF9>I64</span><span class=cF0>)
|
|
<a name="l488"></a>{</span><span class=cF2>//Song by Terry A. Davis</span><span class=cF0>
|
|
<a name="l489"></a> </span><span class=cF5>Fs</span><span class=cF0>->task_end_cb=&</span><span class=cF5>SndTaskEndCB</span><span class=cF0>;
|
|
<a name="l490"></a> </span><span class=cF5>MusicSettingsRst</span><span class=cF0>;
|
|
<a name="l491"></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="l492"></a> </span><span class=cF5>Play</span><span class=cF0>(</span><span class=cF6>"3q.A#eGAeA#qAq.A#eGeAeA#qA"</span><span class=cF0>);
|
|
<a name="l493"></a> </span><span class=cF5>Play</span><span class=cF0>(</span><span class=cF6>"3q.A#eGA#AqGq.A#eGA#AqG"</span><span class=cF0>);
|
|
<a name="l494"></a> </span><span class=cF5>Play</span><span class=cF0>(</span><span class=cF6>"4eA#AqGeA#AqGeA#AGAA#AqG"</span><span class=cF0>);
|
|
<a name="l495"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l496"></a>}
|
|
<a name="l497"></a>
|
|
<a name="l498"></a></span><span class=cF1>U0</span><span class=cF0> MoveMan(</span><span class=cF1>F64</span><span class=cF0> theta)
|
|
<a name="l499"></a>{
|
|
<a name="l500"></a> </span><span class=cF9>I64</span><span class=cF0> x,y,color,step=SCRN_SCALE/2;
|
|
<a name="l501"></a> </span><span class=cF1>do</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l502"></a> x=man_xx+step*</span><span class=cF5>Cos</span><span class=cF0>(theta);
|
|
<a name="l503"></a> y=man_yy-step*</span><span class=cF5>Sin</span><span class=cF0>(theta);
|
|
<a name="l504"></a> x=</span><span class=cF5>Clamp</span><span class=cF0>(x,0,map_width*SCRN_SCALE);
|
|
<a name="l505"></a> y=</span><span class=cF5>Clamp</span><span class=cF0>(y,0,map_height*SCRN_SCALE);
|
|
<a name="l506"></a> color=map[y/SCRN_SCALE*map_width+x/SCRN_SCALE];
|
|
<a name="l507"></a> </span><span class=cF1>if</span><span class=cF0> (color==</span><span class=cF3>DKGRAY</span><span class=cF0> || color==</span><span class=cF3>GREEN</span><span class=cF0>) {
|
|
<a name="l508"></a> man_xx=x;
|
|
<a name="l509"></a> man_yy=y;
|
|
<a name="l510"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l511"></a> } </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l512"></a> step>>=1;
|
|
<a name="l513"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>while</span><span class=cF0> (step);
|
|
<a name="l514"></a>}
|
|
<a name="l515"></a>
|
|
<a name="l516"></a>#</span><span class=cF1>define</span><span class=cF0> MICRO_STEPS 4
|
|
<a name="l517"></a></span><span class=cF1>U0</span><span class=cF0> RotateMan(</span><span class=cF1>F64</span><span class=cF0> d)
|
|
<a name="l518"></a>{
|
|
<a name="l519"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
|
<a name="l520"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<MICRO_STEPS;i++) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l521"></a> man_theta+=d/MICRO_STEPS;
|
|
<a name="l522"></a> </span><span class=cF5>Sleep</span><span class=cF0>(15);
|
|
<a name="l523"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l524"></a>}
|
|
<a name="l525"></a>
|
|
<a name="l526"></a></span><span class=cF1>U0</span><span class=cF0> CastleFrankenstein()
|
|
<a name="l527"></a>{
|
|
<a name="l528"></a> </span><span class=cF9>I64</span><span class=cF0> sc;
|
|
<a name="l529"></a> </span><span class=cF5>MenuPush</span><span class=cF0>(
|
|
<a name="l530"></a> </span><span class=cF6>"File {"</span><span class=cF0>
|
|
<a name="l531"></a> </span><span class=cF6>" Abort(,CH_SHIFT_ESC);"</span><span class=cF0>
|
|
<a name="l532"></a> </span><span class=cF6>" Exit(,CH_ESC);"</span><span class=cF0>
|
|
<a name="l533"></a> </span><span class=cF6>"}"</span><span class=cF0>
|
|
<a name="l534"></a> </span><span class=cF6>"Play {"</span><span class=cF0>
|
|
<a name="l535"></a> </span><span class=cF6>" Restart(,'\n');"</span><span class=cF0>
|
|
<a name="l536"></a> </span><span class=cF6>" Fwd(,,SC_CURSOR_UP);"</span><span class=cF0>
|
|
<a name="l537"></a> </span><span class=cF6>" Bwd(,,SC_CURSOR_DOWN);"</span><span class=cF0>
|
|
<a name="l538"></a> </span><span class=cF6>" Left(,,SC_CURSOR_LEFT);"</span><span class=cF0>
|
|
<a name="l539"></a> </span><span class=cF6>" Right(,,SC_CURSOR_RIGHT);"</span><span class=cF0>
|
|
<a name="l540"></a> </span><span class=cF6>" Fire(,CH_SPACE);"</span><span class=cF0>
|
|
<a name="l541"></a> </span><span class=cF6>"}"</span><span class=cF0>
|
|
<a name="l542"></a> );
|
|
<a name="l543"></a>
|
|
<a name="l544"></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="l545"></a> </span><span class=cF5>Fs</span><span class=cF0>->text_attr=</span><span class=cF3>DKGRAY</span><span class=cF0><<4+</span><span class=cF3>WHITE</span><span class=cF0>;
|
|
<a name="l546"></a> </span><span class=cF5>AutoComplete</span><span class=cF0>;
|
|
<a name="l547"></a> </span><span class=cF5>WinBorder</span><span class=cF0>;
|
|
<a name="l548"></a> </span><span class=cF5>WinMax</span><span class=cF0>;
|
|
<a name="l549"></a> </span><span class=cF5>DocCursor</span><span class=cF0>;
|
|
<a name="l550"></a> Init;
|
|
<a name="l551"></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="l552"></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="l553"></a> </span><span class=cF5>Fs</span><span class=cF0>->draw_it=&</span><span class=cF5>DrawIt</span><span class=cF0>;
|
|
<a name="l554"></a>
|
|
<a name="l555"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l556"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) {
|
|
<a name="l557"></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="l558"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SPACE</span><span class=cF0>:
|
|
<a name="l559"></a> Fire;
|
|
<a name="l560"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l561"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\n'</span><span class=cF0>:
|
|
<a name="l562"></a> Init;
|
|
<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>CH_ESC</span><span class=cF0>:
|
|
<a name="l565"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0>:
|
|
<a name="l566"></a> </span><span class=cF1>goto</span><span class=cF0> fs_done;
|
|
<a name="l567"></a> </span><span class=cF1>case</span><span class=cF0> 0:
|
|
<a name="l568"></a> </span><span class=cF1>switch</span><span class=cF0> (sc.u8[0]) {
|
|
<a name="l569"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_RIGHT</span><span class=cF0>:
|
|
<a name="l570"></a> </span><span class=cF5>Spawn</span><span class=cF0>(&RotateMan,</span><span class=cF7>(</span><span class=cF3>pi</span><span class=cF0>/32</span><span class=cF7>)(</span><span class=cF9>I64</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l571"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l572"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_LEFT</span><span class=cF0>:
|
|
<a name="l573"></a> </span><span class=cF5>Spawn</span><span class=cF0>(&RotateMan,</span><span class=cF7>(</span><span class=cF0>-</span><span class=cF3>pi</span><span class=cF0>/32</span><span class=cF7>)(</span><span class=cF9>I64</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l574"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l575"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_UP</span><span class=cF0>:
|
|
<a name="l576"></a> MoveMan(man_theta);
|
|
<a name="l577"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l578"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_DOWN</span><span class=cF0>:
|
|
<a name="l579"></a> MoveMan(man_theta+</span><span class=cF3>pi</span><span class=cF0>);
|
|
<a name="l580"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l581"></a> }
|
|
<a name="l582"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l583"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l584"></a> }
|
|
<a name="l585"></a>fs_done:
|
|
<a name="l586"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>catch</span><span class=cF0>
|
|
<a name="l587"></a> </span><span class=cF5>PutExcept</span><span class=cF0>;
|
|
<a name="l588"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
|
|
<a name="l589"></a> </span><span class=cF5>SettingsPop</span><span class=cF0>;
|
|
<a name="l590"></a> CleanUp;
|
|
<a name="l591"></a> </span><span class=cF5>MenuPop</span><span class=cF0>;
|
|
<a name="l592"></a> </span><span class=cF5>RegWrite</span><span class=cF0>(</span><span class=cF6>"TempleOS/CastleFrankenstein"</span><span class=cF0>,</span><span class=cF6>"F64 best_score=%5.4f;\n"</span><span class=cF0>,
|
|
<a name="l593"></a> best_score);
|
|
<a name="l594"></a>}
|
|
<a name="l595"></a>
|
|
<a name="l596"></a>CastleFrankenstein;
|
|
</span></pre></body>
|
|
</html>
|