389 lines
31 KiB
Plaintext
389 lines
31 KiB
Plaintext
|
<!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=cF1>U0</span><span class=cF0> InitDefines()
|
||
|
<a name="l2"></a>{
|
||
|
<a name="l3"></a> </span><span class=cF9>I64</span><span class=cF0> w=</span><span class=cF3>GR_WIDTH</span><span class=cF0>,h=</span><span class=cF3>GR_HEIGHT</span><span class=cF0>-</span><span class=cF3>FONT_HEIGHT</span><span class=cF0>,cols,rows,
|
||
|
<a name="l4"></a> size=</span><span class=cF5>PopUpRangeI64</span><span class=cF0>(1,9,,</span><span class=cF6>"Size\n"</span><span class=cF0>),rad=16-size;
|
||
|
<a name="l5"></a> </span><span class=cF1>if</span><span class=cF0> (size<0) </span><span class=cF5>throw</span><span class=cF0>;
|
||
|
<a name="l6"></a> </span><span class=cF5>DefinePrint</span><span class=cF0>(</span><span class=cF6>"UNITS_NUM"</span><span class=cF0>,</span><span class=cF6>"%d"</span><span class=cF0>,4096/</span><span class=cF5>SqrI64</span><span class=cF7>(</span><span class=cF0>rad</span><span class=cF7>)</span><span class=cF0>&~1);
|
||
|
<a name="l7"></a> </span><span class=cF5>DefinePrint</span><span class=cF0>(</span><span class=cF6>"CIRCLE_RAD"</span><span class=cF0>,</span><span class=cF6>"%d"</span><span class=cF0>,rad);
|
||
|
<a name="l8"></a> </span><span class=cF5>DefinePrint</span><span class=cF0>(</span><span class=cF6>"MOVE_CIRCLES"</span><span class=cF0>,</span><span class=cF6>"%d"</span><span class=cF0>,40/rad);
|
||
|
<a name="l9"></a>
|
||
|
<a name="l10"></a> cols=(w-8-rad)/(2*rad)&~1-1;
|
||
|
<a name="l11"></a> </span><span class=cF5>DefinePrint</span><span class=cF0>(</span><span class=cF6>"BORDER_X"</span><span class=cF0>,</span><span class=cF6>"%d"</span><span class=cF0>,</span><span class=cF7>(</span><span class=cF0>w+rad-cols*2*rad</span><span class=cF7>)</span><span class=cF0>/2);
|
||
|
<a name="l12"></a>
|
||
|
<a name="l13"></a> rows=(h-8)/(2*rad)&~1;
|
||
|
<a name="l14"></a> </span><span class=cF5>DefinePrint</span><span class=cF0>(</span><span class=cF6>"BORDER_Y"</span><span class=cF0>,</span><span class=cF6>"%d"</span><span class=cF0>,</span><span class=cF7>(</span><span class=cF0>h-rows*2*rad</span><span class=cF7>)</span><span class=cF0>/2);
|
||
|
<a name="l15"></a>
|
||
|
<a name="l16"></a>} InitDefines;
|
||
|
<a name="l17"></a>
|
||
|
<a name="l18"></a></span><span class=cF1>class</span><span class=cF0> Unit
|
||
|
<a name="l19"></a>{
|
||
|
<a name="l20"></a> </span><span class=cF9>I64</span><span class=cF0> num,x,y,player,link,color;
|
||
|
<a name="l21"></a> </span><span class=cF1>Bool</span><span class=cF0> alive,king;
|
||
|
<a name="l22"></a>} u[UNITS_NUM];
|
||
|
<a name="l23"></a>
|
||
|
<a name="l24"></a></span><span class=cF9>CDC</span><span class=cF0> *map_dc;
|
||
|
<a name="l25"></a></span><span class=cF9>I64</span><span class=cF0> cur_player,num_alive[2],start_x,start_y,end_x,end_y;
|
||
|
<a name="l26"></a></span><span class=cF1>Bool</span><span class=cF0> show_start;
|
||
|
<a name="l27"></a>
|
||
|
<a name="l28"></a></span><span class=cF1>U0</span><span class=cF0> S2Circle(</span><span class=cF9>I64</span><span class=cF0> *_x,</span><span class=cF9>I64</span><span class=cF0> *_y)
|
||
|
<a name="l29"></a>{
|
||
|
<a name="l30"></a> </span><span class=cF9>I64</span><span class=cF0> i,j;
|
||
|
<a name="l31"></a> j=(*_y-BORDER_Y)/(CIRCLE_RAD*2);
|
||
|
<a name="l32"></a> </span><span class=cF1>if</span><span class=cF0> (j&1)
|
||
|
<a name="l33"></a> i=(*_x-CIRCLE_RAD-BORDER_X)/(CIRCLE_RAD*2);
|
||
|
<a name="l34"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l35"></a> i=(*_x-BORDER_X)/(CIRCLE_RAD*2);
|
||
|
<a name="l36"></a> *_y=j;
|
||
|
<a name="l37"></a> *_x=i;
|
||
|
<a name="l38"></a>}
|
||
|
<a name="l39"></a>
|
||
|
<a name="l40"></a></span><span class=cF1>U0</span><span class=cF0> Circle2S(</span><span class=cF9>I64</span><span class=cF0> *_x,</span><span class=cF9>I64</span><span class=cF0> *_y)
|
||
|
<a name="l41"></a>{
|
||
|
<a name="l42"></a> </span><span class=cF9>I64</span><span class=cF0> j=*_y,i=*_x;
|
||
|
<a name="l43"></a> *_y=j*CIRCLE_RAD*2+CIRCLE_RAD+BORDER_Y;
|
||
|
<a name="l44"></a> *_x=i*CIRCLE_RAD*2+CIRCLE_RAD+BORDER_X;
|
||
|
<a name="l45"></a> </span><span class=cF1>if</span><span class=cF0> (j&1) *_x+=CIRCLE_RAD;
|
||
|
<a name="l46"></a>}
|
||
|
<a name="l47"></a>
|
||
|
<a name="l48"></a></span><span class=cF1>U0</span><span class=cF0> S2W(</span><span class=cF9>I64</span><span class=cF0> *_x,</span><span class=cF9>I64</span><span class=cF0> *_y)
|
||
|
<a name="l49"></a>{
|
||
|
<a name="l50"></a> S2Circle(_x,_y);
|
||
|
<a name="l51"></a> Circle2S(_x,_y);
|
||
|
<a name="l52"></a>}
|
||
|
<a name="l53"></a>
|
||
|
<a name="l54"></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="l55"></a>{
|
||
|
<a name="l56"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
||
|
<a name="l57"></a> map_dc->flags|=</span><span class=cF3>DCF_NO_TRANSPARENTS</span><span class=cF0>;
|
||
|
<a name="l58"></a> </span><span class=cF5>GrBlot</span><span class=cF0>(dc,0,0,map_dc);
|
||
|
<a name="l59"></a>
|
||
|
<a name="l60"></a> </span><span class=cF1>if</span><span class=cF0> (cur_player==0) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l61"></a> dc->color=</span><span class=cF3>LTCYAN</span><span class=cF0>;
|
||
|
<a name="l62"></a> </span><span class=cF5>GrFloodFill</span><span class=cF0>(dc,0,0);
|
||
|
<a name="l63"></a> dc->color=</span><span class=cF3>CYAN</span><span class=cF0>;
|
||
|
<a name="l64"></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="l65"></a> dc->color=</span><span class=cF3>LTPURPLE</span><span class=cF0>;
|
||
|
<a name="l66"></a> </span><span class=cF5>GrFloodFill</span><span class=cF0>(dc,0,0);
|
||
|
<a name="l67"></a> dc->color=</span><span class=cF3>PURPLE</span><span class=cF0>;
|
||
|
<a name="l68"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l69"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc,2,2,</span><span class=cF6>"Player %d"</span><span class=cF0>,cur_player+1);
|
||
|
<a name="l70"></a>
|
||
|
<a name="l71"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<UNITS_NUM;i++)
|
||
|
<a name="l72"></a> </span><span class=cF1>if</span><span class=cF0> (u[i].alive) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l73"></a> dc->color=u[i].color;
|
||
|
<a name="l74"></a> </span><span class=cF5>GrFloodFill</span><span class=cF0>(dc,u[i].x,u[i].y);
|
||
|
<a name="l75"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l76"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<UNITS_NUM;i++)
|
||
|
<a name="l77"></a> </span><span class=cF1>if</span><span class=cF0> (u[i].alive && !u[i].king) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l78"></a> dc->color=</span><span class=cF3>BLACK</span><span class=cF0>;
|
||
|
<a name="l79"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc,u[i].x,u[i].y,u[u[i].link].x,u[u[i].link].y);
|
||
|
<a name="l80"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Blink</span><span class=cF0>) {
|
||
|
<a name="l81"></a> dc->color=</span><span class=cF3>BLUE</span><span class=cF0>;
|
||
|
<a name="l82"></a> dc->thick=6;
|
||
|
<a name="l83"></a> </span><span class=cF5>GrPlot3</span><span class=cF0>(dc,</span><span class=cF7>(</span><span class=cF0>u[i].x+u[u[i].link].x</span><span class=cF7>)</span><span class=cF0>>>1,</span><span class=cF7>(</span><span class=cF0>u[i].y+u[u[i].link].y</span><span class=cF7>)</span><span class=cF0>>>1,0);
|
||
|
<a name="l84"></a> }
|
||
|
<a name="l85"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l86"></a> </span><span class=cF1>if</span><span class=cF0> (show_start) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l87"></a> dc->color=</span><span class=cF3>LTRED</span><span class=cF0>;
|
||
|
<a name="l88"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc,start_x-4,start_y-4,start_x+4,start_y+4);
|
||
|
<a name="l89"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc,start_x-4,start_y+4,start_x+4,start_y-4);
|
||
|
<a name="l90"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc,start_x,start_y,end_x,end_y);
|
||
|
<a name="l91"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l92"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>num_alive[0]==1 || num_alive[1]==1</span><span class=cF7>)</span><span class=cF0> && </span><span class=cF5>Blink</span><span class=cF7>(</span><span class=cF0>4</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l93"></a> dc->color=</span><span class=cF3>BLACK</span><span class=cF0>;
|
||
|
<a name="l94"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc,</span><span class=cF7>(</span><span class=cF0>task->pix_width-</span><span class=cF3>FONT_WIDTH</span><span class=cF0>*9</span><span class=cF7>)</span><span class=cF0>>>1,
|
||
|
<a name="l95"></a> </span><span class=cF7>(</span><span class=cF0>task->pix_height-</span><span class=cF3>FONT_HEIGHT</span><span class=cF7>)</span><span class=cF0>>>1,</span><span class=cF6>"Game Over"</span><span class=cF0>);
|
||
|
<a name="l96"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l97"></a>}
|
||
|
<a name="l98"></a>
|
||
|
<a name="l99"></a>Unit *UnitFind(</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> player)
|
||
|
<a name="l100"></a>{
|
||
|
<a name="l101"></a> </span><span class=cF9>I64</span><span class=cF0> i,dd,best_dd=</span><span class=cF3>I64_MAX</span><span class=cF0>;
|
||
|
<a name="l102"></a> Unit *res=</span><span class=cF3>NULL</span><span class=cF0>;
|
||
|
<a name="l103"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<UNITS_NUM;i++) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l104"></a> </span><span class=cF1>if</span><span class=cF0> (u[i].player==player && u[i].alive) {
|
||
|
<a name="l105"></a> dd=</span><span class=cF5>SqrI64</span><span class=cF0>(u[i].x-x)+</span><span class=cF5>SqrI64</span><span class=cF0>(u[i].y-y);
|
||
|
<a name="l106"></a> </span><span class=cF1>if</span><span class=cF0> (dd<best_dd) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l107"></a> best_dd=dd;
|
||
|
<a name="l108"></a> res=&u[i];
|
||
|
<a name="l109"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l110"></a> }
|
||
|
<a name="l111"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l112"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
||
|
<a name="l113"></a>}
|
||
|
<a name="l114"></a>
|
||
|
<a name="l115"></a></span><span class=cF1>U0</span><span class=cF0> KillsChk(</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> player)
|
||
|
<a name="l116"></a>{
|
||
|
<a name="l117"></a> </span><span class=cF9>I64</span><span class=cF0> i,j,x2,y2,dd;
|
||
|
<a name="l118"></a> </span><span class=cF1>Bool</span><span class=cF0> found;
|
||
|
<a name="l119"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<UNITS_NUM;i++) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l120"></a> </span><span class=cF1>if</span><span class=cF0> (u[i].player!=player && u[i].alive && !u[i].king) {
|
||
|
<a name="l121"></a> x2=(u[i].x+u[u[i].link].x)>>1;
|
||
|
<a name="l122"></a> y2=(u[i].y+u[u[i].link].y)>>1;
|
||
|
<a name="l123"></a> dd=</span><span class=cF5>SqrI64</span><span class=cF0>(x2-x1)+</span><span class=cF5>SqrI64</span><span class=cF0>(y2-y1);
|
||
|
<a name="l124"></a> </span><span class=cF1>if</span><span class=cF0> (dd<=</span><span class=cF7>(</span><span class=cF0>CIRCLE_RAD+2</span><span class=cF7>)</span><span class=cF0>*</span><span class=cF7>(</span><span class=cF0>CIRCLE_RAD+2</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l125"></a> u[i].alive=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l126"></a> </span><span class=cF5>Snd</span><span class=cF0>(62);</span><span class=cF5>Sleep</span><span class=cF0>(100);</span><span class=cF5>Snd</span><span class=cF0>;</span><span class=cF5>Sleep</span><span class=cF0>(25);
|
||
|
<a name="l127"></a> num_alive[u[i].player]--;
|
||
|
<a name="l128"></a> </span><span class=cF1>do</span><span class=cF0> {
|
||
|
<a name="l129"></a> found=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l130"></a> </span><span class=cF1>for</span><span class=cF0> (j=0;j<UNITS_NUM;j++)
|
||
|
<a name="l131"></a> </span><span class=cF1>if</span><span class=cF0> (u[j].alive && u[j].player!=player && !u[j].king &&
|
||
|
<a name="l132"></a> !u[u[j].link].alive) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l133"></a> found=</span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l134"></a> u[j].alive=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l135"></a> </span><span class=cF5>Snd</span><span class=cF0>(62);</span><span class=cF5>Sleep</span><span class=cF0>(100);</span><span class=cF5>Snd</span><span class=cF0>;</span><span class=cF5>Sleep</span><span class=cF0>(25);
|
||
|
<a name="l136"></a> num_alive[u[j].player]--;
|
||
|
<a name="l137"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l138"></a> } </span><span class=cF1>while</span><span class=cF0> (found);
|
||
|
<a name="l139"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l140"></a> }
|
||
|
<a name="l141"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l142"></a>}
|
||
|
<a name="l143"></a>
|
||
|
<a name="l144"></a></span><span class=cF1>Bool</span><span class=cF0> UnitMove(Unit *tmpu,</span><span class=cF9>I64</span><span class=cF0> x2,</span><span class=cF9>I64</span><span class=cF0> y2)
|
||
|
<a name="l145"></a>{
|
||
|
<a name="l146"></a> </span><span class=cF9>I64</span><span class=cF0> i,r,c,r2,c2,x=start_x,y=start_y;
|
||
|
<a name="l147"></a> S2W(&x2,&y2);
|
||
|
<a name="l148"></a> c2=x2; r2=y2;
|
||
|
<a name="l149"></a> S2Circle(&c2,&r2);
|
||
|
<a name="l150"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<MOVE_CIRCLES+1;i++) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l151"></a> c=x; r=y;
|
||
|
<a name="l152"></a> S2Circle(&c,&r);
|
||
|
<a name="l153"></a> </span><span class=cF1>if</span><span class=cF0> (c==c2 && r==r2) {
|
||
|
<a name="l154"></a> end_x=tmpu->x=x2;
|
||
|
<a name="l155"></a> end_y=tmpu->y=y2;
|
||
|
<a name="l156"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l157"></a> }
|
||
|
<a name="l158"></a> </span><span class=cF1>if</span><span class=cF0> (r2!=r) {
|
||
|
<a name="l159"></a> </span><span class=cF1>if</span><span class=cF0> (r&1) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l160"></a> </span><span class=cF1>if</span><span class=cF0> (c<c2) c++;
|
||
|
<a name="l161"></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="l162"></a> </span><span class=cF1>if</span><span class=cF0> (c>c2) c--;
|
||
|
<a name="l163"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l164"></a> }
|
||
|
<a name="l165"></a> </span><span class=cF1>if</span><span class=cF0> (r2>r) {
|
||
|
<a name="l166"></a> x=c; y=++r;
|
||
|
<a name="l167"></a> Circle2S(&x,&y);
|
||
|
<a name="l168"></a> } </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (r2<r) {
|
||
|
<a name="l169"></a> x=c; y=--r;
|
||
|
<a name="l170"></a> Circle2S(&x,&y);
|
||
|
<a name="l171"></a> } </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (c2>c) {
|
||
|
<a name="l172"></a> x=++c; y=r;
|
||
|
<a name="l173"></a> Circle2S(&x,&y);
|
||
|
<a name="l174"></a> } </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (c2<c) {
|
||
|
<a name="l175"></a> x=--c; y=r;
|
||
|
<a name="l176"></a> Circle2S(&x,&y);
|
||
|
<a name="l177"></a> }
|
||
|
<a name="l178"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l179"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l180"></a>}
|
||
|
<a name="l181"></a>
|
||
|
<a name="l182"></a></span><span class=cF9>CDC</span><span class=cF0> *DrawHexMap(</span><span class=cF9>I64</span><span class=cF0> *_w,</span><span class=cF9>I64</span><span class=cF0> *_h)
|
||
|
<a name="l183"></a>{
|
||
|
<a name="l184"></a> </span><span class=cF9>CDC</span><span class=cF0> *dc=</span><span class=cF5>DCNew</span><span class=cF0>(*_w,*_h);
|
||
|
<a name="l185"></a> </span><span class=cF9>I64</span><span class=cF0> i,j,x,y;
|
||
|
<a name="l186"></a> *_w=(dc->width-BORDER_X*2-CIRCLE_RAD)/(CIRCLE_RAD*2);
|
||
|
<a name="l187"></a> *_h=(dc->height-BORDER_Y*2)/(CIRCLE_RAD*2);
|
||
|
<a name="l188"></a> </span><span class=cF5>DCFill</span><span class=cF0>(dc,</span><span class=cF3>WHITE</span><span class=cF0>);
|
||
|
<a name="l189"></a> dc->color=</span><span class=cF3>LTGRAY</span><span class=cF0>;
|
||
|
<a name="l190"></a> </span><span class=cF1>for</span><span class=cF0> (j=0;j<*_h;j++) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l191"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<*_w;i++) {
|
||
|
<a name="l192"></a> x=i*CIRCLE_RAD*2+BORDER_X+CIRCLE_RAD;
|
||
|
<a name="l193"></a> y=j*CIRCLE_RAD*2+BORDER_Y+CIRCLE_RAD;
|
||
|
<a name="l194"></a> </span><span class=cF1>if</span><span class=cF0> (j&1) x+=CIRCLE_RAD;
|
||
|
<a name="l195"></a> S2W(&x,&y);
|
||
|
<a name="l196"></a> </span><span class=cF5>GrCircle</span><span class=cF0>(dc,x,y,CIRCLE_RAD);
|
||
|
<a name="l197"></a> }
|
||
|
<a name="l198"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l199"></a> *_w*=CIRCLE_RAD*2;
|
||
|
<a name="l200"></a> *_h*=CIRCLE_RAD*2;
|
||
|
<a name="l201"></a> </span><span class=cF1>return</span><span class=cF0> dc;
|
||
|
<a name="l202"></a>}
|
||
|
<a name="l203"></a>
|
||
|
<a name="l204"></a></span><span class=cF1>U0</span><span class=cF0> Init()
|
||
|
<a name="l205"></a>{
|
||
|
<a name="l206"></a> </span><span class=cF9>I64</span><span class=cF0> i,j,j1,j2,dd,best_dd,best,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="l207"></a>
|
||
|
<a name="l208"></a> map_dc=DrawHexMap(&w,&h);
|
||
|
<a name="l209"></a> cur_player=0;
|
||
|
<a name="l210"></a>
|
||
|
<a name="l211"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<UNITS_NUM/2;i++) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l212"></a> u[i].num=i;
|
||
|
<a name="l213"></a> u[i+UNITS_NUM/2].num=i+UNITS_NUM/2;
|
||
|
<a name="l214"></a>
|
||
|
<a name="l215"></a>ti_restart:
|
||
|
<a name="l216"></a> u[i].y=</span><span class=cF5>FloorI64</span><span class=cF0>(</span><span class=cF5>RandU32</span><span class=cF0>%h,CIRCLE_RAD*2)+CIRCLE_RAD;
|
||
|
<a name="l217"></a> u[i+UNITS_NUM/2].y=h-1-u[i].y;
|
||
|
<a name="l218"></a> j1=u[i].y/(CIRCLE_RAD*2);
|
||
|
<a name="l219"></a> j2=u[i+UNITS_NUM/2].y/(CIRCLE_RAD*2);
|
||
|
<a name="l220"></a> u[i].y+=BORDER_Y;
|
||
|
<a name="l221"></a> u[i+UNITS_NUM/2].y+=BORDER_Y;
|
||
|
<a name="l222"></a>
|
||
|
<a name="l223"></a> </span><span class=cF1>if</span><span class=cF0> (!i) {
|
||
|
<a name="l224"></a> u[i].x=CIRCLE_RAD;
|
||
|
<a name="l225"></a> </span><span class=cF1>if</span><span class=cF0> (j1&1)
|
||
|
<a name="l226"></a> </span><span class=cF1>goto</span><span class=cF0> ti_restart;
|
||
|
<a name="l227"></a> } </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l228"></a> u[i].x=</span><span class=cF5>FloorI64</span><span class=cF0>(</span><span class=cF5>RandU32</span><span class=cF0>%</span><span class=cF7>(</span><span class=cF0>(w-CIRCLE_RAD*2*2)/2</span><span class=cF7>)</span><span class=cF0>,CIRCLE_RAD*2)+CIRCLE_RAD;
|
||
|
<a name="l229"></a> u[i+UNITS_NUM/2].x=w-1-u[i].x;
|
||
|
<a name="l230"></a>
|
||
|
<a name="l231"></a> </span><span class=cF1>if</span><span class=cF0> (j1&1)
|
||
|
<a name="l232"></a> u[i].x+=CIRCLE_RAD;
|
||
|
<a name="l233"></a> </span><span class=cF1>if</span><span class=cF0> (j2&1)
|
||
|
<a name="l234"></a> u[i+UNITS_NUM/2].x+=CIRCLE_RAD;
|
||
|
<a name="l235"></a> u[i].x+=BORDER_X;
|
||
|
<a name="l236"></a> u[i+UNITS_NUM/2].x+=BORDER_X;
|
||
|
<a name="l237"></a>
|
||
|
<a name="l238"></a> S2W(&u[i].x,&u[i].y);
|
||
|
<a name="l239"></a> S2W(&u[i+UNITS_NUM/2].x,&u[i+UNITS_NUM/2].y);
|
||
|
<a name="l240"></a>
|
||
|
<a name="l241"></a> u[i].player=0;
|
||
|
<a name="l242"></a> u[i+UNITS_NUM/2].player=1;
|
||
|
<a name="l243"></a>
|
||
|
<a name="l244"></a> u[i].alive=</span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l245"></a> u[i+UNITS_NUM/2].alive=</span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l246"></a>
|
||
|
<a name="l247"></a> </span><span class=cF1>if</span><span class=cF0> (!i) {
|
||
|
<a name="l248"></a> u[i].color=</span><span class=cF3>LTCYAN</span><span class=cF0>;
|
||
|
<a name="l249"></a> u[i+UNITS_NUM/2].color=</span><span class=cF3>LTPURPLE</span><span class=cF0>;
|
||
|
<a name="l250"></a> u[i].king=</span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l251"></a> u[i+UNITS_NUM/2].king=</span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l252"></a> } </span><span class=cF1>else</span><span class=cF0> {
|
||
|
<a name="l253"></a> u[i].color=</span><span class=cF3>CYAN</span><span class=cF0>;
|
||
|
<a name="l254"></a> u[i+UNITS_NUM/2].color=</span><span class=cF3>PURPLE</span><span class=cF0>;
|
||
|
<a name="l255"></a> u[i].king=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l256"></a> u[i+UNITS_NUM/2].king=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l257"></a> }
|
||
|
<a name="l258"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l259"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<UNITS_NUM/2;i++) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l260"></a> </span><span class=cF1>if</span><span class=cF0> (!u[i].king) {
|
||
|
<a name="l261"></a> best_dd=</span><span class=cF3>I64_MAX</span><span class=cF0>;
|
||
|
<a name="l262"></a> </span><span class=cF1>for</span><span class=cF0> (j=0;j<UNITS_NUM/2;j++) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l263"></a> </span><span class=cF1>if</span><span class=cF0> (i!=j) {
|
||
|
<a name="l264"></a> dd=</span><span class=cF5>SqrI64</span><span class=cF0>(u[i].x-u[j].x)+</span><span class=cF5>SqrI64</span><span class=cF0>(u[i].y-u[j].y);
|
||
|
<a name="l265"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF7>(</span><span class=cF0>u[j].x<u[i].x || u[j].king</span><span class=cF7>)</span><span class=cF0> && dd<best_dd ) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l266"></a> best_dd=dd;
|
||
|
<a name="l267"></a> best=j;
|
||
|
<a name="l268"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l269"></a> }
|
||
|
<a name="l270"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l271"></a> u[i].link=best;
|
||
|
<a name="l272"></a> u[i+UNITS_NUM/2].link=best+UNITS_NUM/2;
|
||
|
<a name="l273"></a> }
|
||
|
<a name="l274"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l275"></a> num_alive[0]=UNITS_NUM/2;
|
||
|
<a name="l276"></a> num_alive[1]=UNITS_NUM/2;
|
||
|
<a name="l277"></a>}
|
||
|
<a name="l278"></a>
|
||
|
<a name="l279"></a></span><span class=cF1>U0</span><span class=cF0> CleanUp()
|
||
|
<a name="l280"></a>{
|
||
|
<a name="l281"></a> </span><span class=cF5>DCDel</span><span class=cF0>(map_dc);
|
||
|
<a name="l282"></a>}
|
||
|
<a name="l283"></a>
|
||
|
<a name="l284"></a></span><span class=cF1>U0</span><span class=cF0> TreeCheckers()
|
||
|
<a name="l285"></a>{
|
||
|
<a name="l286"></a> </span><span class=cF9>I64</span><span class=cF0> msg_code,arg1,arg2,ch,sc;
|
||
|
<a name="l287"></a> Unit *tmpu;
|
||
|
<a name="l288"></a>
|
||
|
<a name="l289"></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="l290"></a> </span><span class=cF5>MenuPush</span><span class=cF0>(
|
||
|
<a name="l291"></a> </span><span class=cF6>"File {"</span><span class=cF0>
|
||
|
<a name="l292"></a> </span><span class=cF6>" Abort(,CH_SHIFT_ESC);"</span><span class=cF0>
|
||
|
<a name="l293"></a> </span><span class=cF6>" Exit(,CH_ESC);"</span><span class=cF0>
|
||
|
<a name="l294"></a> </span><span class=cF6>"}"</span><span class=cF0>
|
||
|
<a name="l295"></a> </span><span class=cF6>"Play {"</span><span class=cF0>
|
||
|
<a name="l296"></a> </span><span class=cF6>" Restart(,'\n');"</span><span class=cF0>
|
||
|
<a name="l297"></a> </span><span class=cF6>"}"</span><span class=cF0>
|
||
|
<a name="l298"></a> );
|
||
|
<a name="l299"></a> </span><span class=cF5>AutoComplete</span><span class=cF0>;
|
||
|
<a name="l300"></a> </span><span class=cF5>WinBorder</span><span class=cF0>;
|
||
|
<a name="l301"></a> </span><span class=cF5>WinMax</span><span class=cF0>;
|
||
|
<a name="l302"></a> </span><span class=cF5>DocCursor</span><span class=cF0>;
|
||
|
<a name="l303"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
|
||
|
<a name="l304"></a> </span><span class=cF5>PopUpOk</span><span class=cF0>(</span><span class=cF6>"Step on the link mid points.\n"</span><span class=cF0>);
|
||
|
<a name="l305"></a> </span><span class=cF5>Fs</span><span class=cF0>->win_inhibit=</span><span class=cF3>WIG_TASK_DFT</span><span class=cF0>-</span><span class=cF3>WIF_SELF_FOCUS</span><span class=cF0>
|
||
|
<a name="l306"></a> -</span><span class=cF3>WIF_SELF_BORDER</span><span class=cF0>-</span><span class=cF3>WIF_FOCUS_TASK_MENU</span><span class=cF0>;
|
||
|
<a name="l307"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l308"></a>cn_start:
|
||
|
<a name="l309"></a> Init;
|
||
|
<a name="l310"></a> tmpu=</span><span class=cF3>NULL</span><span class=cF0>;
|
||
|
<a name="l311"></a> show_start=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l312"></a> </span><span class=cF5>Fs</span><span class=cF0>->draw_it=&</span><span class=cF5>DrawIt</span><span class=cF0>;
|
||
|
<a name="l313"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) {
|
||
|
<a name="l314"></a> msg_code=</span><span class=cF5>GetMsg</span><span class=cF0>(&arg1,&arg2,
|
||
|
<a name="l315"></a> 1<<</span><span class=cF3>MSG_KEY_DOWN</span><span class=cF0>+1<<</span><span class=cF3>MSG_MS_L_DOWN</span><span class=cF0>+1<<</span><span class=cF3>MSG_MS_L_UP</span><span class=cF0>+1<<</span><span class=cF3>MSG_MS_MOVE</span><span class=cF0>);
|
||
|
<a name="l316"></a> </span><span class=cF1>switch</span><span class=cF0> (msg_code) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l317"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_KEY_DOWN</span><span class=cF0>:
|
||
|
<a name="l318"></a> </span><span class=cF1>switch</span><span class=cF0> (arg1) {
|
||
|
<a name="l319"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\n'</span><span class=cF0>:
|
||
|
<a name="l320"></a> CleanUp;
|
||
|
<a name="l321"></a> </span><span class=cF1>goto</span><span class=cF0> cn_start;
|
||
|
<a name="l322"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_ESC</span><span class=cF0>:
|
||
|
<a name="l323"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0>:
|
||
|
<a name="l324"></a> </span><span class=cF1>goto</span><span class=cF0> cn_done;
|
||
|
<a name="l325"></a> }
|
||
|
<a name="l326"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l327"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_MS_L_DOWN</span><span class=cF0>:
|
||
|
<a name="l328"></a> </span><span class=cF1>if</span><span class=cF0> (num_alive[0]>1 && num_alive[1]>1) {
|
||
|
<a name="l329"></a> tmpu=UnitFind(arg1,arg2,cur_player);
|
||
|
<a name="l330"></a> end_x=start_x=tmpu->x;
|
||
|
<a name="l331"></a> end_y=start_y=tmpu->y;
|
||
|
<a name="l332"></a> show_start=</span><span class=cF3>TRUE</span><span class=cF0>;
|
||
|
<a name="l333"></a> }
|
||
|
<a name="l334"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l335"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_MS_MOVE</span><span class=cF0>:
|
||
|
<a name="l336"></a> </span><span class=cF1>if</span><span class=cF0> (tmpu)
|
||
|
<a name="l337"></a> UnitMove(tmpu,arg1,arg2);
|
||
|
<a name="l338"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l339"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MSG_MS_L_UP</span><span class=cF0>:
|
||
|
<a name="l340"></a> UnitMove(tmpu,arg1,arg2);
|
||
|
<a name="l341"></a> KillsChk(tmpu->x,tmpu->y,cur_player);
|
||
|
<a name="l342"></a> show_start=</span><span class=cF3>FALSE</span><span class=cF0>;
|
||
|
<a name="l343"></a> tmpu=</span><span class=cF3>NULL</span><span class=cF0>;
|
||
|
<a name="l344"></a> cur_player=1-cur_player;
|
||
|
<a name="l345"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l346"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l347"></a> }
|
||
|
<a name="l348"></a>cn_done:
|
||
|
<a name="l349"></a> </span><span class=cF5>GetMsg</span><span class=cF0>(,,1<<</span><span class=cF3>MSG_KEY_UP</span><span class=cF0>);
|
||
|
<a name="l350"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>catch</span><span class=cF0>
|
||
|
<a name="l351"></a> </span><span class=cF5>PutExcept</span><span class=cF0>;
|
||
|
<a name="l352"></a> </span><span class=cF5>SettingsPop</span><span class=cF0>;
|
||
|
<a name="l353"></a> CleanUp;
|
||
|
<a name="l354"></a> </span><span class=cF5>MenuPop</span><span class=cF0>;
|
||
|
<a name="l355"></a>}
|
||
|
<a name="l356"></a>
|
||
|
<a name="l357"></a>TreeCheckers;
|
||
|
</span></pre></body>
|
||
|
</html>
|