140 lines
11 KiB
HTML
Executable File
140 lines
11 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=cF0>#</span><span class=cF1>define</span><span class=cF0> MAP_WIDTH 640 </span><span class=cF2>//Change this, if you like.</span><span class=cF0>
|
|
<a name="l2"></a>#</span><span class=cF1>define</span><span class=cF0> UNITS_NUM 32 </span><span class=cF2>//Change this, if you like.</span><span class=cF0>
|
|
<a name="l3"></a>#</span><span class=cF1>define</span><span class=cF0> HEX_SIDE 11
|
|
<a name="l4"></a>
|
|
<a name="l5"></a></span><span class=cF1>U0</span><span class=cF0> InitDefines()
|
|
<a name="l6"></a>{
|
|
<a name="l7"></a> </span><span class=cF5>DefinePrint</span><span class=cF0>(</span><span class=cF6>"MAP_HEIGHT"</span><span class=cF0>,</span><span class=cF6>"%d"</span><span class=cF0>,</span><span class=cF7>(</span><span class=cF3>GR_HEIGHT</span><span class=cF0>-</span><span class=cF3>FONT_HEIGHT</span><span class=cF0>*2</span><span class=cF7>)</span><span class=cF0>*MAP_WIDTH/</span><span class=cF3>GR_WIDTH</span><span class=cF0>);
|
|
<a name="l8"></a> </span><span class=cF5>DefinePrint</span><span class=cF0>(</span><span class=cF6>"DCOS"</span><span class=cF0>, </span><span class=cF6>"%12.9f"</span><span class=cF0>, HEX_SIDE*</span><span class=cF5>Cos</span><span class=cF7>(</span><span class=cF0>60.0/180*</span><span class=cF3>pi</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l9"></a> </span><span class=cF5>DefinePrint</span><span class=cF0>(</span><span class=cF6>"DSIN"</span><span class=cF0>, </span><span class=cF6>"%12.9f"</span><span class=cF0>, HEX_SIDE*</span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>60.0/180*</span><span class=cF3>pi</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l10"></a> </span><span class=cF5>DefinePrint</span><span class=cF0>(</span><span class=cF6>"HEX_RADIUS"</span><span class=cF0>,</span><span class=cF6>"%12.9f"</span><span class=cF0>, HEX_SIDE*</span><span class=cF5>Sin</span><span class=cF7>(</span><span class=cF0>60.0/180*</span><span class=cF3>pi</span><span class=cF7>)</span><span class=cF0>+0.01); </span><span class=cF2>//Slop</span><span class=cF0>
|
|
<a name="l11"></a>} InitDefines;
|
|
<a name="l12"></a>
|
|
<a name="l13"></a></span><span class=cF9>I64</span><span class=cF0> map_cols=(MAP_WIDTH-DCOS)/(2*HEX_SIDE+2*DCOS),
|
|
<a name="l14"></a> map_rows=</span><span class=cF5>ToI64</span><span class=cF0>(</span><span class=cF7>(</span><span class=cF0>MAP_HEIGHT-DSIN</span><span class=cF7>)</span><span class=cF0>/DSIN)&~1,
|
|
<a name="l15"></a> map_width=map_cols*(2*HEX_SIDE+2*DCOS)+DCOS,
|
|
<a name="l16"></a> map_height=map_rows*DSIN+DSIN+1,
|
|
<a name="l17"></a> x0,y0;
|
|
<a name="l18"></a>
|
|
<a name="l19"></a></span><span class=cF9>CDC</span><span class=cF0> *map_dc;
|
|
<a name="l20"></a></span><span class=cF1>U8</span><span class=cF0> terrain[map_rows][map_cols];
|
|
<a name="l21"></a>
|
|
<a name="l22"></a></span><span class=cF2>//Centers of hexes</span><span class=cF0>
|
|
<a name="l23"></a></span><span class=cF1>class</span><span class=cF0> Pt
|
|
<a name="l24"></a>{
|
|
<a name="l25"></a> </span><span class=cF1>F64</span><span class=cF0> x,y;
|
|
<a name="l26"></a>};
|
|
<a name="l27"></a>Pt hex_centers[map_rows][map_cols];
|
|
<a name="l28"></a>
|
|
<a name="l29"></a></span><span class=cF9>I64</span><span class=cF0> show_vis_row,show_vis_col;
|
|
<a name="l30"></a></span><span class=cF1>Bool</span><span class=cF0> roads[map_rows][map_cols],
|
|
<a name="l31"></a> rivers[map_rows][map_cols],
|
|
<a name="l32"></a> vis_map[map_rows][map_cols];
|
|
<a name="l33"></a>
|
|
<a name="l34"></a></span><span class=cF2>//Other options for PLAINS are WHITE or YELLOW</span><span class=cF0>
|
|
<a name="l35"></a>#</span><span class=cF1>define</span><span class=cF0> PLAINS </span><span class=cF3>LTGREEN</span><span class=cF0>
|
|
<a name="l36"></a>#</span><span class=cF1>define</span><span class=cF0> TREES </span><span class=cF3>GREEN</span><span class=cF0>
|
|
<a name="l37"></a>#</span><span class=cF1>define</span><span class=cF0> MOUNTAINS </span><span class=cF3>DKGRAY</span><span class=cF0>
|
|
<a name="l38"></a>
|
|
<a name="l39"></a></span><span class=cF2>//These are used to display a range circle when they player</span><span class=cF0>
|
|
<a name="l40"></a></span><span class=cF2>//is firing.</span><span class=cF0>
|
|
<a name="l41"></a></span><span class=cF1>F64</span><span class=cF0> fire_radius,fire_radius_x,fire_radius_y;
|
|
<a name="l42"></a>
|
|
<a name="l43"></a></span><span class=cF2>//These display "phase", "turn" and "game over".</span><span class=cF0>
|
|
<a name="l44"></a></span><span class=cF1>U8</span><span class=cF0> msg_buf[</span><span class=cF3>STR_LEN</span><span class=cF0>];
|
|
<a name="l45"></a></span><span class=cF9>I64</span><span class=cF0> msg_off_timeout; </span><span class=cF2>//Jiffies. Goes away after a time.</span><span class=cF0>
|
|
<a name="l46"></a>
|
|
<a name="l47"></a></span><span class=cF2>//Unit types</span><span class=cF0>
|
|
<a name="l48"></a>#</span><span class=cF1>define</span><span class=cF0> UT_INFANTRY 0
|
|
<a name="l49"></a>#</span><span class=cF1>define</span><span class=cF0> UT_ARTILLERY 1
|
|
<a name="l50"></a>#</span><span class=cF1>define</span><span class=cF0> UT_LT_TANK 2
|
|
<a name="l51"></a>#</span><span class=cF1>define</span><span class=cF0> UT_MD_TANK 3
|
|
<a name="l52"></a>
|
|
<a name="l53"></a></span><span class=cF1>class</span><span class=cF0> Unit
|
|
<a name="l54"></a>{
|
|
<a name="l55"></a> </span><span class=cF1>U8</span><span class=cF0> *img;
|
|
<a name="l56"></a> </span><span class=cF9>I64</span><span class=cF0> num,row,col,
|
|
<a name="l57"></a> armored_attack,unarmored_attack,armor;
|
|
<a name="l58"></a> </span><span class=cF1>I8</span><span class=cF0> type,player,facing,movement,life,
|
|
<a name="l59"></a> range,remaining_movement,accuracy;
|
|
<a name="l60"></a> </span><span class=cF1>Bool</span><span class=cF0> vis[2],fired,infantry,indirect_fire,pad[3];
|
|
<a name="l61"></a>};
|
|
<a name="l62"></a>
|
|
<a name="l63"></a>Unit units[2][UNITS_NUM];
|
|
<a name="l64"></a>
|
|
<a name="l65"></a></span><span class=cF2>// Bt(vis_unit_bitmap,player1+player0*((UNITS_NUM+7)&~7))</span><span class=cF0>
|
|
<a name="l66"></a></span><span class=cF1>U8</span><span class=cF0> vis_unit_bitmap[2][(</span><span class=cF7>(</span><span class=cF0>(UNITS_NUM+7)&~7</span><span class=cF7>)</span><span class=cF0>*UNITS_NUM)>>3];
|
|
<a name="l67"></a>
|
|
<a name="l68"></a>#</span><span class=cF1>define</span><span class=cF0> PHASE_START 0
|
|
<a name="l69"></a>#</span><span class=cF1>define</span><span class=cF0> PHASE_INDIRECT 0
|
|
<a name="l70"></a>#</span><span class=cF1>define</span><span class=cF0> PHASE_INDIRECT0 0
|
|
<a name="l71"></a>#</span><span class=cF1>define</span><span class=cF0> PHASE_INDIRECT1 1
|
|
<a name="l72"></a>#</span><span class=cF1>define</span><span class=cF0> PHASE_MOVE 2
|
|
<a name="l73"></a>#</span><span class=cF1>define</span><span class=cF0> PHASE_MOVE0 2
|
|
<a name="l74"></a>#</span><span class=cF1>define</span><span class=cF0> PHASE_MOVE1 3
|
|
<a name="l75"></a>#</span><span class=cF1>define</span><span class=cF0> PHASE_DIRECT 4
|
|
<a name="l76"></a>#</span><span class=cF1>define</span><span class=cF0> PHASE_DIRECT0 4
|
|
<a name="l77"></a>#</span><span class=cF1>define</span><span class=cF0> PHASE_DIRECT1 5
|
|
<a name="l78"></a>#</span><span class=cF1>define</span><span class=cF0> PHASE_END 6
|
|
<a name="l79"></a>
|
|
<a name="l80"></a></span><span class=cF9>I64</span><span class=cF0> phase,cur_player,enemy_player,view_player,turn,
|
|
<a name="l81"></a> cursor_row,cursor_col,alive_cnt[2],
|
|
<a name="l82"></a> player_indirect[2],player_move[2],player_direct[2];
|
|
<a name="l83"></a></span><span class=cF1>F64</span><span class=cF0> animation_delay=0.5;
|
|
<a name="l84"></a>
|
|
<a name="l85"></a></span><span class=cF1>Bool</span><span class=cF0> moving=</span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l86"></a></span><span class=cF9>I64</span><span class=cF0> move_x,move_y;
|
|
<a name="l87"></a></span><span class=cF1>F64</span><span class=cF0> move_facing;
|
|
<a name="l88"></a>Unit *moving_unit;
|
|
<a name="l89"></a></span><span class=cF1>extern</span><span class=cF0> </span><span class=cF9>I64</span><span class=cF0> HexMoveOne(</span><span class=cF9>I64</span><span class=cF0> *_row,</span><span class=cF9>I64</span><span class=cF0> *_col,</span><span class=cF1>F64</span><span class=cF0> x,</span><span class=cF1>F64</span><span class=cF0> y);
|
|
<a name="l90"></a>
|
|
<a name="l91"></a></span><span class=cF1>class</span><span class=cF0> IndirectOrders
|
|
<a name="l92"></a>{
|
|
<a name="l93"></a> IndirectOrders *next,*last;
|
|
<a name="l94"></a> Unit *attacker;
|
|
<a name="l95"></a> </span><span class=cF9>I64</span><span class=cF0> row,col;
|
|
<a name="l96"></a>} indirect_head;
|
|
<a name="l97"></a>
|
|
<a name="l98"></a></span><span class=cF1>Bool</span><span class=cF0> firing=</span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l99"></a></span><span class=cF9>I64</span><span class=cF0> fire_x,fire_y;
|
|
<a name="l100"></a>Unit *target_unit;
|
|
<a name="l101"></a></span><span class=cF1>Bool</span><span class=cF0> target_hit;
|
|
<a name="l102"></a>
|
|
<a name="l103"></a></span><span class=cF1>Bool</span><span class=cF0> indirect_explosion=</span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l104"></a></span><span class=cF9>I64</span><span class=cF0> indirect_row,indirect_col;
|
|
<a name="l105"></a>
|
|
<a name="l106"></a></span><span class=cF9>I64</span><span class=cF0> row_offsets[7]={-1,-2,-1,1,2,1,0};
|
|
<a name="l107"></a></span><span class=cF9>I64</span><span class=cF0> col_offsets_even[7]={-1, 0, 0,0,0,-1,0};
|
|
<a name="l108"></a></span><span class=cF9>I64</span><span class=cF0> col_offsets_odd [7]={ 0, 0, 1,1,0, 0,0};
|
|
</span></pre></body>
|
|
</html>
|