mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-28 08:16:31 +00:00
22e3d8f06e
Remove some palettes. Add PaletteSetSlate. Change all gr_palette_std to gr32_palette_std. Change all CBGR48 to CBGR24.
833 lines
81 KiB
HTML
Executable file
833 lines
81 KiB
HTML
Executable file
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
|
|
<meta name="generator" content="ZealOS V0.11">
|
|
<style type="text/css">
|
|
body {background-color:#fef1f0;}
|
|
.cE0{color:#000000;background-color:#c7ab00;}
|
|
.cEA{color:#82bc49;background-color:#c7ab00;}
|
|
.cF0{color:#000000;background-color:#fef1f0;}
|
|
.cF1{color:#0148a4;background-color:#fef1f0;}
|
|
.cF2{color:#3b7901;background-color:#fef1f0;}
|
|
.cF3{color:#057c7e;background-color:#fef1f0;}
|
|
.cF4{color:#bb2020;background-color:#fef1f0;}
|
|
.cF5{color:#9e42ae;background-color:#fef1f0;}
|
|
.cF6{color:#b57901;background-color:#fef1f0;}
|
|
.cF7{color:#b2b6af;background-color:#fef1f0;}
|
|
.cF8{color:#555753;background-color:#fef1f0;}
|
|
.cF9{color:#678fbb;background-color:#fef1f0;}
|
|
.cFA{color:#82bc49;background-color:#fef1f0;}
|
|
.cFB{color:#0097a2;background-color:#fef1f0;}
|
|
.cFC{color:#e26a6a;background-color:#fef1f0;}
|
|
.cFD{color:#c671bc;background-color:#fef1f0;}
|
|
.cFE{color:#c7ab00;background-color:#fef1f0;}
|
|
.cFF{color:#fef1f0;background-color:#fef1f0;}
|
|
</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><1>/* 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><2>/* 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><3>/* 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><4>/* 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><5>/* 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><6>/* 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><7>/* 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><8>/* 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><9>/* 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><10>/* 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><11>/* 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><12>/* 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><13>/* 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><14>/* 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><15>/* 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><16>/* 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><17>/* 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><18>/* 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><19>/* 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><20>/* 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><21>/* 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><22>/* 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><23>/* 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><6></span><span class=cF0>, </span><span class=cFA><7></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><2></span><span class=cF0>, </span><span class=cFA><3></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><6></span><span class=cF0>, </span><span class=cFA><7></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><4></span><span class=cF0>, </span><span class=cFA><5></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><8></span><span class=cF0>, </span><span class=cFA><9></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><10></span><span class=cF0>, </span><span class=cFA><11></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><12></span><span class=cF0>, </span><span class=cFA><13></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><12></span><span class=cF0>, </span><span class=cFA><13></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><14></span><span class=cF0>, </span><span class=cFA><15></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><20></span><span class=cF0>, </span><span class=cFA><21></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><16></span><span class=cF0>, </span><span class=cFA><17></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><20></span><span class=cF0>, </span><span class=cFA><21></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><18></span><span class=cF0>, </span><span class=cFA><19></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><20></span><span class=cF0>, </span><span class=cFA><21></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><22></span><span class=cF0>, </span><span class=cFA><23></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>"ZealOS/KeepAway"</span><span class=cF0>, </span><span class=cF6>"I64 best_score0=0,best_score1=9999;\n"</span><span class=cF0>);
|
|
<a name="l221"></a></span><span class=cF5>RegExe</span><span class=cF0>(</span><span class=cF6>"ZealOS/KeepAway"</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->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->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->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->x, o->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->x, o->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->x, </span><span class=cF7>(</span><span class=cF0>o->y - o->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->y, </span><span class=cFA><1></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->last_t0</span><span class=cF7>)</span><span class=cF0> / </span><span class=cF7>(</span><span class=cF0>o->next_t0 - o->last_t0</span><span class=cF7>)</span><span class=cF0>,
|
|
<a name="l271"></a> imgs[o->last_img].img[o->team],
|
|
<a name="l272"></a> imgs[o->next_img].img[o->team]);
|
|
<a name="l273"></a> </span><span class=cF5>Sprite3YB</span><span class=cF0>(dc, o->x, </span><span class=cF7>(</span><span class=cF0>o->y - o->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->y, tmps, o->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->y - o2->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->ls.x = </span><span class=cFE>10000</span><span class=cF0>;
|
|
<a name="l291"></a> dc->ls.y = </span><span class=cFE>60000</span><span class=cF0>;
|
|
<a name="l292"></a> dc->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>(&dc->ls);
|
|
<a name="l294"></a> dc->ls.x *= d;
|
|
<a name="l295"></a> dc->ls.y *= d;
|
|
<a name="l296"></a> dc->ls.z *= d;
|
|
<a name="l297"></a>
|
|
<a name="l298"></a> dc->thick = </span><span class=cFE>2</span><span class=cF0>;
|
|
<a name="l299"></a> dc->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->pix_width - </span><span class=cFE>1</span><span class=cF0> - COURT_BORDER,
|
|
<a name="l302"></a> task->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 < OBJS_NUM; i++)
|
|
<a name="l304"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l305"></a> o = o_sort[i] = &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->has_ball)
|
|
<a name="l309"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l310"></a> ball->x = o->x + HAND_X_OFFSET * </span><span class=cF5>Cos</span><span class=cF0>(o->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->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->y = o->y + HAND_X_OFFSET * </span><span class=cF5>Sin</span><span class=cF0>(o->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->theta) / </span><span class=cFE>2</span><span class=cF0>;
|
|
<a name="l313"></a> </span><span class=cF1>if</span><span class=cF0> (ball->z + ball->radius * </span><span class=cFE>2</span><span class=cF0> > o->z + HAND_Z_OFFSET)
|
|
<a name="l314"></a> ball->z = o->z + HAND_Z_OFFSET - ball->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->shooting)
|
|
<a name="l317"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l318"></a> ball->x = o->x;
|
|
<a name="l319"></a> ball->y = o->y;
|
|
<a name="l320"></a> ball->z = o->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 > o->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->has_ball && </span><span class=cF7>(</span><span class=cF0>ball->z + ball->radius * </span><span class=cFE>2</span><span class=cF0> >= o->z + HAND_Z_OFFSET || </span><span class=cF5>Abs</span><span class=cF0>(ball->DzDt) < </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->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->z + HAND_Z_OFFSET - ball->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->last_t0 = tt;
|
|
<a name="l337"></a> o->last_img = o->next_img++;
|
|
<a name="l338"></a> </span><span class=cF1>if</span><span class=cF0> (o->stopped)
|
|
<a name="l339"></a> {
|
|
<a name="l340"></a> </span><span class=cF1>if</span><span class=cF0> (o->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 <= o->next_img <= LAST_STOPPED_DRIBBLING</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l343"></a> o->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->next_img = FIRST_STANDING;
|
|
<a name="l347"></a> o->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->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 <= o->last_img <= LAST_SHOOTING</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l352"></a> o->next_img = FIRST_SHOOTING;
|
|
<a name="l353"></a> </span><span class=cF1>if</span><span class=cF0> (o->next_img > LAST_SHOOTING)
|
|
<a name="l354"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l355"></a> o->next_img = FIRST_STANDING;
|
|
<a name="l356"></a> someone_has_ball = someone_shooting = o->has_ball = o->shooting = </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l357"></a> ball->DxDt = o->DxDt + SHOT_VELOCITY / </span><span class=cF3>sqrt2</span><span class=cF0> * </span><span class=cF5>Cos</span><span class=cF0>(o->theta - </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>);
|
|
<a name="l358"></a> ball->DyDt = o->DyDt + SHOT_VELOCITY / </span><span class=cF3>sqrt2</span><span class=cF0> * </span><span class=cF5>Sin</span><span class=cF0>(o->theta - </span><span class=cF3>pi</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>);
|
|
<a name="l359"></a> ball->DzDt = o->DzDt + SHOT_VELOCITY / </span><span class=cF3>sqrt2</span><span class=cF0>;
|
|
<a name="l360"></a> shot_land_t = tt + (ball->DzDt + </span><span class=cF5>Sqrt</span><span class=cF7>(</span><span class=cF5>Sqr</span><span class=cF0>(ball->DzDt) +
|
|
<a name="l361"></a> </span><span class=cFE>2</span><span class=cF0> * GRAVITY_ACCELERATION * ball->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->DxDt = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l366"></a> ball->DyDt = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l367"></a> ball->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->has_ball)
|
|
<a name="l371"></a> {
|
|
<a name="l372"></a> </span><span class=cF1>if</span><span class=cF0> (FIRST_RUNNING <= o->next_img <= LAST_RUNNING)
|
|
<a name="l373"></a> o->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 <= o->next_img <= LAST_DRIBBLING</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l375"></a> o->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 <= o->next_img <= LAST_DRIBBLING)
|
|
<a name="l380"></a> o->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 <= o->next_img <= LAST_RUNNING</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l382"></a> o->next_img = FIRST_RUNNING;
|
|
<a name="l383"></a> }
|
|
<a name="l384"></a> o->next_t0 += imgs[o->last_img].dt;
|
|
<a name="l385"></a> </span><span class=cF1>if</span><span class=cF0> (o->next_t0 <= tt)
|
|
<a name="l386"></a> o->next_t0 = tt + imgs[o->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, &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 < 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 <= </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->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->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> >> </span><span class=cFE>1</span><span class=cF0>,
|
|
<a name="l401"></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> >> </span><span class=cFE>1</span><span class=cF0>, </span><span class=cF6>"Game Over"</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> < foul_t_end)
|
|
<a name="l406"></a> {
|
|
<a name="l407"></a> dc->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->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> >> </span><span class=cFE>1</span><span class=cF0>,
|
|
<a name="l410"></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> >> </span><span class=cFE>1</span><span class=cF0>, </span><span class=cF6>"Foul"</span><span class=cF0>);
|
|
<a name="l411"></a> }
|
|
<a name="l412"></a> dc->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>"Time:%d:%04.1f Score:"</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>"Best Score:"</span><span class=cF0>);
|
|
<a name="l416"></a>
|
|
<a name="l417"></a> dc->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>"%02d"</span><span class=cF0>, score0);
|
|
<a name="l419"></a> dc->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>"%02d"</span><span class=cF0>, score1);
|
|
<a name="l421"></a>
|
|
<a name="l422"></a> dc->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>"%02d"</span><span class=cF0>, best_score0);
|
|
<a name="l424"></a> dc->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>"%02d"</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 && o->has_ball)
|
|
<a name="l431"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l432"></a> someone_shooting = o->stopped = o->shooting = </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l433"></a> o->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> MyNoise(</span><span class=cF9>I64</span><span class=cF0> mS, </span><span class=cF1>F64</span><span class=cF0> min_ona, </span><span class=cF1>F64</span><span class=cF0> max_ona)
|
|
<a name="l438"></a>{</span><span class=cF2>//Make white noise for given number of mS.</span><span class=cF0>
|
|
<a name="l439"></a></span><span class=cF2>// See </span><a href="https://zeal-operating-system.github.io/ZealOS/System/Sound.CC.html#l432"><span class=cF4>Noise</span></a><span class=cF2>. On bare-metal, Spawn() hogs CPU.</span><span class=cF0>
|
|
<a name="l440"></a> </span><span class=cF9>CSoundEffectFrame</span><span class=cF0> *ns;
|
|
<a name="l441"></a>
|
|
<a name="l442"></a> </span><span class=cF1>if</span><span class=cF0> (mS > </span><span class=cFE>0</span><span class=cF0>)
|
|
<a name="l443"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l444"></a> ns = </span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CSoundEffectFrame</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l445"></a> ns->type = </span><span class=cF3>SE_NOISE</span><span class=cF0>;
|
|
<a name="l446"></a> ns->duration = mS / </span><span class=cFE>1000</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l447"></a> ns->ona1 = min_ona;
|
|
<a name="l448"></a> ns->ona2 = max_ona;
|
|
<a name="l449"></a> </span><span class=cFB>music</span><span class=cF0>.mute++;
|
|
<a name="l450"></a> </span><span class=cF5>SoundEffectTask</span><span class=cF0>(ns);
|
|
<a name="l451"></a> </span><span class=cF5>Sound</span><span class=cF0>;
|
|
<a name="l452"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l453"></a>
|
|
<a name="l454"></a> </span><span class=cF1>return</span><span class=cF0>;
|
|
<a name="l455"></a>}
|
|
<a name="l456"></a>
|
|
<a name="l457"></a></span><span class=cF1>U0</span><span class=cF0> AnimateTask(</span><span class=cF9>CTask</span><span class=cF0> *parent_task)
|
|
<a name="l458"></a>{
|
|
<a name="l459"></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="l460"></a> </span><span class=cF9>I64</span><span class=cF0> i, j;
|
|
<a name="l461"></a> </span><span class=cF1>Bool</span><span class=cF0> gets_ball;
|
|
<a name="l462"></a> Obj *o, *nearest_ball[</span><span class=cFE>2</span><span class=cF0>];
|
|
<a name="l463"></a>
|
|
<a name="l464"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
|
|
<a name="l465"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l466"></a> dt = </span><span class=cF5>tS</span><span class=cF0> - t0;
|
|
<a name="l467"></a> t0 = </span><span class=cF5>tS</span><span class=cF0>;
|
|
<a name="l468"></a>
|
|
<a name="l469"></a> </span><span class=cF1>if</span><span class=cF0> (game_t_end && game_t_end < t0)
|
|
<a name="l470"></a> {
|
|
<a name="l471"></a> game_t_end = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l472"></a> </span><span class=cF5>Beep</span><span class=cF0>;
|
|
<a name="l473"></a> </span><span class=cF1>if</span><span class=cF0> (score0 - score1 > best_score0 - best_score1)
|
|
<a name="l474"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l475"></a> best_score0 = score0;
|
|
<a name="l476"></a> best_score1 = score1;
|
|
<a name="l477"></a> </span><span class=cF5>Sound</span><span class=cF0>(</span><span class=cFE>86</span><span class=cF0>);
|
|
<a name="l478"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>100</span><span class=cF0>);
|
|
<a name="l479"></a> </span><span class=cF5>Sound</span><span class=cF0>;
|
|
<a name="l480"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>100</span><span class=cF0>);
|
|
<a name="l481"></a> </span><span class=cF5>Sound</span><span class=cF0>(</span><span class=cFE>86</span><span class=cF0>);
|
|
<a name="l482"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>100</span><span class=cF0>);
|
|
<a name="l483"></a> </span><span class=cF5>Sound</span><span class=cF0>;
|
|
<a name="l484"></a> </span><span class=cF5>Sleep</span><span class=cF0>(</span><span class=cFE>100</span><span class=cF0>);
|
|
<a name="l485"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l486"></a> }
|
|
<a name="l487"></a>
|
|
<a name="l488"></a> </span><span class=cF1>if</span><span class=cF0> (game_t_end)
|
|
<a name="l489"></a> {
|
|
<a name="l490"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&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="l491"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < OBJS_NUM; i++) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l492"></a> o = &objs[i];
|
|
<a name="l493"></a> o->nearest_ball = </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l494"></a> </span><span class=cF1>if</span><span class=cF0> (o != ball)
|
|
<a name="l495"></a> {
|
|
<a name="l496"></a> d = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l497"></a> </span><span class=cF1>for</span><span class=cF0> (j = </span><span class=cFE>0</span><span class=cF0>; j < </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="l498"></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->DxDt * d + ball->x - o->x</span><span class=cF7>)</span><span class=cF0> + </span><span class=cF5>Sqr</span><span class=cF7>(</span><span class=cF0>ball->DyDt * d + ball->y - o->y</span><span class=cF7>)</span><span class=cF0>) / MAN_VELOCITY;
|
|
<a name="l499"></a> o->get_ball_dt = d;
|
|
<a name="l500"></a> o->get_ball_theta = </span><span class=cF5>Arg</span><span class=cF0>(ball->DxDt * d + ball->x - o->x, ball->DyDt * d + ball->y - o->y);
|
|
<a name="l501"></a> </span><span class=cF1>if</span><span class=cF0> (o != last_owner && !nearest_ball[o->team] || o->get_ball_dt < nearest_ball[o->team]->get_ball_dt)
|
|
<a name="l502"></a> nearest_ball[o->team] = o;
|
|
<a name="l503"></a> }
|
|
<a name="l504"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l505"></a> nearest_ball[</span><span class=cFE>0</span><span class=cF0>]->nearest_ball = </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l506"></a> nearest_ball[</span><span class=cFE>1</span><span class=cF0>]->nearest_ball = </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l507"></a>
|
|
<a name="l508"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < OBJS_NUM; i++)
|
|
<a name="l509"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l510"></a> o = &objs[i];
|
|
<a name="l511"></a> </span><span class=cF1>if</span><span class=cF0> (o == ball)
|
|
<a name="l512"></a> {
|
|
<a name="l513"></a> o->x += dt * o->DxDt;
|
|
<a name="l514"></a> o->y += dt * o->DyDt;
|
|
<a name="l515"></a> </span><span class=cF1>if</span><span class=cF0> (!someone_shooting)
|
|
<a name="l516"></a> o->z += dt * (o->DzDt - </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0> * GRAVITY_ACCELERATION * dt);
|
|
<a name="l517"></a> }
|
|
<a name="l518"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l519"></a> {
|
|
<a name="l520"></a> </span><span class=cF1>if</span><span class=cF0> (!o->has_ball)
|
|
<a name="l521"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l522"></a> </span><span class=cF1>if</span><span class=cF0> (t0 - o->stolen_t0 > </span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> && !someone_shooting)
|
|
<a name="l523"></a> {
|
|
<a name="l524"></a> dx = ball->x - o->x;
|
|
<a name="l525"></a> dy = ball->y - o->y;
|
|
<a name="l526"></a> </span><span class=cF1>if</span><span class=cF0> (dx * dx + dy * dy < HAND_SQR_OFFSET && ball->z < o->z + HAND_Z_OFFSET)
|
|
<a name="l527"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l528"></a> gets_ball = </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l529"></a> </span><span class=cF1>for</span><span class=cF0> (j = </span><span class=cFE>0</span><span class=cF0>; j < PER_SIDE_NUM * </span><span class=cFE>2</span><span class=cF0>; j++)
|
|
<a name="l530"></a> </span><span class=cF1>if</span><span class=cF0> (j != i && objs[j].has_ball)
|
|
<a name="l531"></a> {
|
|
<a name="l532"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Rand</span><span class=cF0><</span><span class=cFE>2</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> * dt)
|
|
<a name="l533"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l534"></a> objs[j].stolen_t0 = t0;
|
|
<a name="l535"></a> objs[j].has_ball = </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l536"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l537"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l538"></a> gets_ball = </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l539"></a> }
|
|
<a name="l540"></a> </span><span class=cF1>if</span><span class=cF0> (gets_ball)
|
|
<a name="l541"></a> {
|
|
<a name="l542"></a> someone_has_ball = o->has_ball = </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l543"></a> </span><span class=cF1>if</span><span class=cF0> (o != last_owner)
|
|
<a name="l544"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l545"></a> </span><span class=cF1>if</span><span class=cF0> (o->team)
|
|
<a name="l546"></a> {
|
|
<a name="l547"></a> </span><span class=cF1>if</span><span class=cF0> (t0 < shot_land_t + </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>1</span><span class=cF0>)
|
|
<a name="l548"></a> score1 += </span><span class=cFE>6</span><span class=cF0>;
|
|
<a name="l549"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l550"></a> score1 += </span><span class=cFE>2</span><span class=cF0>;
|
|
<a name="l551"></a> MyNoise(</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="l552"></a> }
|
|
<a name="l553"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l554"></a> {
|
|
<a name="l555"></a> </span><span class=cF1>if</span><span class=cF0> (t0 < shot_land_t + </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>1</span><span class=cF0>)
|
|
<a name="l556"></a> score0 += </span><span class=cFE>6</span><span class=cF0>;
|
|
<a name="l557"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l558"></a> score0 += </span><span class=cFE>2</span><span class=cF0>;
|
|
<a name="l559"></a> MyNoise(</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="l560"></a> }
|
|
<a name="l561"></a> last_owner = o;
|
|
<a name="l562"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l563"></a> }
|
|
<a name="l564"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l565"></a> }
|
|
<a name="l566"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l567"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (o != human && </span><span class=cF5>Rand</span><span class=cF0> < </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>25</span><span class=cF0> * dt)
|
|
<a name="l568"></a> Shoot(o);
|
|
<a name="l569"></a> </span><span class=cF1>if</span><span class=cF0> (!o->shooting)
|
|
<a name="l570"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l571"></a> </span><span class=cF1>if</span><span class=cF0> (o == human)
|
|
<a name="l572"></a> {
|
|
<a name="l573"></a> dx = (</span><span class=cFB>mouse</span><span class=cF0>.pos.x - parent_task->pix_left - parent_task->scroll_x) - o->x;
|
|
<a name="l574"></a> dy = (</span><span class=cFB>mouse</span><span class=cF0>.pos.y - parent_task->pix_top - parent_task->scroll_y) * </span><span class=cFE>2</span><span class=cF0> - o->y;
|
|
<a name="l575"></a> }
|
|
<a name="l576"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l577"></a> {
|
|
<a name="l578"></a> </span><span class=cF1>if</span><span class=cF0> (!someone_has_ball && o->nearest_man_dd > </span><span class=cFE>4</span><span class=cF0> * MAN_SQR_RADIUS && o->nearest_ball)
|
|
<a name="l579"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l580"></a> dx = o->DxDt = MAN_VELOCITY * </span><span class=cF5>Cos</span><span class=cF0>(o->get_ball_theta);
|
|
<a name="l581"></a> dy = o->DyDt = MAN_VELOCITY * </span><span class=cF5>Sin</span><span class=cF0>(o->get_ball_theta);
|
|
<a name="l582"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l583"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l584"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l585"></a> dx = o->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="l586"></a> dy = o->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="l587"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l588"></a> }
|
|
<a name="l589"></a> d = </span><span class=cF5>Sqrt</span><span class=cF0>(dx * dx + dy * dy);
|
|
<a name="l590"></a> </span><span class=cF1>if</span><span class=cF0> (d >= </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0>)
|
|
<a name="l591"></a> {
|
|
<a name="l592"></a> o->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="l593"></a> dx *= MAN_VELOCITY / </span><span class=cF3>sqrt2</span><span class=cF0> * dt / d;
|
|
<a name="l594"></a> dy *= MAN_VELOCITY / </span><span class=cF3>sqrt2</span><span class=cF0> * dt / d;
|
|
<a name="l595"></a> o->nearest_man_dd = </span><span class=cF3>F64_MAX</span><span class=cF0>;
|
|
<a name="l596"></a> </span><span class=cF1>for</span><span class=cF0> (j = </span><span class=cFE>0</span><span class=cF0>; j < PER_SIDE_NUM * </span><span class=cFE>2</span><span class=cF0>; j++)
|
|
<a name="l597"></a> </span><span class=cF1>if</span><span class=cF0> (j != i)
|
|
<a name="l598"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l599"></a> dx2 = objs[j].x - o->x;
|
|
<a name="l600"></a> dy2 = objs[j].y - o->y;
|
|
<a name="l601"></a> d = </span><span class=cF5>Sqr</span><span class=cF0>(dx2) + </span><span class=cF5>Sqr</span><span class=cF0>(dy2);
|
|
<a name="l602"></a> </span><span class=cF1>if</span><span class=cF0> (d < o->nearest_man_dd)
|
|
<a name="l603"></a> o->nearest_man_dd = d;
|
|
<a name="l604"></a> </span><span class=cF1>if</span><span class=cF0> (d < MAN_SQR_RADIUS)
|
|
<a name="l605"></a> {
|
|
<a name="l606"></a> </span><span class=cF1>if</span><span class=cF0> (d)
|
|
<a name="l607"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l608"></a> d = </span><span class=cF5>Sqrt</span><span class=cF0>(d);
|
|
<a name="l609"></a> dx2 /= d;
|
|
<a name="l610"></a> dy2 /= d;
|
|
<a name="l611"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l612"></a> </span><span class=cF1>if</span><span class=cF0> (t0 > o->foul_t0 + </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>15</span><span class=cF0>)
|
|
<a name="l613"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l614"></a> d = (dx - objs[j].DxDt) * dx2 + (dy - objs[j].DyDt) * dy2;
|
|
<a name="l615"></a> </span><span class=cF1>if</span><span class=cF0> (o == human && t0 > o->foul_t0 + </span><span class=cFE>1</span><span class=cF0>.</span><span class=cFE>0</span><span class=cF0> &&
|
|
<a name="l616"></a> dt && d / dt>FOUL_VELOCITY_THRESHOLD && objs[j].team)
|
|
<a name="l617"></a> {
|
|
<a name="l618"></a> MyNoise(</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="l619"></a> score1 += </span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l620"></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="l621"></a> }
|
|
<a name="l622"></a> o->foul_t0=t0;
|
|
<a name="l623"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l624"></a> }
|
|
<a name="l625"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l626"></a> </span><span class=cF1>if</span><span class=cF0> (t0 < o->foul_t0 + </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>15</span><span class=cF0>)
|
|
<a name="l627"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l628"></a> dx = -dx;
|
|
<a name="l629"></a> dy = -dy;
|
|
<a name="l630"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l631"></a> o->x += dx;
|
|
<a name="l632"></a> o->y += dy;
|
|
<a name="l633"></a> o->stopped = </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l634"></a> }
|
|
<a name="l635"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l636"></a> o->stopped = </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l637"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l638"></a> </span><span class=cF1>if</span><span class=cF0> (o->DzDt)
|
|
<a name="l639"></a> o->z += dt * (o->DzDt - </span><span class=cFE>0</span><span class=cF0>.</span><span class=cFE>5</span><span class=cF0> * GRAVITY_ACCELERATION * dt);
|
|
<a name="l640"></a> }
|
|
<a name="l641"></a>
|
|
<a name="l642"></a> </span><span class=cF1>if</span><span class=cF0> (o->x + o->radius >= parent_task->pix_width - COURT_BORDER)
|
|
<a name="l643"></a> {
|
|
<a name="l644"></a> o->x = parent_task->pix_width - COURT_BORDER - </span><span class=cFE>1</span><span class=cF0> - o->radius;
|
|
<a name="l645"></a> o->DxDt = -COLLISION_DAMP * o->DxDt;
|
|
<a name="l646"></a> </span><span class=cF1>if</span><span class=cF0> (o == ball)
|
|
<a name="l647"></a> MyNoise(</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="l648"></a> }
|
|
<a name="l649"></a> </span><span class=cF1>if</span><span class=cF0> (o->x - o->radius < COURT_BORDER)
|
|
<a name="l650"></a> {
|
|
<a name="l651"></a> o->x = COURT_BORDER + o->radius;
|
|
<a name="l652"></a> o->DxDt = -COLLISION_DAMP * o->DxDt;
|
|
<a name="l653"></a> </span><span class=cF1>if</span><span class=cF0> (o == ball)
|
|
<a name="l654"></a> MyNoise(</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="l655"></a> }
|
|
<a name="l656"></a>
|
|
<a name="l657"></a> </span><span class=cF1>if</span><span class=cF0> (o->y + o->radius * </span><span class=cFE>2</span><span class=cF0> >= </span><span class=cF7>(</span><span class=cF0>parent_task->pix_height - COURT_BORDER</span><span class=cF7>)</span><span class=cF0> * </span><span class=cFE>2</span><span class=cF0>)
|
|
<a name="l658"></a> {
|
|
<a name="l659"></a> o->y = (parent_task->pix_height - COURT_BORDER) * </span><span class=cFE>2</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0> - o->radius * </span><span class=cFE>2</span><span class=cF0>;
|
|
<a name="l660"></a> o->DyDt = -COLLISION_DAMP * o->DyDt;
|
|
<a name="l661"></a> </span><span class=cF1>if</span><span class=cF0> (o == ball)
|
|
<a name="l662"></a> MyNoise(</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="l663"></a> }
|
|
<a name="l664"></a> </span><span class=cF1>if</span><span class=cF0> (o->y - o->radius * </span><span class=cFE>2</span><span class=cF0> < </span><span class=cFE>2</span><span class=cF0> * COURT_BORDER)
|
|
<a name="l665"></a> {
|
|
<a name="l666"></a> o->y = COURT_BORDER * </span><span class=cFE>2</span><span class=cF0> + o->radius * </span><span class=cFE>2</span><span class=cF0>;
|
|
<a name="l667"></a> o->DyDt = -COLLISION_DAMP* o->DyDt;
|
|
<a name="l668"></a> </span><span class=cF1>if</span><span class=cF0> (o == ball)
|
|
<a name="l669"></a> MyNoise(</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="l670"></a> }
|
|
<a name="l671"></a>
|
|
<a name="l672"></a> </span><span class=cF1>if</span><span class=cF0> (o->z - o->radius * </span><span class=cFE>2</span><span class=cF0> < </span><span class=cFE>0</span><span class=cF0>)
|
|
<a name="l673"></a> {
|
|
<a name="l674"></a> o->z = o->radius * </span><span class=cFE>2</span><span class=cF0>;
|
|
<a name="l675"></a> o->DzDt = -COLLISION_DAMP * o->DzDt;
|
|
<a name="l676"></a> </span><span class=cF1>if</span><span class=cF0> (o->DzDt > ROLL_VELOCITY_THRESHOLD)
|
|
<a name="l677"></a> MyNoise(</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="l678"></a> </span><span class=cF1>if</span><span class=cF0> (o != ball)
|
|
<a name="l679"></a> o->DzDt = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l680"></a> }
|
|
<a name="l681"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (o->z - o->radius * </span><span class=cFE>2</span><span class=cF0> > </span><span class=cFE>0</span><span class=cF0>)
|
|
<a name="l682"></a> o->DzDt -= GRAVITY_ACCELERATION * dt;
|
|
<a name="l683"></a> </span><span class=cF1>if</span><span class=cF0> (o == ball)
|
|
<a name="l684"></a> {
|
|
<a name="l685"></a> d = </span><span class=cF5>Exp</span><span class=cF0>(-AIR_VISCOSITY * dt);
|
|
<a name="l686"></a> o->DxDt *= d;
|
|
<a name="l687"></a> o->DyDt *= d;
|
|
<a name="l688"></a> o->DzDt *= d;
|
|
<a name="l689"></a> }
|
|
<a name="l690"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l691"></a> }
|
|
<a name="l692"></a> </span><span class=cF5>Refresh</span><span class=cF0>;
|
|
<a name="l693"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l694"></a>}
|
|
<a name="l695"></a>
|
|
<a name="l696"></a></span><span class=cF1>U0</span><span class=cF0> Init()
|
|
<a name="l697"></a>{
|
|
<a name="l698"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
|
<a name="l699"></a>
|
|
<a name="l700"></a> someone_shooting = </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l701"></a> shot_land_t = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l702"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&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="l703"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i < PER_SIDE_NUM*</span><span class=cFE>2</span><span class=cF0>;i++)
|
|
<a name="l704"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l705"></a> objs[i].team = i & </span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l706"></a> objs[i].x = </span><span class=cF5>Fs</span><span class=cF0>->pix_width / </span><span class=cFE>2</span><span class=cF0> ;
|
|
<a name="l707"></a> objs[i].y = </span><span class=cFE>2</span><span class=cF0> * </span><span class=cF5>Fs</span><span class=cF0>->pix_height / </span><span class=cFE>2</span><span class=cF0>;
|
|
<a name="l708"></a> objs[i].next_img = objs[i].last_img = FIRST_RUNNING;
|
|
<a name="l709"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l710"></a> last_owner = </span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l711"></a> human = &objs[</span><span class=cFE>0</span><span class=cF0>];
|
|
<a name="l712"></a> ball =&objs[i];
|
|
<a name="l713"></a> ball->team = -</span><span class=cFE>1</span><span class=cF0>;
|
|
<a name="l714"></a> ball->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>->pix_width / </span><span class=cFE>2</span><span class=cF0>;
|
|
<a name="l715"></a> ball->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>->pix_height / </span><span class=cFE>2</span><span class=cF0>;
|
|
<a name="l716"></a> ball->radius = </span><span class=cFE>11</span><span class=cF0>;
|
|
<a name="l717"></a> ball->z = ball->radius;
|
|
<a name="l718"></a> score0 = score1 = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l719"></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="l720"></a> foul_t_end = </span><span class=cFE>0</span><span class=cF0>;
|
|
<a name="l721"></a>}
|
|
<a name="l722"></a>
|
|
<a name="l723"></a></span><span class=cF1>U0</span><span class=cF0> KeepAway()
|
|
<a name="l724"></a>{
|
|
<a name="l725"></a> </span><span class=cF9>I64</span><span class=cF0> message_code, arg1, arg2;
|
|
<a name="l726"></a>
|
|
<a name="l727"></a> </span><span class=cF5>PopUpOk</span><span class=cF0>( </span><span class=cF6>"Pass or hand-off to your team to score points.$FG$\n\n"</span><span class=cF0>
|
|
<a name="l728"></a> </span><span class=cF6>"\t2 points for successful hand-off.\n"</span><span class=cF0>
|
|
<a name="l729"></a> </span><span class=cF6>"\t6 points for successful pass.\n"</span><span class=cF0>
|
|
<a name="l730"></a> </span><span class=cF6>"\t1 point penalty for foul.\n\n"</span><span class=cF0>
|
|
<a name="l731"></a> </span><span class=cF6>"Left-Click\tto pass.\n\n"</span><span class=cF0>
|
|
<a name="l732"></a> </span><span class=cF6>"Right-Click\tto jump.\n"</span><span class=cF0>);
|
|
<a name="l733"></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="l734"></a> </span><span class=cF5>Fs</span><span class=cF0>->text_attr = </span><span class=cF3>BLACK</span><span class=cF0> + </span><span class=cF3>YELLOW</span><span class=cF0> << </span><span class=cFE>4</span><span class=cF0>;
|
|
<a name="l735"></a> </span><span class=cF5>Fs</span><span class=cF0>->win_inhibit |= </span><span class=cF3>WIG_DBL_CLICK</span><span class=cF0>;
|
|
<a name="l736"></a> </span><span class=cF5>AutoComplete</span><span class=cF0>;
|
|
<a name="l737"></a> </span><span class=cF5>WinBorder</span><span class=cF0>;
|
|
<a name="l738"></a> </span><span class=cF5>WinMax</span><span class=cF0>;
|
|
<a name="l739"></a> </span><span class=cF5>DocCursor</span><span class=cF0>;
|
|
<a name="l740"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
|
|
<a name="l741"></a>
|
|
<a name="l742"></a> </span><span class=cF5>MenuPush</span><span class=cF0>( </span><span class=cF6>"File {"</span><span class=cF0>
|
|
<a name="l743"></a> </span><span class=cF6>" Abort(,CH_SHIFT_ESC);"</span><span class=cF0>
|
|
<a name="l744"></a> </span><span class=cF6>" Exit(,CH_ESC);"</span><span class=cF0>
|
|
<a name="l745"></a> </span><span class=cF6>"}"</span><span class=cF0>
|
|
<a name="l746"></a> </span><span class=cF6>"Play {"</span><span class=cF0>
|
|
<a name="l747"></a> </span><span class=cF6>" Restart(,'\n');"</span><span class=cF0>
|
|
<a name="l748"></a> </span><span class=cF6>" Shoot(,CH_SPACE);"</span><span class=cF0>
|
|
<a name="l749"></a> </span><span class=cF6>" Jump(,'j');"</span><span class=cF0>
|
|
<a name="l750"></a> </span><span class=cF6>"}"</span><span class=cF0>
|
|
<a name="l751"></a> );
|
|
<a name="l752"></a>
|
|
<a name="l753"></a> Init;
|
|
<a name="l754"></a> </span><span class=cF5>Fs</span><span class=cF0>->draw_it = &</span><span class=cF5>DrawIt</span><span class=cF0>;
|
|
<a name="l755"></a> </span><span class=cF5>Fs</span><span class=cF0>->animate_task = </span><span class=cF5>Spawn</span><span class=cF0>(&AnimateTask, </span><span class=cF5>Fs</span><span class=cF0>, </span><span class=cF6>"Animate"</span><span class=cF0>,, </span><span class=cF5>Fs</span><span class=cF0>);
|
|
<a name="l756"></a>
|
|
<a name="l757"></a> </span><span class=cF1>try</span><span class=cF0>
|
|
<a name="l758"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l759"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>)
|
|
<a name="l760"></a> {
|
|
<a name="l761"></a> message_code = </span><span class=cF5>MessageGet</span><span class=cF0>(&arg1, &arg2, </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>MESSAGE_MS_L_DOWN</span><span class=cF0> | </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>MESSAGE_MS_R_DOWN</span><span class=cF0> | </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>MESSAGE_KEY_DOWN</span><span class=cF0>);
|
|
<a name="l762"></a> </span><span class=cF1>switch</span><span class=cF0> (message_code)
|
|
<a name="l763"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l764"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MESSAGE_MS_L_DOWN</span><span class=cF0>:
|
|
<a name="l765"></a>ka_shoot:
|
|
<a name="l766"></a> Shoot(human);
|
|
<a name="l767"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l768"></a>
|
|
<a name="l769"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MESSAGE_MS_R_DOWN</span><span class=cF0>:
|
|
<a name="l770"></a>ka_jump:
|
|
<a name="l771"></a> human->DzDt = JUMP_VELOCITY;
|
|
<a name="l772"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l773"></a>
|
|
<a name="l774"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>MESSAGE_KEY_DOWN</span><span class=cF0>:
|
|
<a name="l775"></a> </span><span class=cF1>switch</span><span class=cF0> (arg1)
|
|
<a name="l776"></a> {
|
|
<a name="l777"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\n'</span><span class=cF0>:
|
|
<a name="l778"></a> Init;
|
|
<a name="l779"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l780"></a>
|
|
<a name="l781"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'j'</span><span class=cF0>:
|
|
<a name="l782"></a> </span><span class=cF1>goto</span><span class=cF0> ka_jump;
|
|
<a name="l783"></a>
|
|
<a name="l784"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SPACE</span><span class=cF0>:
|
|
<a name="l785"></a> </span><span class=cF1>goto</span><span class=cF0> ka_shoot;
|
|
<a name="l786"></a>
|
|
<a name="l787"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0>:
|
|
<a name="l788"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_ESC</span><span class=cF0>:
|
|
<a name="l789"></a> </span><span class=cF1>goto</span><span class=cF0> ka_done;
|
|
<a name="l790"></a> }
|
|
<a name="l791"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l792"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l793"></a> }
|
|
<a name="l794"></a>ka_done: </span><span class=cF2>//Don't goto out of try</span><span class=cF0>
|
|
<a name="l795"></a> </span><span class=cF5>MessageGet</span><span class=cF0>(,, </span><span class=cFE>1</span><span class=cF0> << </span><span class=cF3>MESSAGE_KEY_UP</span><span class=cF0>);
|
|
<a name="l796"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l797"></a> </span><span class=cF1>catch</span><span class=cF0>
|
|
<a name="l798"></a> </span><span class=cF5>PutExcept</span><span class=cF0>;
|
|
<a name="l799"></a> </span><span class=cF5>SettingsPop</span><span class=cF0>;
|
|
<a name="l800"></a> </span><span class=cF5>MenuPop</span><span class=cF0>;
|
|
<a name="l801"></a> </span><span class=cF5>RegWrite</span><span class=cF0>(</span><span class=cF6>"ZealOS/KeepAway"</span><span class=cF0>, </span><span class=cF6>"I64 best_score0=%d,best_score1=%d;\n"</span><span class=cF0>, best_score0, best_score1);
|
|
<a name="l802"></a>}
|
|
</span></pre></body>
|
|
</html>
|