ZealOS/docs/Apps/KeepAway/KeepAway.CC.html
2021-10-27 03:28:16 -04:00

813 lines
80 KiB
HTML
Executable file

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
<meta name="generator" content="ZealOS V1.04">
<style type="text/css">
body {background-color:#1f1f1f;}
.cE0{color:#e3e3e3;background-color:#d4b475;}
.cEA{color:#a1ce97;background-color:#d4b475;}
.cF0{color:#e3e3e3;background-color:#1f1f1f;}
.cF1{color:#4f84a6;background-color:#1f1f1f;}
.cF2{color:#73a255;background-color:#1f1f1f;}
.cF3{color:#297582;background-color:#1f1f1f;}
.cF4{color:#b34f4b;background-color:#1f1f1f;}
.cF5{color:#8a52c3;background-color:#1f1f1f;}
.cF6{color:#b7822f;background-color:#1f1f1f;}
.cF7{color:#444444;background-color:#1f1f1f;}
.cF8{color:#6d6d6d;background-color:#1f1f1f;}
.cF9{color:#94bfde;background-color:#1f1f1f;}
.cFA{color:#a1ce97;background-color:#1f1f1f;}
.cFB{color:#6db4be;background-color:#1f1f1f;}
.cFC{color:#e88e88;background-color:#1f1f1f;}
.cFD{color:#ca94e8;background-color:#1f1f1f;}
.cFE{color:#d4b475;background-color:#1f1f1f;}
.cFF{color:#1f1f1f;background-color:#1f1f1f;}
</style>
</head>
<body>
<pre style="font-family:monospace;font-size:12pt">
<a name="l1"></a><span class=cF2>//The ball and men were generated</span><span class=cF0>
<a name="l2"></a></span><span class=cF2>//with </span><a href="https://zeal-operating-system.github.io/ZealOS/Apps/GrModels/Run.CC.html#l1"><span class=cF4>::/Apps/GrModels/Run.CC</span></a><span class=cF2>.</span><span class=cF0>
<a name="l3"></a></span><span class=cF2>//They were cut-and-pasted here.</span><span class=cF0>
<a name="l4"></a>
<a name="l5"></a></span><span class=cE0>
<a name="l6"></a> </span><span class=cEA>&lt;1&gt;/* Graphics Not Rendered in HTML */</span><span class=cE0>
<a name="l7"></a>
<a name="l8"></a>
<a name="l9"></a>
<a name="l10"></a>
<a name="l11"></a>
<a name="l12"></a> </span><span class=cEA>&lt;2&gt;/* Graphics Not Rendered in HTML */</span><span class=cE0>
<a name="l13"></a>
<a name="l14"></a>
<a name="l15"></a>
<a name="l16"></a>
<a name="l17"></a>
<a name="l18"></a>
<a name="l19"></a> </span><span class=cEA>&lt;3&gt;/* Graphics Not Rendered in HTML */</span><span class=cE0>
<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> </span><span class=cEA>&lt;4&gt;/* Graphics Not Rendered in HTML */</span><span class=cE0>
<a name="l27"></a>
<a name="l28"></a>
<a name="l29"></a>
<a name="l30"></a>
<a name="l31"></a>
<a name="l32"></a>
<a name="l33"></a> </span><span class=cEA>&lt;5&gt;/* Graphics Not Rendered in HTML */</span><span class=cE0>
<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> </span><span class=cEA>&lt;6&gt;/* Graphics Not Rendered in HTML */</span><span class=cE0>
<a name="l41"></a>
<a name="l42"></a>
<a name="l43"></a>
<a name="l44"></a>
<a name="l45"></a>
<a name="l46"></a>
<a name="l47"></a> </span><span class=cEA>&lt;7&gt;/* Graphics Not Rendered in HTML */</span><span class=cE0>
<a name="l48"></a>
<a name="l49"></a>
<a name="l50"></a>
<a name="l51"></a>
<a name="l52"></a>
<a name="l53"></a>
<a name="l54"></a> </span><span class=cEA>&lt;8&gt;/* Graphics Not Rendered in HTML */</span><span class=cE0>
<a name="l55"></a>
<a name="l56"></a>
<a name="l57"></a>
<a name="l58"></a>
<a name="l59"></a>
<a name="l60"></a>
<a name="l61"></a> </span><span class=cEA>&lt;9&gt;/* Graphics Not Rendered in HTML */</span><span class=cE0>
<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> </span><span class=cEA>&lt;10&gt;/* Graphics Not Rendered in HTML */</span><span class=cE0>
<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> </span><span class=cEA>&lt;11&gt;/* Graphics Not Rendered in HTML */</span><span class=cE0>
<a name="l76"></a>
<a name="l77"></a>
<a name="l78"></a>
<a name="l79"></a>
<a name="l80"></a>
<a name="l81"></a>
<a name="l82"></a> </span><span class=cEA>&lt;12&gt;/* Graphics Not Rendered in HTML */</span><span class=cE0>
<a name="l83"></a>
<a name="l84"></a>
<a name="l85"></a>
<a name="l86"></a>
<a name="l87"></a>
<a name="l88"></a> </span><span class=cEA>&lt;13&gt;/* Graphics Not Rendered in HTML */</span><span class=cE0>
<a name="l89"></a>
<a name="l90"></a>
<a name="l91"></a>
<a name="l92"></a>
<a name="l93"></a>
<a name="l94"></a>
<a name="l95"></a> </span><span class=cEA>&lt;14&gt;/* Graphics Not Rendered in HTML */</span><span class=cE0>
<a name="l96"></a>
<a name="l97"></a>
<a name="l98"></a>
<a name="l99"></a>
<a name="l100"></a>
<a name="l101"></a> </span><span class=cEA>&lt;15&gt;/* Graphics Not Rendered in HTML */</span><span class=cE0>
<a name="l102"></a>
<a name="l103"></a>
<a name="l104"></a>
<a name="l105"></a>
<a name="l106"></a>
<a name="l107"></a> </span><span class=cEA>&lt;16&gt;/* Graphics Not Rendered in HTML */</span><span class=cE0>
<a name="l108"></a>
<a name="l109"></a>
<a name="l110"></a>
<a name="l111"></a>
<a name="l112"></a>
<a name="l113"></a>
<a name="l114"></a> </span><span class=cEA>&lt;17&gt;/* Graphics Not Rendered in HTML */</span><span class=cE0>
<a name="l115"></a>
<a name="l116"></a>
<a name="l117"></a>
<a name="l118"></a>
<a name="l119"></a>
<a name="l120"></a>
<a name="l121"></a> </span><span class=cEA>&lt;18&gt;/* Graphics Not Rendered in HTML */</span><span class=cE0>
<a name="l122"></a>
<a name="l123"></a>
<a name="l124"></a>
<a name="l125"></a>
<a name="l126"></a>
<a name="l127"></a>
<a name="l128"></a> </span><span class=cEA>&lt;19&gt;/* Graphics Not Rendered in HTML */</span><span class=cE0>
<a name="l129"></a>
<a name="l130"></a>
<a name="l131"></a>
<a name="l132"></a>
<a name="l133"></a>
<a name="l134"></a>
<a name="l135"></a> </span><span class=cEA>&lt;20&gt;/* Graphics Not Rendered in HTML */</span><span class=cE0>
<a name="l136"></a>
<a name="l137"></a>
<a name="l138"></a>
<a name="l139"></a>
<a name="l140"></a>
<a name="l141"></a>
<a name="l142"></a> </span><span class=cEA>&lt;21&gt;/* Graphics Not Rendered in HTML */</span><span class=cE0>
<a name="l143"></a>
<a name="l144"></a>
<a name="l145"></a>
<a name="l146"></a>
<a name="l147"></a>
<a name="l148"></a>
<a name="l149"></a> </span><span class=cEA>&lt;22&gt;/* Graphics Not Rendered in HTML */</span><span class=cE0>
<a name="l150"></a>
<a name="l151"></a>
<a name="l152"></a>
<a name="l153"></a>
<a name="l154"></a>
<a name="l155"></a>
<a name="l156"></a> </span><span class=cEA>&lt;23&gt;/* Graphics Not Rendered in HTML */</span><span class=cE0>
<a name="l157"></a>
<a name="l158"></a>
<a name="l159"></a>
<a name="l160"></a></span><span class=cF1>class</span><span class=cF0> Frame
<a name="l161"></a>{
<a name="l162"></a> </span><span class=cF1>U8</span><span class=cF0> *img[</span><span class=cFE>2</span><span class=cF0>];
<a name="l163"></a> </span><span class=cF1>F64</span><span class=cF0> dt;
<a name="l164"></a>};
<a name="l165"></a>
<a name="l166"></a>#</span><span class=cF1>define</span><span class=cF0> COURT_BORDER </span><span class=cFE>10</span><span class=cF0>
<a name="l167"></a>#</span><span class=cF1>define</span><span class=cF0> COLLISION_DAMP </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>8</span><span class=cF0>
<a name="l168"></a>#</span><span class=cF1>define</span><span class=cF0> AIR_VISCOSITY </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>1</span><span class=cF0>
<a name="l169"></a>
<a name="l170"></a>#</span><span class=cF1>define</span><span class=cF0> GRAVITY_ACCELERATION </span><span class=cFE>500</span><span class=cF0>
<a name="l171"></a>#</span><span class=cF1>define</span><span class=cF0> SHOT_VELOCITY </span><span class=cFE>400</span><span class=cF0>
<a name="l172"></a>#</span><span class=cF1>define</span><span class=cF0> DRIBBLE_T </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>25</span><span class=cF0>
<a name="l173"></a>#</span><span class=cF1>define</span><span class=cF0> MAN_VELOCITY </span><span class=cFE>150</span><span class=cF0>
<a name="l174"></a>#</span><span class=cF1>define</span><span class=cF0> MAN_SQR_RADIUS (</span><span class=cFE>20</span><span class=cF0> * </span><span class=cFE>20</span><span class=cF0>)
<a name="l175"></a>#</span><span class=cF1>define</span><span class=cF0> FOUL_VELOCITY_THRESHOLD </span><span class=cFE>50</span><span class=cF0>
<a name="l176"></a>#</span><span class=cF1>define</span><span class=cF0> JUMP_VELOCITY </span><span class=cFE>250</span><span class=cF0>
<a name="l177"></a>#</span><span class=cF1>define</span><span class=cF0> ROLL_VELOCITY_THRESHOLD </span><span class=cFE>100</span><span class=cF0>
<a name="l178"></a>#</span><span class=cF1>define</span><span class=cF0> RANDOM_MAN_ACCELERATION </span><span class=cFE>30</span><span class=cF0>
<a name="l179"></a>
<a name="l180"></a>#</span><span class=cF1>define</span><span class=cF0> HEAD_Z_OFFSET </span><span class=cFE>200</span><span class=cF0>
<a name="l181"></a>#</span><span class=cF1>define</span><span class=cF0> HAND_X_OFFSET </span><span class=cFE>30</span><span class=cF0>
<a name="l182"></a>#</span><span class=cF1>define</span><span class=cF0> HAND_Y_OFFSET </span><span class=cFE>20</span><span class=cF0>
<a name="l183"></a>#</span><span class=cF1>define</span><span class=cF0> HAND_SQR_OFFSET (HAND_X_OFFSET * HAND_X_OFFSET + HAND_Y_OFFSET * HAND_Y_OFFSET)
<a name="l184"></a>#</span><span class=cF1>define</span><span class=cF0> HAND_Z_OFFSET </span><span class=cFE>110</span><span class=cF0>
<a name="l185"></a>
<a name="l186"></a>#</span><span class=cF1>define</span><span class=cF0> FIRST_STANDING </span><span class=cFE>0</span><span class=cF0>
<a name="l187"></a>
<a name="l188"></a>#</span><span class=cF1>define</span><span class=cF0> RUNNING_IMGS_NUM </span><span class=cFE>4</span><span class=cF0>
<a name="l189"></a>#</span><span class=cF1>define</span><span class=cF0> FIRST_RUNNING </span><span class=cFE>0</span><span class=cF0>
<a name="l190"></a>#</span><span class=cF1>define</span><span class=cF0> LAST_RUNNING (FIRST_RUNNING + RUNNING_IMGS_NUM - </span><span class=cFE>1</span><span class=cF0>)
<a name="l191"></a>
<a name="l192"></a>#</span><span class=cF1>define</span><span class=cF0> SHOOTING_IMGS_NUM </span><span class=cFE>5</span><span class=cF0>
<a name="l193"></a>#</span><span class=cF1>define</span><span class=cF0> FIRST_SHOOTING (LAST_RUNNING + </span><span class=cFE>1</span><span class=cF0>)
<a name="l194"></a>#</span><span class=cF1>define</span><span class=cF0> LAST_SHOOTING (FIRST_SHOOTING + SHOOTING_IMGS_NUM - </span><span class=cFE>1</span><span class=cF0>)
<a name="l195"></a>
<a name="l196"></a>#</span><span class=cF1>define</span><span class=cF0> DRIBBLING_IMGS_NUM </span><span class=cFE>4</span><span class=cF0>
<a name="l197"></a>#</span><span class=cF1>define</span><span class=cF0> FIRST_DRIBBLING (LAST_SHOOTING + </span><span class=cFE>1</span><span class=cF0>)
<a name="l198"></a>#</span><span class=cF1>define</span><span class=cF0> LAST_DRIBBLING (FIRST_DRIBBLING + DRIBBLING_IMGS_NUM - </span><span class=cFE>1</span><span class=cF0>)
<a name="l199"></a>
<a name="l200"></a>#</span><span class=cF1>define</span><span class=cF0> STOPPED_DRIBBLING_IMGS_NUM </span><span class=cFE>2</span><span class=cF0>
<a name="l201"></a>#</span><span class=cF1>define</span><span class=cF0> FIRST_STOPPED_DRIBBLING (LAST_DRIBBLING + </span><span class=cFE>1</span><span class=cF0>)
<a name="l202"></a>#</span><span class=cF1>define</span><span class=cF0> LAST_STOPPED_DRIBBLING (FIRST_STOPPED_DRIBBLING + STOPPED_DRIBBLING_IMGS_NUM - </span><span class=cFE>1</span><span class=cF0>)
<a name="l203"></a>
<a name="l204"></a>Frame imgs[LAST_STOPPED_DRIBBLING+</span><span class=cFE>1</span><span class=cF0>] = {
<a name="l205"></a>
<a name="l206"></a> </span><span class=cF7>{</span><span class=cF0>{</span><span class=cFA>&lt;6&gt;</span><span class=cF0>, </span><span class=cFA>&lt;7&gt;</span><span class=cF0>}, </span><span class=cFE>2</span><span class=cF0> * DRIBBLE_T / RUNNING_IMGS_NUM</span><span class=cF7>}</span><span class=cF0>,
<a name="l207"></a> </span><span class=cF7>{</span><span class=cF0>{</span><span class=cFA>&lt;2&gt;</span><span class=cF0>, </span><span class=cFA>&lt;3&gt;</span><span class=cF0>}, </span><span class=cFE>2</span><span class=cF0> * DRIBBLE_T / RUNNING_IMGS_NUM</span><span class=cF7>}</span><span class=cF0>,
<a name="l208"></a> </span><span class=cF7>{</span><span class=cF0>{</span><span class=cFA>&lt;6&gt;</span><span class=cF0>, </span><span class=cFA>&lt;7&gt;</span><span class=cF0>}, </span><span class=cFE>2</span><span class=cF0> * DRIBBLE_T / RUNNING_IMGS_NUM</span><span class=cF7>}</span><span class=cF0>,
<a name="l209"></a> </span><span class=cF7>{</span><span class=cF0>{</span><span class=cFA>&lt;4&gt;</span><span class=cF0>, </span><span class=cFA>&lt;5&gt;</span><span class=cF0>}, </span><span class=cFE>2</span><span class=cF0> * DRIBBLE_T / RUNNING_IMGS_NUM</span><span class=cF7>}</span><span class=cF0>,
<a name="l210"></a> </span><span class=cF7>{</span><span class=cF0>{</span><span class=cFA>&lt;8&gt;</span><span class=cF0>, </span><span class=cFA>&lt;9&gt;</span><span class=cF0>}, </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>1</span><span class=cF7>}</span><span class=cF0>, </span><span class=cF7>{</span><span class=cF0>{</span><span class=cFA>&lt;10&gt;</span><span class=cF0>, </span><span class=cFA>&lt;11&gt;</span><span class=cF0>}, </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>2</span><span class=cF7>}</span><span class=cF0>,
<a name="l211"></a> </span><span class=cF7>{</span><span class=cF0>{</span><span class=cFA>&lt;12&gt;</span><span class=cF0>, </span><span class=cFA>&lt;13&gt;</span><span class=cF0>}, </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>2</span><span class=cF7>}</span><span class=cF0>, </span><span class=cF7>{</span><span class=cF0>{</span><span class=cFA>&lt;12&gt;</span><span class=cF0>, </span><span class=cFA>&lt;13&gt;</span><span class=cF0>}, </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>1</span><span class=cF7>}</span><span class=cF0>, </span><span class=cF7>{</span><span class=cF0>{</span><span class=cFA>&lt;14&gt;</span><span class=cF0>, </span><span class=cFA>&lt;15&gt;</span><span class=cF0>}, </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>1</span><span class=cF7>}</span><span class=cF0>,
<a name="l212"></a> </span><span class=cF7>{</span><span class=cF0>{</span><span class=cFA>&lt;20&gt;</span><span class=cF0>, </span><span class=cFA>&lt;21&gt;</span><span class=cF0>}, </span><span class=cFE>2</span><span class=cF0> * DRIBBLE_T / DRIBBLING_IMGS_NUM</span><span class=cF7>}</span><span class=cF0>,
<a name="l213"></a> </span><span class=cF7>{</span><span class=cF0>{</span><span class=cFA>&lt;16&gt;</span><span class=cF0>, </span><span class=cFA>&lt;17&gt;</span><span class=cF0>}, </span><span class=cFE>2</span><span class=cF0> * DRIBBLE_T / DRIBBLING_IMGS_NUM</span><span class=cF7>}</span><span class=cF0>,
<a name="l214"></a> </span><span class=cF7>{</span><span class=cF0>{</span><span class=cFA>&lt;20&gt;</span><span class=cF0>, </span><span class=cFA>&lt;21&gt;</span><span class=cF0>}, </span><span class=cFE>2</span><span class=cF0> * DRIBBLE_T / DRIBBLING_IMGS_NUM</span><span class=cF7>}</span><span class=cF0>,
<a name="l215"></a> </span><span class=cF7>{</span><span class=cF0>{</span><span class=cFA>&lt;18&gt;</span><span class=cF0>, </span><span class=cFA>&lt;19&gt;</span><span class=cF0>}, </span><span class=cFE>2</span><span class=cF0> * DRIBBLE_T / DRIBBLING_IMGS_NUM</span><span class=cF7>}</span><span class=cF0>,
<a name="l216"></a> </span><span class=cF7>{</span><span class=cF0>{</span><span class=cFA>&lt;20&gt;</span><span class=cF0>, </span><span class=cFA>&lt;21&gt;</span><span class=cF0>}, DRIBBLE_T / STOPPED_DRIBBLING_IMGS_NUM</span><span class=cF7>}</span><span class=cF0>,
<a name="l217"></a> </span><span class=cF7>{</span><span class=cF0>{</span><span class=cFA>&lt;22&gt;</span><span class=cF0>, </span><span class=cFA>&lt;23&gt;</span><span class=cF0>}, DRIBBLE_T / STOPPED_DRIBBLING_IMGS_NUM</span><span class=cF7>}</span><span class=cF0>,
<a name="l218"></a>};
<a name="l219"></a>
<a name="l220"></a></span><span class=cF5>RegDefault</span><span class=cF0>(</span><span class=cF6>&quot;ZealOS/KeepAway&quot;</span><span class=cF0>, </span><span class=cF6>&quot;I64 best_score0=0,best_score1=9999;\n&quot;</span><span class=cF0>);
<a name="l221"></a></span><span class=cF5>RegExe</span><span class=cF0>(</span><span class=cF6>&quot;ZealOS/KeepAway&quot;</span><span class=cF0>);
<a name="l222"></a>
<a name="l223"></a></span><span class=cF1>F64</span><span class=cF0> game_t_end, foul_t_end;
<a name="l224"></a></span><span class=cF9>I64</span><span class=cF0> score0, score1;
<a name="l225"></a>
<a name="l226"></a>#</span><span class=cF1>define</span><span class=cF0> PER_SIDE_NUM </span><span class=cFE>3</span><span class=cF0>
<a name="l227"></a>#</span><span class=cF1>define</span><span class=cF0> OBJS_NUM (PER_SIDE_NUM * </span><span class=cFE>2</span><span class=cF0> + </span><span class=cFE>1</span><span class=cF0>)
<a name="l228"></a></span><span class=cF1>Bool</span><span class=cF0> someone_shooting, someone_has_ball;
<a name="l229"></a></span><span class=cF1>F64</span><span class=cF0> shot_land_t;
<a name="l230"></a>
<a name="l231"></a></span><span class=cF1>class</span><span class=cF0> Obj
<a name="l232"></a>{
<a name="l233"></a> </span><span class=cF9>I64</span><span class=cF0> team; </span><span class=cF2>//-1 is ball</span><span class=cF0>
<a name="l234"></a> </span><span class=cF1>F64</span><span class=cF0> x, y, z, DxDt, DyDt, DzDt, theta, radius, stolen_t0;
<a name="l235"></a> </span><span class=cF1>F64</span><span class=cF0> get_ball_dt, get_ball_theta, nearest_man_dd, last_t0, next_t0, foul_t0;
<a name="l236"></a> </span><span class=cF9>I64</span><span class=cF0> last_img, next_img;
<a name="l237"></a> </span><span class=cF1>Bool</span><span class=cF0> stopped, shooting, has_ball, nearest_ball, pad[</span><span class=cFE>4</span><span class=cF0>];
<a name="l238"></a>
<a name="l239"></a>} objs[OBJS_NUM], *ball, *human, *last_owner;
<a name="l240"></a>
<a name="l241"></a></span><span class=cF2>/*</span><span class=cF0>
<a name="l242"></a></span><span class=cF2>Just to be different, Terry didn't use the built-in</span><span class=cF0>
<a name="l243"></a></span><span class=cF2>DCF_TRANSFORMATION flag in this game.</span><span class=cF0>
<a name="l244"></a></span><span class=cF2>Instead, he chose a 45 degree angle</span><span class=cF0>
<a name="l245"></a></span><span class=cF2>between Y and Z as the view point.</span><span class=cF0>
<a name="l246"></a></span><span class=cF2>If he had used the transform, he would</span><span class=cF0>
<a name="l247"></a></span><span class=cF2>have to make all the men taller.</span><span class=cF0>
<a name="l248"></a></span><span class=cF2>This is a little simpler, and faster,</span><span class=cF0>
<a name="l249"></a></span><span class=cF2>but adds lots of factor 2 vals.</span><span class=cF0>
<a name="l250"></a>
<a name="l251"></a></span><span class=cF2>Terry also didn't use the </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l281"><span class=cF4>CMathODE</span></a><span class=cF2> feat,</span><span class=cF0>
<a name="l252"></a></span><span class=cF2>just to be different.</span><span class=cF0>
<a name="l253"></a></span><span class=cF2>*/</span><span class=cF0>
<a name="l254"></a>
<a name="l255"></a></span><span class=cF1>U0</span><span class=cF0> DrawObj(</span><span class=cF9>CDC</span><span class=cF0> *dc, Obj *o, </span><span class=cF1>F64</span><span class=cF0> tt)
<a name="l256"></a>{
<a name="l257"></a> </span><span class=cF1>U8</span><span class=cF0> *tmps;
<a name="l258"></a> </span><span class=cF1>F64</span><span class=cF0> r1 = </span><span class=cF5>Max</span><span class=cF0>(</span><span class=cFE>9</span><span class=cF0> - </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>1</span><span class=cF0> * o-&gt;z, </span><span class=cFE>1</span><span class=cF0>), r2 = </span><span class=cF5>Max</span><span class=cF0>(r1 / </span><span class=cFE>4</span><span class=cF0>, </span><span class=cFE>1</span><span class=cF0>);
<a name="l259"></a>
<a name="l260"></a> </span><span class=cF1>if</span><span class=cF0> (o == human)
<a name="l261"></a> dc-&gt;color = </span><span class=cF3>LTRED</span><span class=cF0>;
<a name="l262"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l263"></a> dc-&gt;color = </span><span class=cF3>BLACK</span><span class=cF0>;
<a name="l264"></a> </span><span class=cF5>GrEllipse</span><span class=cF0>(dc, o-&gt;x, o-&gt;y / </span><span class=cFE>2</span><span class=cF0>, r1, r2);
<a name="l265"></a> </span><span class=cF5>GrFloodFill</span><span class=cF0>(dc, o-&gt;x, o-&gt;y / </span><span class=cFE>2</span><span class=cF0>);
<a name="l266"></a>
<a name="l267"></a> </span><span class=cF1>if</span><span class=cF0> (o == ball)
<a name="l268"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc, o-&gt;x, </span><span class=cF7>(</span><span class=cF0>o-&gt;y - o-&gt;z</span><span class=cF7>)</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>, </span><span class=cF3>GR_Z_ALL</span><span class=cF0> - o-&gt;y, </span><span class=cFA>&lt;1&gt;</span><span class=cF0>);
<a name="l269"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l270"></a> tmps = </span><span class=cF5>SpriteInterpolate</span><span class=cF0>(</span><span class=cF7>(</span><span class=cF0>tt - o-&gt;last_t0</span><span class=cF7>)</span><span class=cF0> / </span><span class=cF7>(</span><span class=cF0>o-&gt;next_t0 - o-&gt;last_t0</span><span class=cF7>)</span><span class=cF0>,
<a name="l271"></a> imgs[o-&gt;last_img].img[o-&gt;team],
<a name="l272"></a> imgs[o-&gt;next_img].img[o-&gt;team]);
<a name="l273"></a> </span><span class=cF5>Sprite3YB</span><span class=cF0>(dc, o-&gt;x, </span><span class=cF7>(</span><span class=cF0>o-&gt;y - o-&gt;z</span><span class=cF7>)</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>, </span><span class=cF3>GR_Z_ALL</span><span class=cF0> - o-&gt;y, tmps, o-&gt;theta);
<a name="l274"></a> </span><span class=cF5>Free</span><span class=cF0>(tmps);
<a name="l275"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l276"></a>}
<a name="l277"></a>
<a name="l278"></a></span><span class=cF9>I64</span><span class=cF0> ObjCompare(Obj *o1, Obj *o2)
<a name="l279"></a>{
<a name="l280"></a> </span><span class=cF1>return</span><span class=cF0> o1-&gt;y - o2-&gt;y;
<a name="l281"></a>}
<a name="l282"></a>
<a name="l283"></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="l284"></a>{
<a name="l285"></a> </span><span class=cF1>F64</span><span class=cF0> tt = </span><span class=cF5>tS</span><span class=cF0>, d, d_down, d_up;
<a name="l286"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l287"></a> Obj *o_sort[OBJS_NUM], *o;
<a name="l288"></a>
<a name="l289"></a> </span><span class=cF5>DCDepthBufAlloc</span><span class=cF0>(dc);
<a name="l290"></a> dc-&gt;ls.x = </span><span class=cFE>10000</span><span class=cF0>;
<a name="l291"></a> dc-&gt;ls.y = </span><span class=cFE>60000</span><span class=cF0>;
<a name="l292"></a> dc-&gt;ls.z = </span><span class=cFE>10000</span><span class=cF0>;
<a name="l293"></a> d = </span><span class=cFE>65535</span><span class=cF0> / </span><span class=cF5>D3I32Norm</span><span class=cF0>(&amp;dc-&gt;ls);
<a name="l294"></a> dc-&gt;ls.x *= d;
<a name="l295"></a> dc-&gt;ls.y *= d;
<a name="l296"></a> dc-&gt;ls.z *= d;
<a name="l297"></a>
<a name="l298"></a> dc-&gt;thick = </span><span class=cFE>2</span><span class=cF0>;
<a name="l299"></a> dc-&gt;color = </span><span class=cF3>RED</span><span class=cF0>;
<a name="l300"></a> </span><span class=cF5>GrBorder</span><span class=cF0>(dc, COURT_BORDER, COURT_BORDER,
<a name="l301"></a> task-&gt;pix_width - </span><span class=cFE>1</span><span class=cF0> - COURT_BORDER,
<a name="l302"></a> task-&gt;pix_height - </span><span class=cFE>1</span><span class=cF0> - COURT_BORDER);
<a name="l303"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; OBJS_NUM; i++)
<a name="l304"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l305"></a> o = o_sort[i] = &amp;objs[i];
<a name="l306"></a> </span><span class=cF1>if</span><span class=cF0> (o != ball)
<a name="l307"></a> {
<a name="l308"></a> </span><span class=cF1>if</span><span class=cF0> (o-&gt;has_ball)
<a name="l309"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l310"></a> ball-&gt;x = o-&gt;x + HAND_X_OFFSET * </span><span class=cF5>Cos</span><span class=cF0>(o-&gt;theta - </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>) + HAND_Y_OFFSET * </span><span class=cF5>Cos</span><span class=cF0>(o-&gt;theta);
<a name="l311"></a> </span><span class=cF2>//The factor 2 is because the man is not transformed.</span><span class=cF0>
<a name="l312"></a> ball-&gt;y = o-&gt;y + HAND_X_OFFSET * </span><span class=cF5>Sin</span><span class=cF0>(o-&gt;theta - </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>) / </span><span class=cFE>2</span><span class=cF0> + HAND_Y_OFFSET * </span><span class=cF5>Sin</span><span class=cF0>(o-&gt;theta) / </span><span class=cFE>2</span><span class=cF0>;
<a name="l313"></a> </span><span class=cF1>if</span><span class=cF0> (ball-&gt;z + ball-&gt;radius * </span><span class=cFE>2</span><span class=cF0> &gt; o-&gt;z + HAND_Z_OFFSET)
<a name="l314"></a> ball-&gt;z = o-&gt;z + HAND_Z_OFFSET - ball-&gt;radius * </span><span class=cFE>2</span><span class=cF0>;
<a name="l315"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l316"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (o-&gt;shooting)
<a name="l317"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l318"></a> ball-&gt;x = o-&gt;x;
<a name="l319"></a> ball-&gt;y = o-&gt;y;
<a name="l320"></a> ball-&gt;z = o-&gt;z + HEAD_Z_OFFSET;
<a name="l321"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l322"></a> </span><span class=cF1>if</span><span class=cF0> (tt &gt; o-&gt;next_t0)
<a name="l323"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l324"></a> </span><span class=cF1>if</span><span class=cF0> (o-&gt;has_ball &amp;&amp; </span><span class=cF7>(</span><span class=cF0>ball-&gt;z + ball-&gt;radius * </span><span class=cFE>2</span><span class=cF0> &gt;= o-&gt;z + HAND_Z_OFFSET || </span><span class=cF5>Abs</span><span class=cF0>(ball-&gt;DzDt) &lt; </span><span class=cFE>30</span><span class=cF7>)</span><span class=cF0>)
<a name="l325"></a> {
<a name="l326"></a> </span><span class=cF2>//This is an approximation. Terry's instinct told him the viscosity term</span><span class=cF0>
<a name="l327"></a> </span><span class=cF2>//needs an </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelB.HH.html#l97"><span class=cF4>Exp</span></a><span class=cF2>(). However, we should be syncronized to img frames, </span><span class=cF0>
<a name="l328"></a> </span><span class=cF2>//so we don't have to be perfect.</span><span class=cF0>
<a name="l329"></a> d_down = </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l330"></a> d_up = </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> / COLLISION_DAMP;
<a name="l331"></a> </span><span class=cF2>//Up bounce takes higher % because speed lost in collision.</span><span class=cF0>
<a name="l332"></a> ball-&gt;DzDt = -(</span><span class=cF7>(</span><span class=cF0>d_down + d_up</span><span class=cF7>)</span><span class=cF0> * </span><span class=cF7>(</span><span class=cF0>o-&gt;z + HAND_Z_OFFSET - ball-&gt;radius * </span><span class=cFE>4</span><span class=cF7>)</span><span class=cF0> / </span><span class=cF7>(</span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> - AIR_VISCOSITY</span><span class=cF7>)</span><span class=cF0> +
<a name="l333"></a> </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0> * GRAVITY_ACCELERATION * </span><span class=cF7>(</span><span class=cF5>Sqr</span><span class=cF0>(DRIBBLE_T * d_up / </span><span class=cF7>(</span><span class=cF0>d_down + d_up</span><span class=cF7>)</span><span class=cF0>) -
<a name="l334"></a> </span><span class=cF5>Sqr</span><span class=cF0>(DRIBBLE_T * d_down / </span><span class=cF7>(</span><span class=cF0>d_down + d_up</span><span class=cF7>)</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0>) / DRIBBLE_T;
<a name="l335"></a> }
<a name="l336"></a> o-&gt;last_t0 = tt;
<a name="l337"></a> o-&gt;last_img = o-&gt;next_img++;
<a name="l338"></a> </span><span class=cF1>if</span><span class=cF0> (o-&gt;stopped)
<a name="l339"></a> {
<a name="l340"></a> </span><span class=cF1>if</span><span class=cF0> (o-&gt;has_ball)
<a name="l341"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l342"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>FIRST_STOPPED_DRIBBLING &lt;= o-&gt;next_img &lt;= LAST_STOPPED_DRIBBLING</span><span class=cF7>)</span><span class=cF0>)
<a name="l343"></a> o-&gt;next_img = FIRST_STOPPED_DRIBBLING;
<a name="l344"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l345"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l346"></a> o-&gt;next_img = FIRST_STANDING;
<a name="l347"></a> o-&gt;stopped = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l348"></a> }
<a name="l349"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (o-&gt;shooting)
<a name="l350"></a> {
<a name="l351"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>FIRST_SHOOTING &lt;= o-&gt;last_img &lt;= LAST_SHOOTING</span><span class=cF7>)</span><span class=cF0>)
<a name="l352"></a> o-&gt;next_img = FIRST_SHOOTING;
<a name="l353"></a> </span><span class=cF1>if</span><span class=cF0> (o-&gt;next_img &gt; LAST_SHOOTING)
<a name="l354"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l355"></a> o-&gt;next_img = FIRST_STANDING;
<a name="l356"></a> someone_has_ball = someone_shooting = o-&gt;has_ball = o-&gt;shooting = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l357"></a> ball-&gt;DxDt = o-&gt;DxDt + SHOT_VELOCITY / </span><span class=cF3>sqrt2</span><span class=cF0> * </span><span class=cF5>Cos</span><span class=cF0>(o-&gt;theta - </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>);
<a name="l358"></a> ball-&gt;DyDt = o-&gt;DyDt + SHOT_VELOCITY / </span><span class=cF3>sqrt2</span><span class=cF0> * </span><span class=cF5>Sin</span><span class=cF0>(o-&gt;theta - </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>);
<a name="l359"></a> ball-&gt;DzDt = o-&gt;DzDt + SHOT_VELOCITY / </span><span class=cF3>sqrt2</span><span class=cF0>;
<a name="l360"></a> shot_land_t = tt + (ball-&gt;DzDt + </span><span class=cF5>Sqrt</span><span class=cF7>(</span><span class=cF5>Sqr</span><span class=cF0>(ball-&gt;DzDt) +
<a name="l361"></a> </span><span class=cFE>2</span><span class=cF0> * GRAVITY_ACCELERATION * ball-&gt;z</span><span class=cF7>)</span><span class=cF0>) / GRAVITY_ACCELERATION;
<a name="l362"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l363"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l364"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l365"></a> ball-&gt;DxDt = </span><span class=cFE>0</span><span class=cF0>;
<a name="l366"></a> ball-&gt;DyDt = </span><span class=cFE>0</span><span class=cF0>;
<a name="l367"></a> ball-&gt;DzDt = </span><span class=cFE>0</span><span class=cF0>;
<a name="l368"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l369"></a> }
<a name="l370"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (o-&gt;has_ball)
<a name="l371"></a> {
<a name="l372"></a> </span><span class=cF1>if</span><span class=cF0> (FIRST_RUNNING &lt;= o-&gt;next_img &lt;= LAST_RUNNING)
<a name="l373"></a> o-&gt;next_img += FIRST_DRIBBLING - FIRST_RUNNING;
<a name="l374"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>FIRST_DRIBBLING &lt;= o-&gt;next_img &lt;= LAST_DRIBBLING</span><span class=cF7>)</span><span class=cF0>)
<a name="l375"></a> o-&gt;next_img = FIRST_DRIBBLING;
<a name="l376"></a> }
<a name="l377"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l378"></a> {
<a name="l379"></a> </span><span class=cF1>if</span><span class=cF0> (FIRST_DRIBBLING &lt;= o-&gt;next_img &lt;= LAST_DRIBBLING)
<a name="l380"></a> o-&gt;next_img += FIRST_RUNNING - FIRST_DRIBBLING;
<a name="l381"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>FIRST_RUNNING &lt;= o-&gt;next_img &lt;= LAST_RUNNING</span><span class=cF7>)</span><span class=cF0>)
<a name="l382"></a> o-&gt;next_img = FIRST_RUNNING;
<a name="l383"></a> }
<a name="l384"></a> o-&gt;next_t0 += imgs[o-&gt;last_img].dt;
<a name="l385"></a> </span><span class=cF1>if</span><span class=cF0> (o-&gt;next_t0 &lt;= tt)
<a name="l386"></a> o-&gt;next_t0 = tt + imgs[o-&gt;last_img].dt;
<a name="l387"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l388"></a> }
<a name="l389"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l390"></a>
<a name="l391"></a> </span><span class=cF5>QuickSortI64</span><span class=cF0>(o_sort, OBJS_NUM, &amp;ObjCompare);
<a name="l392"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; OBJS_NUM; i++)
<a name="l393"></a> DrawObj(dc, o_sort[i], tt);
<a name="l394"></a> tt = (game_t_end - </span><span class=cF5>tS</span><span class=cF0>) / </span><span class=cFE>60</span><span class=cF0>;
<a name="l395"></a> </span><span class=cF1>if</span><span class=cF0> (tt &lt;= </span><span class=cFE>0</span><span class=cF0>)
<a name="l396"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l397"></a> dc-&gt;color = </span><span class=cF3>RED</span><span class=cF0>;
<a name="l398"></a> tt = </span><span class=cFE>0</span><span class=cF0>;
<a name="l399"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Blink</span><span class=cF0>)
<a name="l400"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, </span><span class=cF7>(</span><span class=cF0>task-&gt;pix_width - </span><span class=cF3>FONT_WIDTH</span><span class=cF0> * </span><span class=cFE>9</span><span class=cF7>)</span><span class=cF0> &gt;&gt; </span><span class=cFE>1</span><span class=cF0>,
<a name="l401"></a> </span><span class=cF7>(</span><span class=cF0>task-&gt;pix_height - </span><span class=cF3>FONT_HEIGHT</span><span class=cF7>)</span><span class=cF0> &gt;&gt; </span><span class=cFE>1</span><span class=cF0>, </span><span class=cF6>&quot;Game Over&quot;</span><span class=cF0>);
<a name="l402"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l403"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l404"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l405"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>tS</span><span class=cF0> &lt; foul_t_end)
<a name="l406"></a> {
<a name="l407"></a> dc-&gt;color = </span><span class=cF3>LTRED</span><span class=cF0>;
<a name="l408"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Blink</span><span class=cF0>)
<a name="l409"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, </span><span class=cF7>(</span><span class=cF0>task-&gt;pix_width - </span><span class=cF3>FONT_WIDTH</span><span class=cF0> * </span><span class=cFE>4</span><span class=cF7>)</span><span class=cF0> &gt;&gt; </span><span class=cFE>1</span><span class=cF0>,
<a name="l410"></a> </span><span class=cF7>(</span><span class=cF0>task-&gt;pix_height - </span><span class=cF3>FONT_HEIGHT</span><span class=cF7>)</span><span class=cF0> &gt;&gt; </span><span class=cFE>1</span><span class=cF0>, </span><span class=cF6>&quot;Foul&quot;</span><span class=cF0>);
<a name="l411"></a> }
<a name="l412"></a> dc-&gt;color = </span><span class=cF3>BLACK</span><span class=cF0>;
<a name="l413"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l414"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cF6>&quot;Time:%d:%04.1f Score:&quot;</span><span class=cF0>, </span><span class=cF5>ToI64</span><span class=cF7>(</span><span class=cF0>tt</span><span class=cF7>)</span><span class=cF0>, </span><span class=cF7>(</span><span class=cF0>tt - </span><span class=cF5>ToI64</span><span class=cF0>(tt)</span><span class=cF7>)</span><span class=cF0> * </span><span class=cFE>60</span><span class=cF0>);
<a name="l415"></a> </span><span class=cF5>GrPrint</span><span class=cF0> (dc, </span><span class=cF3>FONT_WIDTH</span><span class=cF0> * </span><span class=cFE>27</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cF6>&quot;Best Score:&quot;</span><span class=cF0>);
<a name="l416"></a>
<a name="l417"></a> dc-&gt;color = </span><span class=cF3>LTCYAN</span><span class=cF0>;
<a name="l418"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, </span><span class=cF3>FONT_WIDTH</span><span class=cF0> * </span><span class=cFE>20</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cF6>&quot;%02d&quot;</span><span class=cF0>, score0);
<a name="l419"></a> dc-&gt;color = </span><span class=cF3>LTPURPLE</span><span class=cF0>;
<a name="l420"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, </span><span class=cF3>FONT_WIDTH</span><span class=cF0> * </span><span class=cFE>23</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cF6>&quot;%02d&quot;</span><span class=cF0>, score1);
<a name="l421"></a>
<a name="l422"></a> dc-&gt;color = </span><span class=cF3>LTCYAN</span><span class=cF0>;
<a name="l423"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, </span><span class=cF3>FONT_WIDTH</span><span class=cF0> * </span><span class=cFE>39</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cF6>&quot;%02d&quot;</span><span class=cF0>, best_score0);
<a name="l424"></a> dc-&gt;color = </span><span class=cF3>LTPURPLE</span><span class=cF0>;
<a name="l425"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, </span><span class=cF3>FONT_WIDTH</span><span class=cF0> * </span><span class=cFE>42</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cF6>&quot;%02d&quot;</span><span class=cF0>, best_score1);
<a name="l426"></a>}
<a name="l427"></a>
<a name="l428"></a></span><span class=cF1>U0</span><span class=cF0> Shoot(Obj *o)
<a name="l429"></a>{
<a name="l430"></a> </span><span class=cF1>if</span><span class=cF0> (!someone_shooting &amp;&amp; o-&gt;has_ball)
<a name="l431"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l432"></a> someone_shooting = o-&gt;stopped = o-&gt;shooting = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l433"></a> o-&gt;has_ball = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l434"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l435"></a>}
<a name="l436"></a>
<a name="l437"></a></span><span class=cF1>U0</span><span class=cF0> AnimateTask(</span><span class=cF9>CTask</span><span class=cF0> *parent_task)
<a name="l438"></a>{
<a name="l439"></a> </span><span class=cF1>F64</span><span class=cF0> d, dx, dy, dt, dx2, dy2, t0 = </span><span class=cF5>tS</span><span class=cF0>;
<a name="l440"></a> </span><span class=cF9>I64</span><span class=cF0> i, j;
<a name="l441"></a> </span><span class=cF1>Bool</span><span class=cF0> gets_ball;
<a name="l442"></a> Obj *o, *nearest_ball[</span><span class=cFE>2</span><span class=cF0>];
<a name="l443"></a>
<a name="l444"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l445"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l446"></a> dt = </span><span class=cF5>tS</span><span class=cF0> - t0;
<a name="l447"></a> t0 = </span><span class=cF5>tS</span><span class=cF0>;
<a name="l448"></a>
<a name="l449"></a> </span><span class=cF1>if</span><span class=cF0> (game_t_end &amp;&amp; game_t_end &lt; t0)
<a name="l450"></a> {
<a name="l451"></a> game_t_end = </span><span class=cFE>0</span><span class=cF0>;
<a name="l452"></a> </span><span class=cF5>Beep</span><span class=cF0>;
<a name="l453"></a> </span><span class=cF1>if</span><span class=cF0> (score0 - score1 &gt; best_score0 - best_score1)
<a name="l454"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l455"></a> best_score0 = score0;
<a name="l456"></a> best_score1 = score1;
<a name="l457"></a> </span><span class=cF5>Sound</span><span class=cF0>(</span><span class=cFE>86</span><span class=cF0>);
<a name="l458"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>100</span><span class=cF0>);
<a name="l459"></a> </span><span class=cF5>Sound</span><span class=cF0>;
<a name="l460"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>100</span><span class=cF0>);
<a name="l461"></a> </span><span class=cF5>Sound</span><span class=cF0>(</span><span class=cFE>86</span><span class=cF0>);
<a name="l462"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>100</span><span class=cF0>);
<a name="l463"></a> </span><span class=cF5>Sound</span><span class=cF0>;
<a name="l464"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>100</span><span class=cF0>);
<a name="l465"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l466"></a> }
<a name="l467"></a>
<a name="l468"></a> </span><span class=cF1>if</span><span class=cF0> (game_t_end)
<a name="l469"></a> {
<a name="l470"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&amp;nearest_ball, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>nearest_ball</span><span class=cF7>)</span><span class=cF0>);
<a name="l471"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; OBJS_NUM; i++) </span><span class=cF7>{</span><span class=cF0>
<a name="l472"></a> o = &amp;objs[i];
<a name="l473"></a> o-&gt;nearest_ball = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l474"></a> </span><span class=cF1>if</span><span class=cF0> (o != ball)
<a name="l475"></a> {
<a name="l476"></a> d = </span><span class=cFE>0</span><span class=cF0>;
<a name="l477"></a> </span><span class=cF1>for</span><span class=cF0> (j = </span><span class=cFE>0</span><span class=cF0>; j &lt; </span><span class=cFE>5</span><span class=cF0>; j++) </span><span class=cF2>//Iterative estimate of how long to get ball.</span><span class=cF0>
<a name="l478"></a> d = </span><span class=cF5>Sqrt</span><span class=cF0>(</span><span class=cF5>Sqr</span><span class=cF7>(</span><span class=cF0>ball-&gt;DxDt * d + ball-&gt;x - o-&gt;x</span><span class=cF7>)</span><span class=cF0> + </span><span class=cF5>Sqr</span><span class=cF7>(</span><span class=cF0>ball-&gt;DyDt * d + ball-&gt;y - o-&gt;y</span><span class=cF7>)</span><span class=cF0>) / MAN_VELOCITY;
<a name="l479"></a> o-&gt;get_ball_dt = d;
<a name="l480"></a> o-&gt;get_ball_theta = </span><span class=cF5>Arg</span><span class=cF0>(ball-&gt;DxDt * d + ball-&gt;x - o-&gt;x, ball-&gt;DyDt * d + ball-&gt;y - o-&gt;y);
<a name="l481"></a> </span><span class=cF1>if</span><span class=cF0> (o != last_owner &amp;&amp; !nearest_ball[o-&gt;team] || o-&gt;get_ball_dt &lt; nearest_ball[o-&gt;team]-&gt;get_ball_dt)
<a name="l482"></a> nearest_ball[o-&gt;team] = o;
<a name="l483"></a> }
<a name="l484"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l485"></a> nearest_ball[</span><span class=cFE>0</span><span class=cF0>]-&gt;nearest_ball = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l486"></a> nearest_ball[</span><span class=cFE>1</span><span class=cF0>]-&gt;nearest_ball = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l487"></a>
<a name="l488"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; OBJS_NUM; i++)
<a name="l489"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l490"></a> o = &amp;objs[i];
<a name="l491"></a> </span><span class=cF1>if</span><span class=cF0> (o == ball)
<a name="l492"></a> {
<a name="l493"></a> o-&gt;x += dt * o-&gt;DxDt;
<a name="l494"></a> o-&gt;y += dt * o-&gt;DyDt;
<a name="l495"></a> </span><span class=cF1>if</span><span class=cF0> (!someone_shooting)
<a name="l496"></a> o-&gt;z += dt * (o-&gt;DzDt - </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0> * GRAVITY_ACCELERATION * dt);
<a name="l497"></a> }
<a name="l498"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l499"></a> {
<a name="l500"></a> </span><span class=cF1>if</span><span class=cF0> (!o-&gt;has_ball)
<a name="l501"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l502"></a> </span><span class=cF1>if</span><span class=cF0> (t0 - o-&gt;stolen_t0 &gt; </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> &amp;&amp; !someone_shooting)
<a name="l503"></a> {
<a name="l504"></a> dx = ball-&gt;x - o-&gt;x;
<a name="l505"></a> dy = ball-&gt;y - o-&gt;y;
<a name="l506"></a> </span><span class=cF1>if</span><span class=cF0> (dx * dx + dy * dy &lt; HAND_SQR_OFFSET &amp;&amp; ball-&gt;z &lt; o-&gt;z + HAND_Z_OFFSET)
<a name="l507"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l508"></a> gets_ball = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l509"></a> </span><span class=cF1>for</span><span class=cF0> (j = </span><span class=cFE>0</span><span class=cF0>; j &lt; PER_SIDE_NUM * </span><span class=cFE>2</span><span class=cF0>; j++)
<a name="l510"></a> </span><span class=cF1>if</span><span class=cF0> (j != i &amp;&amp; objs[j].has_ball)
<a name="l511"></a> {
<a name="l512"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Rand</span><span class=cF0>&lt;</span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> * dt)
<a name="l513"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l514"></a> objs[j].stolen_t0 = t0;
<a name="l515"></a> objs[j].has_ball = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l516"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l517"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l518"></a> gets_ball = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l519"></a> }
<a name="l520"></a> </span><span class=cF1>if</span><span class=cF0> (gets_ball)
<a name="l521"></a> {
<a name="l522"></a> someone_has_ball = o-&gt;has_ball = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l523"></a> </span><span class=cF1>if</span><span class=cF0> (o != last_owner)
<a name="l524"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l525"></a> </span><span class=cF1>if</span><span class=cF0> (o-&gt;team)
<a name="l526"></a> {
<a name="l527"></a> </span><span class=cF1>if</span><span class=cF0> (t0 &lt; shot_land_t + </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>1</span><span class=cF0>)
<a name="l528"></a> score1 += </span><span class=cFE>6</span><span class=cF0>;
<a name="l529"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l530"></a> score1 += </span><span class=cFE>2</span><span class=cF0>;
<a name="l531"></a> </span><span class=cF5>Noise</span><span class=cF0>(</span><span class=cFE>250</span><span class=cF0>, </span><span class=cFE>74</span><span class=cF0>, </span><span class=cFE>74</span><span class=cF0>);
<a name="l532"></a> }
<a name="l533"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l534"></a> {
<a name="l535"></a> </span><span class=cF1>if</span><span class=cF0> (t0 &lt; shot_land_t + </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>1</span><span class=cF0>)
<a name="l536"></a> score0 += </span><span class=cFE>6</span><span class=cF0>;
<a name="l537"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l538"></a> score0 += </span><span class=cFE>2</span><span class=cF0>;
<a name="l539"></a> </span><span class=cF5>Noise</span><span class=cF0>(</span><span class=cFE>250</span><span class=cF0>, </span><span class=cFE>86</span><span class=cF0>, </span><span class=cFE>86</span><span class=cF0>);
<a name="l540"></a> }
<a name="l541"></a> last_owner = o;
<a name="l542"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l543"></a> }
<a name="l544"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l545"></a> }
<a name="l546"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l547"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (o != human &amp;&amp; </span><span class=cF5>Rand</span><span class=cF0> &lt; </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>25</span><span class=cF0> * dt)
<a name="l548"></a> Shoot(o);
<a name="l549"></a> </span><span class=cF1>if</span><span class=cF0> (!o-&gt;shooting)
<a name="l550"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l551"></a> </span><span class=cF1>if</span><span class=cF0> (o == human)
<a name="l552"></a> {
<a name="l553"></a> dx = (</span><span class=cFB>mouse</span><span class=cF0>.pos.x - parent_task-&gt;pix_left - parent_task-&gt;scroll_x) - o-&gt;x;
<a name="l554"></a> dy = (</span><span class=cFB>mouse</span><span class=cF0>.pos.y - parent_task-&gt;pix_top - parent_task-&gt;scroll_y) * </span><span class=cFE>2</span><span class=cF0> - o-&gt;y;
<a name="l555"></a> }
<a name="l556"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l557"></a> {
<a name="l558"></a> </span><span class=cF1>if</span><span class=cF0> (!someone_has_ball &amp;&amp; o-&gt;nearest_man_dd &gt; </span><span class=cFE>4</span><span class=cF0> * MAN_SQR_RADIUS &amp;&amp; o-&gt;nearest_ball)
<a name="l559"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l560"></a> dx = o-&gt;DxDt = MAN_VELOCITY * </span><span class=cF5>Cos</span><span class=cF0>(o-&gt;get_ball_theta);
<a name="l561"></a> dy = o-&gt;DyDt = MAN_VELOCITY * </span><span class=cF5>Sin</span><span class=cF0>(o-&gt;get_ball_theta);
<a name="l562"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l563"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l564"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l565"></a> dx = o-&gt;DxDt += RANDOM_MAN_ACCELERATION / </span><span class=cF3>sqrt2</span><span class=cF0> * </span><span class=cF5>RandI16</span><span class=cF0> / </span><span class=cF3>I16_MAX</span><span class=cF0> * dt;
<a name="l566"></a> dy = o-&gt;DyDt += RANDOM_MAN_ACCELERATION / </span><span class=cF3>sqrt2</span><span class=cF0> * </span><span class=cF5>RandI16</span><span class=cF0> / </span><span class=cF3>I16_MAX</span><span class=cF0> * dt;
<a name="l567"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l568"></a> }
<a name="l569"></a> d = </span><span class=cF5>Sqrt</span><span class=cF0>(dx * dx + dy * dy);
<a name="l570"></a> </span><span class=cF1>if</span><span class=cF0> (d &gt;= </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>)
<a name="l571"></a> {
<a name="l572"></a> o-&gt;theta = </span><span class=cF5>Arg</span><span class=cF0>(dx, dy) + </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>;
<a name="l573"></a> dx *= MAN_VELOCITY / </span><span class=cF3>sqrt2</span><span class=cF0> * dt / d;
<a name="l574"></a> dy *= MAN_VELOCITY / </span><span class=cF3>sqrt2</span><span class=cF0> * dt / d;
<a name="l575"></a> o-&gt;nearest_man_dd = </span><span class=cF3>F64_MAX</span><span class=cF0>;
<a name="l576"></a> </span><span class=cF1>for</span><span class=cF0> (j = </span><span class=cFE>0</span><span class=cF0>; j &lt; PER_SIDE_NUM * </span><span class=cFE>2</span><span class=cF0>; j++)
<a name="l577"></a> </span><span class=cF1>if</span><span class=cF0> (j != i)
<a name="l578"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l579"></a> dx2 = objs[j].x - o-&gt;x;
<a name="l580"></a> dy2 = objs[j].y - o-&gt;y;
<a name="l581"></a> d = </span><span class=cF5>Sqr</span><span class=cF0>(dx2) + </span><span class=cF5>Sqr</span><span class=cF0>(dy2);
<a name="l582"></a> </span><span class=cF1>if</span><span class=cF0> (d &lt; o-&gt;nearest_man_dd)
<a name="l583"></a> o-&gt;nearest_man_dd = d;
<a name="l584"></a> </span><span class=cF1>if</span><span class=cF0> (d &lt; MAN_SQR_RADIUS)
<a name="l585"></a> {
<a name="l586"></a> </span><span class=cF1>if</span><span class=cF0> (d)
<a name="l587"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l588"></a> d = </span><span class=cF5>Sqrt</span><span class=cF0>(d);
<a name="l589"></a> dx2 /= d;
<a name="l590"></a> dy2 /= d;
<a name="l591"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l592"></a> </span><span class=cF1>if</span><span class=cF0> (t0 &gt; o-&gt;foul_t0 + </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>15</span><span class=cF0>)
<a name="l593"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l594"></a> d = (dx - objs[j].DxDt) * dx2 + (dy - objs[j].DyDt) * dy2;
<a name="l595"></a> </span><span class=cF1>if</span><span class=cF0> (o == human &amp;&amp; t0 &gt; o-&gt;foul_t0 + </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> &amp;&amp;
<a name="l596"></a> dt &amp;&amp; d / dt&gt;FOUL_VELOCITY_THRESHOLD &amp;&amp; objs[j].team)
<a name="l597"></a> {
<a name="l598"></a> </span><span class=cF5>Noise</span><span class=cF0>(</span><span class=cFE>250</span><span class=cF0>, </span><span class=cFE>62</span><span class=cF0>, </span><span class=cFE>62</span><span class=cF0>);
<a name="l599"></a> score1 += </span><span class=cFE>1</span><span class=cF0>;
<a name="l600"></a> foul_t_end = t0 + </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
<a name="l601"></a> }
<a name="l602"></a> o-&gt;foul_t0=t0;
<a name="l603"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l604"></a> }
<a name="l605"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l606"></a> </span><span class=cF1>if</span><span class=cF0> (t0 &lt; o-&gt;foul_t0 + </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>15</span><span class=cF0>)
<a name="l607"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l608"></a> dx = -dx;
<a name="l609"></a> dy = -dy;
<a name="l610"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l611"></a> o-&gt;x += dx;
<a name="l612"></a> o-&gt;y += dy;
<a name="l613"></a> o-&gt;stopped = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l614"></a> }
<a name="l615"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l616"></a> o-&gt;stopped = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l617"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l618"></a> </span><span class=cF1>if</span><span class=cF0> (o-&gt;DzDt)
<a name="l619"></a> o-&gt;z += dt * (o-&gt;DzDt - </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0> * GRAVITY_ACCELERATION * dt);
<a name="l620"></a> }
<a name="l621"></a>
<a name="l622"></a> </span><span class=cF1>if</span><span class=cF0> (o-&gt;x + o-&gt;radius &gt;= parent_task-&gt;pix_width - COURT_BORDER)
<a name="l623"></a> {
<a name="l624"></a> o-&gt;x = parent_task-&gt;pix_width - COURT_BORDER - </span><span class=cFE>1</span><span class=cF0> - o-&gt;radius;
<a name="l625"></a> o-&gt;DxDt = -COLLISION_DAMP * o-&gt;DxDt;
<a name="l626"></a> </span><span class=cF1>if</span><span class=cF0> (o == ball)
<a name="l627"></a> </span><span class=cF5>Noise</span><span class=cF0>(</span><span class=cFE>10</span><span class=cF0>, </span><span class=cFE>74</span><span class=cF0>, </span><span class=cFE>86</span><span class=cF0>);
<a name="l628"></a> }
<a name="l629"></a> </span><span class=cF1>if</span><span class=cF0> (o-&gt;x - o-&gt;radius &lt; COURT_BORDER)
<a name="l630"></a> {
<a name="l631"></a> o-&gt;x = COURT_BORDER + o-&gt;radius;
<a name="l632"></a> o-&gt;DxDt = -COLLISION_DAMP * o-&gt;DxDt;
<a name="l633"></a> </span><span class=cF1>if</span><span class=cF0> (o == ball)
<a name="l634"></a> </span><span class=cF5>Noise</span><span class=cF0>(</span><span class=cFE>10</span><span class=cF0>, </span><span class=cFE>74</span><span class=cF0>, </span><span class=cFE>86</span><span class=cF0>);
<a name="l635"></a> }
<a name="l636"></a>
<a name="l637"></a> </span><span class=cF1>if</span><span class=cF0> (o-&gt;y + o-&gt;radius * </span><span class=cFE>2</span><span class=cF0> &gt;= </span><span class=cF7>(</span><span class=cF0>parent_task-&gt;pix_height - COURT_BORDER</span><span class=cF7>)</span><span class=cF0> * </span><span class=cFE>2</span><span class=cF0>)
<a name="l638"></a> {
<a name="l639"></a> o-&gt;y = (parent_task-&gt;pix_height - COURT_BORDER) * </span><span class=cFE>2</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0> - o-&gt;radius * </span><span class=cFE>2</span><span class=cF0>;
<a name="l640"></a> o-&gt;DyDt = -COLLISION_DAMP * o-&gt;DyDt;
<a name="l641"></a> </span><span class=cF1>if</span><span class=cF0> (o == ball)
<a name="l642"></a> </span><span class=cF5>Noise</span><span class=cF0>(</span><span class=cFE>10</span><span class=cF0>, </span><span class=cFE>74</span><span class=cF0>, </span><span class=cFE>86</span><span class=cF0>);
<a name="l643"></a> }
<a name="l644"></a> </span><span class=cF1>if</span><span class=cF0> (o-&gt;y - o-&gt;radius * </span><span class=cFE>2</span><span class=cF0> &lt; </span><span class=cFE>2</span><span class=cF0> * COURT_BORDER)
<a name="l645"></a> {
<a name="l646"></a> o-&gt;y = COURT_BORDER * </span><span class=cFE>2</span><span class=cF0> + o-&gt;radius * </span><span class=cFE>2</span><span class=cF0>;
<a name="l647"></a> o-&gt;DyDt = -COLLISION_DAMP* o-&gt;DyDt;
<a name="l648"></a> </span><span class=cF1>if</span><span class=cF0> (o == ball)
<a name="l649"></a> </span><span class=cF5>Noise</span><span class=cF0>(</span><span class=cFE>10</span><span class=cF0>, </span><span class=cFE>74</span><span class=cF0>, </span><span class=cFE>86</span><span class=cF0>);
<a name="l650"></a> }
<a name="l651"></a>
<a name="l652"></a> </span><span class=cF1>if</span><span class=cF0> (o-&gt;z - o-&gt;radius * </span><span class=cFE>2</span><span class=cF0> &lt; </span><span class=cFE>0</span><span class=cF0>)
<a name="l653"></a> {
<a name="l654"></a> o-&gt;z = o-&gt;radius * </span><span class=cFE>2</span><span class=cF0>;
<a name="l655"></a> o-&gt;DzDt = -COLLISION_DAMP * o-&gt;DzDt;
<a name="l656"></a> </span><span class=cF1>if</span><span class=cF0> (o-&gt;DzDt &gt; ROLL_VELOCITY_THRESHOLD)
<a name="l657"></a> </span><span class=cF5>Noise</span><span class=cF0>(</span><span class=cFE>10</span><span class=cF0>, </span><span class=cFE>74</span><span class=cF0>, </span><span class=cFE>86</span><span class=cF0>);
<a name="l658"></a> </span><span class=cF1>if</span><span class=cF0> (o != ball)
<a name="l659"></a> o-&gt;DzDt = </span><span class=cFE>0</span><span class=cF0>;
<a name="l660"></a> }
<a name="l661"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (o-&gt;z - o-&gt;radius * </span><span class=cFE>2</span><span class=cF0> &gt; </span><span class=cFE>0</span><span class=cF0>)
<a name="l662"></a> o-&gt;DzDt -= GRAVITY_ACCELERATION * dt;
<a name="l663"></a> </span><span class=cF1>if</span><span class=cF0> (o == ball)
<a name="l664"></a> {
<a name="l665"></a> d = </span><span class=cF5>Exp</span><span class=cF0>(-AIR_VISCOSITY * dt);
<a name="l666"></a> o-&gt;DxDt *= d;
<a name="l667"></a> o-&gt;DyDt *= d;
<a name="l668"></a> o-&gt;DzDt *= d;
<a name="l669"></a> }
<a name="l670"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l671"></a> }
<a name="l672"></a> </span><span class=cF5>Refresh</span><span class=cF0>;
<a name="l673"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l674"></a>}
<a name="l675"></a>
<a name="l676"></a></span><span class=cF1>U0</span><span class=cF0> Init()
<a name="l677"></a>{
<a name="l678"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l679"></a>
<a name="l680"></a> someone_shooting = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l681"></a> shot_land_t = </span><span class=cFE>0</span><span class=cF0>;
<a name="l682"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&amp;objs, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>objs</span><span class=cF7>)</span><span class=cF0>);
<a name="l683"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; PER_SIDE_NUM*</span><span class=cFE>2</span><span class=cF0>;i++)
<a name="l684"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l685"></a> objs[i].team = i &amp; </span><span class=cFE>1</span><span class=cF0>;
<a name="l686"></a> objs[i].x = </span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_width / </span><span class=cFE>2</span><span class=cF0> ;
<a name="l687"></a> objs[i].y = </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_height / </span><span class=cFE>2</span><span class=cF0>;
<a name="l688"></a> objs[i].next_img = objs[i].last_img = FIRST_RUNNING;
<a name="l689"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l690"></a> last_owner = </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l691"></a> human = &amp;objs[</span><span class=cFE>0</span><span class=cF0>];
<a name="l692"></a> ball =&amp;objs[i];
<a name="l693"></a> ball-&gt;team = -</span><span class=cFE>1</span><span class=cF0>;
<a name="l694"></a> ball-&gt;x = </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0> * </span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_width / </span><span class=cFE>2</span><span class=cF0>;
<a name="l695"></a> ball-&gt;y = </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0> * </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF5>Fs</span><span class=cF0>-&gt;pix_height / </span><span class=cFE>2</span><span class=cF0>;
<a name="l696"></a> ball-&gt;radius = </span><span class=cFE>11</span><span class=cF0>;
<a name="l697"></a> ball-&gt;z = ball-&gt;radius;
<a name="l698"></a> score0 = score1 = </span><span class=cFE>0</span><span class=cF0>;
<a name="l699"></a> game_t_end = </span><span class=cF5>tS</span><span class=cF0> + </span><span class=cFE>3</span><span class=cF0> * </span><span class=cFE>60</span><span class=cF0>;
<a name="l700"></a> foul_t_end = </span><span class=cFE>0</span><span class=cF0>;
<a name="l701"></a>}
<a name="l702"></a>
<a name="l703"></a></span><span class=cF1>U0</span><span class=cF0> KeepAway()
<a name="l704"></a>{
<a name="l705"></a> </span><span class=cF9>I64</span><span class=cF0> message_code, arg1, arg2;
<a name="l706"></a>
<a name="l707"></a> </span><span class=cF5>PopUpOk</span><span class=cF0>( </span><span class=cF6>&quot;Pass or hand-off to your team to score points.$FG$\n\n&quot;</span><span class=cF0>
<a name="l708"></a> </span><span class=cF6>&quot;\t2 points for successful hand-off.\n&quot;</span><span class=cF0>
<a name="l709"></a> </span><span class=cF6>&quot;\t6 points for successful pass.\n&quot;</span><span class=cF0>
<a name="l710"></a> </span><span class=cF6>&quot;\t1 point penalty for foul.\n\n&quot;</span><span class=cF0>
<a name="l711"></a> </span><span class=cF6>&quot;Left-Click\tto pass.\n\n&quot;</span><span class=cF0>
<a name="l712"></a> </span><span class=cF6>&quot;Right-Click\tto jump.\n&quot;</span><span class=cF0>);
<a name="l713"></a> </span><span class=cF5>SettingsPush</span><span class=cF0>; </span><span class=cF2>//See </span><a href="https://zeal-operating-system.github.io/ZealOS/System/TaskSettings.CC.html#l3"><span class=cF4>SettingsPush</span></a><span class=cF0>
<a name="l714"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;text_attr = </span><span class=cF3>BLACK</span><span class=cF0> + </span><span class=cF3>YELLOW</span><span class=cF0> &lt;&lt; </span><span class=cFE>4</span><span class=cF0>;
<a name="l715"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;win_inhibit |= </span><span class=cF3>WIG_DBL_CLICK</span><span class=cF0>;
<a name="l716"></a> </span><span class=cF5>AutoComplete</span><span class=cF0>;
<a name="l717"></a> </span><span class=cF5>WinBorder</span><span class=cF0>;
<a name="l718"></a> </span><span class=cF5>WinMax</span><span class=cF0>;
<a name="l719"></a> </span><span class=cF5>DocCursor</span><span class=cF0>;
<a name="l720"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
<a name="l721"></a>
<a name="l722"></a> </span><span class=cF5>MenuPush</span><span class=cF0>( </span><span class=cF6>&quot;File {&quot;</span><span class=cF0>
<a name="l723"></a> </span><span class=cF6>&quot; Abort(,CH_SHIFT_ESC);&quot;</span><span class=cF0>
<a name="l724"></a> </span><span class=cF6>&quot; Exit(,CH_ESC);&quot;</span><span class=cF0>
<a name="l725"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l726"></a> </span><span class=cF6>&quot;Play {&quot;</span><span class=cF0>
<a name="l727"></a> </span><span class=cF6>&quot; Restart(,'\n');&quot;</span><span class=cF0>
<a name="l728"></a> </span><span class=cF6>&quot; Shoot(,CH_SPACE);&quot;</span><span class=cF0>
<a name="l729"></a> </span><span class=cF6>&quot; Jump(,'j');&quot;</span><span class=cF0>
<a name="l730"></a> </span><span class=cF6>&quot;}&quot;</span><span class=cF0>
<a name="l731"></a> );
<a name="l732"></a>
<a name="l733"></a> Init;
<a name="l734"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;draw_it = &amp;</span><span class=cF5>DrawIt</span><span class=cF0>;
<a name="l735"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;animate_task = </span><span class=cF5>Spawn</span><span class=cF0>(&amp;AnimateTask, </span><span class=cF5>Fs</span><span class=cF0>, </span><span class=cF6>&quot;Animate&quot;</span><span class=cF0>,, </span><span class=cF5>Fs</span><span class=cF0>);
<a name="l736"></a>
<a name="l737"></a> </span><span class=cF1>try</span><span class=cF0>
<a name="l738"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l739"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l740"></a> {
<a name="l741"></a> message_code = </span><span class=cF5>MessageGet</span><span class=cF0>(&amp;arg1, &amp;arg2, </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cF3>MESSAGE_MS_L_DOWN</span><span class=cF0> | </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cF3>MESSAGE_MS_R_DOWN</span><span class=cF0> | </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cF3>MESSAGE_KEY_DOWN</span><span class=cF0>);
<a name="l742"></a> </span><span class=cF1>switch</span><span class=cF0> (message_code)
<a name="l743"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l744"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MESSAGE_MS_L_DOWN</span><span class=cF0>:
<a name="l745"></a>ka_shoot:
<a name="l746"></a> Shoot(human);
<a name="l747"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l748"></a>
<a name="l749"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MESSAGE_MS_R_DOWN</span><span class=cF0>:
<a name="l750"></a>ka_jump:
<a name="l751"></a> human-&gt;DzDt = JUMP_VELOCITY;
<a name="l752"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l753"></a>
<a name="l754"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MESSAGE_KEY_DOWN</span><span class=cF0>:
<a name="l755"></a> </span><span class=cF1>switch</span><span class=cF0> (arg1)
<a name="l756"></a> {
<a name="l757"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\n'</span><span class=cF0>:
<a name="l758"></a> Init;
<a name="l759"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l760"></a>
<a name="l761"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'j'</span><span class=cF0>:
<a name="l762"></a> </span><span class=cF1>goto</span><span class=cF0> ka_jump;
<a name="l763"></a>
<a name="l764"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SPACE</span><span class=cF0>:
<a name="l765"></a> </span><span class=cF1>goto</span><span class=cF0> ka_shoot;
<a name="l766"></a>
<a name="l767"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0>:
<a name="l768"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_ESC</span><span class=cF0>:
<a name="l769"></a> </span><span class=cF1>goto</span><span class=cF0> ka_done;
<a name="l770"></a> }
<a name="l771"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l772"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l773"></a> }
<a name="l774"></a>ka_done: </span><span class=cF2>//Don't goto out of try</span><span class=cF0>
<a name="l775"></a> </span><span class=cF5>MessageGet</span><span class=cF0>(,, </span><span class=cFE>1</span><span class=cF0> &lt;&lt; </span><span class=cF3>MESSAGE_KEY_UP</span><span class=cF0>);
<a name="l776"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l777"></a> </span><span class=cF1>catch</span><span class=cF0>
<a name="l778"></a> </span><span class=cF5>PutExcept</span><span class=cF0>;
<a name="l779"></a> </span><span class=cF5>SettingsPop</span><span class=cF0>;
<a name="l780"></a> </span><span class=cF5>MenuPop</span><span class=cF0>;
<a name="l781"></a> </span><span class=cF5>RegWrite</span><span class=cF0>(</span><span class=cF6>&quot;ZealOS/KeepAway&quot;</span><span class=cF0>, </span><span class=cF6>&quot;I64 best_score0=%d,best_score1=%d;\n&quot;</span><span class=cF0>, best_score0, best_score1);
<a name="l782"></a>}
</span></pre></body>
</html>