416 lines
32 KiB
HTML
Executable File
416 lines
32 KiB
HTML
Executable File
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="generator" content="TempleOS V5.03">
|
|
<meta name="viewport" content="width=device-width">
|
|
<link rel="stylesheet" href="/style/templeos.css">
|
|
<script src="/script/templeos.js"></script>
|
|
<style type="text/css">
|
|
.cB0{color:#000000;background-color:#55ffff;}
|
|
.cBA{color:#55ff55;background-color:#55ffff;}
|
|
.cF0{color:#000000;background-color:#ffffff;}
|
|
.cF1{color:#0000aa;background-color:#ffffff;}
|
|
.cF2{color:#00aa00;background-color:#ffffff;}
|
|
.cF3{color:#00aaaa;background-color:#ffffff;}
|
|
.cF4{color:#aa0000;background-color:#ffffff;}
|
|
.cF5{color:#aa00aa;background-color:#ffffff;}
|
|
.cF6{color:#aa5500;background-color:#ffffff;}
|
|
.cF7{color:#aaaaaa;background-color:#ffffff;}
|
|
.cF8{color:#555555;background-color:#ffffff;}
|
|
.cF9{color:#5555ff;background-color:#ffffff;}
|
|
.cFA{color:#55ff55;background-color:#ffffff;}
|
|
.cFB{color:#55ffff;background-color:#ffffff;}
|
|
.cFC{color:#ff5555;background-color:#ffffff;}
|
|
.cFD{color:#ff55ff;background-color:#ffffff;}
|
|
.cFE{color:#ffff55;background-color:#ffffff;}
|
|
.cFF{color:#ffffff;background-color:#ffffff;}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<pre id="content">
|
|
<a name="l1"></a><span class=cF0>#</span><span class=cF1>define</span><span class=cF0> MT_HOSE 1
|
|
<a name="l2"></a>#</span><span class=cF1>define</span><span class=cF0> MT_DROPLET 2
|
|
<a name="l3"></a></span><span class=cF1>class</span><span class=cF0> MyMass:</span><span class=cF9>CMass</span><span class=cF0>
|
|
<a name="l4"></a>{
|
|
<a name="l5"></a> </span><span class=cF9>I64</span><span class=cF0> type;
|
|
<a name="l6"></a> </span><span class=cF1>F64</span><span class=cF0> radius;
|
|
<a name="l7"></a>};
|
|
<a name="l8"></a>
|
|
<a name="l9"></a>#</span><span class=cF1>define</span><span class=cF0> ST_HOSE 1
|
|
<a name="l10"></a></span><span class=cF1>class</span><span class=cF0> MySpring:</span><span class=cF9>CSpring</span><span class=cF0>
|
|
<a name="l11"></a>{
|
|
<a name="l12"></a> </span><span class=cF9>I64</span><span class=cF0> type;
|
|
<a name="l13"></a>};
|
|
<a name="l14"></a></span><span class=cB0>
|
|
<a name="l15"></a>
|
|
<a name="l16"></a>
|
|
<a name="l17"></a> </span><span class=cBA><1>/* Graphics Not Rendered in HTML */</span><span class=cB0>
|
|
<a name="l18"></a>
|
|
<a name="l19"></a> </span><span class=cBA><2>/* Graphics Not Rendered in HTML */</span><span class=cB0>
|
|
<a name="l20"></a>
|
|
<a name="l21"></a> </span><span class=cBA><3>/* Graphics Not Rendered in HTML */</span><span class=cB0>
|
|
<a name="l22"></a></span><span class=cF0>
|
|
<a name="l23"></a>
|
|
<a name="l24"></a>
|
|
<a name="l25"></a>
|
|
<a name="l26"></a>
|
|
<a name="l27"></a>
|
|
<a name="l28"></a>
|
|
<a name="l29"></a>
|
|
<a name="l30"></a>
|
|
<a name="l31"></a>
|
|
<a name="l32"></a>
|
|
<a name="l33"></a>
|
|
<a name="l34"></a>
|
|
<a name="l35"></a>
|
|
<a name="l36"></a></span><span class=cFA>
|
|
<a name="l37"></a>/* Graphics Not Rendered in HTML */</span><span class=cF0>
|
|
<a name="l38"></a>
|
|
<a name="l39"></a>#</span><span class=cF1>define</span><span class=cF0> HOSE_RADIUS 3
|
|
<a name="l40"></a>#</span><span class=cF1>define</span><span class=cF0> LINK_SIZE 6
|
|
<a name="l41"></a>#</span><span class=cF1>define</span><span class=cF0> NOZZLE_START_Y (</span><span class=cF3>GR_HEIGHT</span><span class=cF0>-15*</span><span class=cF3>FONT_HEIGHT</span><span class=cF0>)
|
|
<a name="l42"></a>#</span><span class=cF1>define</span><span class=cF0> NOZZLE_LEN 18
|
|
<a name="l43"></a>#</span><span class=cF1>define</span><span class=cF0> FAUCET_X (5*HOSE_RADIUS)
|
|
<a name="l44"></a>#</span><span class=cF1>define</span><span class=cF0> FAUCET_Y (</span><span class=cF3>GR_HEIGHT</span><span class=cF0>-12*</span><span class=cF3>FONT_HEIGHT</span><span class=cF0>)
|
|
<a name="l45"></a>#</span><span class=cF1>define</span><span class=cF0> GROUND_Y (</span><span class=cF3>GR_HEIGHT</span><span class=cF0>-3*</span><span class=cF3>FONT_HEIGHT</span><span class=cF0>)
|
|
<a name="l46"></a>MyMass *faucet,*nozzle;
|
|
<a name="l47"></a></span><span class=cF1>F64</span><span class=cF0> nozzle_theta;
|
|
<a name="l48"></a>
|
|
<a name="l49"></a></span><span class=cF9>CMathODE</span><span class=cF0> *ode=</span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l50"></a></span><span class=cF1>F64</span><span class=cF0> start_up_timeout;
|
|
<a name="l51"></a>
|
|
<a name="l52"></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> *,</span><span class=cF9>CDC</span><span class=cF0> *dc)
|
|
<a name="l53"></a>{
|
|
<a name="l54"></a> </span><span class=cF1>Bool</span><span class=cF0> first;
|
|
<a name="l55"></a> </span><span class=cF1>F64</span><span class=cF0> dx,dy,d;
|
|
<a name="l56"></a> </span><span class=cF9>I64</span><span class=cF0> x1b,y1b,x2b,y2b,
|
|
<a name="l57"></a> x1a,y1a,x2a,y2a;
|
|
<a name="l58"></a> MyMass *tmpm,*tmpm1;
|
|
<a name="l59"></a> MySpring *tmps;
|
|
<a name="l60"></a> </span><span class=cF9>CD3I32</span><span class=cF0> poly[4];
|
|
<a name="l61"></a>
|
|
<a name="l62"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc,0,GROUND_Y,0,</span><span class=cFA><4></span><span class=cF0>);
|
|
<a name="l63"></a> </span><span class=cF1>if</span><span class=cF0> (start_up_timeout></span><span class=cF5>tS</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l64"></a> ode->drag_v2=0.01; </span><span class=cF2>//Let hose settle during start-up</span><span class=cF0>
|
|
<a name="l65"></a> ode->drag_v3=0.0001;
|
|
<a name="l66"></a> dc->color=</span><span class=cF3>RED</span><span class=cF0>;
|
|
<a name="l67"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc,</span><span class=cF7>(</span><span class=cF3>GR_WIDTH</span><span class=cF0>-</span><span class=cF3>FONT_WIDTH</span><span class=cF0>*6</span><span class=cF7>)</span><span class=cF0>>>1,</span><span class=cF3>GR_HEIGHT</span><span class=cF0>>>1,</span><span class=cF6>"Squirt"</span><span class=cF0>);
|
|
<a name="l68"></a> </span><span class=cF1>return</span><span class=cF0>;
|
|
<a name="l69"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l70"></a> ode->drag_v2=0.0005;
|
|
<a name="l71"></a> ode->drag_v3=0.0000025;
|
|
<a name="l72"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l73"></a>
|
|
<a name="l74"></a> tmpm=faucet;
|
|
<a name="l75"></a> dc->color=</span><span class=cF3>BLACK</span><span class=cF0>;
|
|
<a name="l76"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc,tmpm->x+8,tmpm->y,8,GROUND_Y-FAUCET_Y);
|
|
<a name="l77"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc,tmpm->x,tmpm->y,0,</span><span class=cFA><1></span><span class=cF0>);
|
|
<a name="l78"></a> dc->color=</span><span class=cF3>BLACK</span><span class=cF0>;
|
|
<a name="l79"></a> </span><span class=cF5>GrCircle</span><span class=cF0>(dc,tmpm->x,tmpm->y,tmpm->radius);
|
|
<a name="l80"></a> dc->color=</span><span class=cF3>GREEN</span><span class=cF0>;
|
|
<a name="l81"></a> </span><span class=cF5>GrFloodFill</span><span class=cF0>(dc,tmpm->x,tmpm->y);
|
|
<a name="l82"></a>
|
|
<a name="l83"></a> tmpm=nozzle;
|
|
<a name="l84"></a> tmpm1=nozzle->last;
|
|
<a name="l85"></a> dx=tmpm->x-tmpm1->x;
|
|
<a name="l86"></a> dy=tmpm->y-tmpm1->y;
|
|
<a name="l87"></a> nozzle_theta=</span><span class=cF5>Wrap</span><span class=cF0>(</span><span class=cF5>Arg</span><span class=cF7>(</span><span class=cF0>dx,dy</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l88"></a> </span><span class=cF5>Sprite3ZB</span><span class=cF0>(dc,tmpm->x,tmpm->y,0,</span><span class=cFA><2></span><span class=cF0>,nozzle_theta);
|
|
<a name="l89"></a> dc->color=</span><span class=cF3>BLACK</span><span class=cF0>;
|
|
<a name="l90"></a> </span><span class=cF5>GrCircle</span><span class=cF0>(dc,tmpm->x,tmpm->y,tmpm->radius);
|
|
<a name="l91"></a> dc->color=</span><span class=cF3>GREEN</span><span class=cF0>;
|
|
<a name="l92"></a> </span><span class=cF5>GrFloodFill</span><span class=cF0>(dc,tmpm->x,tmpm->y);
|
|
<a name="l93"></a>
|
|
<a name="l94"></a> first=</span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l95"></a> tmpm=ode->next_mass;
|
|
<a name="l96"></a> </span><span class=cF1>while</span><span class=cF0> (tmpm!=&ode->next_mass) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l97"></a> </span><span class=cF1>if</span><span class=cF0> (tmpm->type==MT_HOSE) {
|
|
<a name="l98"></a> tmpm1=tmpm->last;
|
|
<a name="l99"></a> dx=tmpm->x-tmpm1->x;
|
|
<a name="l100"></a> dy=tmpm->y-tmpm1->y;
|
|
<a name="l101"></a> d=HOSE_RADIUS/</span><span class=cF5>Max</span><span class=cF0>(</span><span class=cF5>Sqrt</span><span class=cF7>(</span><span class=cF0>dx*dx+dy*dy</span><span class=cF7>)</span><span class=cF0>,0.001);
|
|
<a name="l102"></a> dx*=d;
|
|
<a name="l103"></a> dy*=d;
|
|
<a name="l104"></a> x2a=tmpm->x-dy;
|
|
<a name="l105"></a> y2a=tmpm->y+dx;
|
|
<a name="l106"></a> x2b=tmpm->x+dy;
|
|
<a name="l107"></a> y2b=tmpm->y-dx;
|
|
<a name="l108"></a>
|
|
<a name="l109"></a> </span><span class=cF1>if</span><span class=cF0> (first)
|
|
<a name="l110"></a> first=</span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l111"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l112"></a> dc->color=</span><span class=cF3>GREEN</span><span class=cF0>;
|
|
<a name="l113"></a> poly[0].x=x1a;
|
|
<a name="l114"></a> poly[0].y=y1a;
|
|
<a name="l115"></a> poly[0].z=0;
|
|
<a name="l116"></a> poly[1].x=x2a;
|
|
<a name="l117"></a> poly[1].y=y2a;
|
|
<a name="l118"></a> poly[1].z=0;
|
|
<a name="l119"></a> poly[2].x=x2b;
|
|
<a name="l120"></a> poly[2].y=y2b;
|
|
<a name="l121"></a> poly[2].z=0;
|
|
<a name="l122"></a> poly[3].x=x1b;
|
|
<a name="l123"></a> poly[3].y=y1b;
|
|
<a name="l124"></a> poly[3].z=0;
|
|
<a name="l125"></a> </span><span class=cF5>GrFillPoly3</span><span class=cF0>(dc,4,poly);
|
|
<a name="l126"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l127"></a>
|
|
<a name="l128"></a> </span><span class=cF2>//Fill gaps</span><span class=cF0>
|
|
<a name="l129"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc,x2a,y2a,x2b,y2b);
|
|
<a name="l130"></a>
|
|
<a name="l131"></a> x1a=x2a;
|
|
<a name="l132"></a> y1a=y2a;
|
|
<a name="l133"></a> x1b=x2b;
|
|
<a name="l134"></a> y1b=y2b;
|
|
<a name="l135"></a> } </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (tmpm->type==MT_DROPLET)
|
|
<a name="l136"></a> </span><span class=cF5>Sprite3</span><span class=cF0>(dc,tmpm->x,tmpm->y,0,</span><span class=cFA><3></span><span class=cF0>);
|
|
<a name="l137"></a> tmpm=tmpm->next;
|
|
<a name="l138"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l139"></a>
|
|
<a name="l140"></a> tmps=ode->next_spring;
|
|
<a name="l141"></a> </span><span class=cF1>while</span><span class=cF0> (tmps!=&ode->next_spring) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l142"></a> </span><span class=cF1>if</span><span class=cF0> (tmps->type==ST_HOSE) {
|
|
<a name="l143"></a> dx=tmps->end1->x-tmps->end2->x;
|
|
<a name="l144"></a> dy=tmps->end1->y-tmps->end2->y;
|
|
<a name="l145"></a> d=HOSE_RADIUS/</span><span class=cF5>Max</span><span class=cF0>(</span><span class=cF5>Sqrt</span><span class=cF7>(</span><span class=cF0>dx*dx+dy*dy</span><span class=cF7>)</span><span class=cF0>,0.001);
|
|
<a name="l146"></a> dx*=d;
|
|
<a name="l147"></a> dy*=d;
|
|
<a name="l148"></a> dc->color=</span><span class=cF3>BLACK</span><span class=cF0>;
|
|
<a name="l149"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc,tmps->end1->x-dy,tmps->end1->y+dx,
|
|
<a name="l150"></a> tmps->end2->x-dy,tmps->end2->y+dx);
|
|
<a name="l151"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc,tmps->end1->x+dy,tmps->end1->y-dx,
|
|
<a name="l152"></a> tmps->end2->x+dy,tmps->end2->y-dx);
|
|
<a name="l153"></a> }
|
|
<a name="l154"></a> tmps=tmps->next;
|
|
<a name="l155"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l156"></a>}
|
|
<a name="l157"></a>
|
|
<a name="l158"></a></span><span class=cF1>U0</span><span class=cF0> MyDerivative(</span><span class=cF9>CMathODE</span><span class=cF0> *ode,</span><span class=cF1>F64</span><span class=cF0> t,</span><span class=cF9>COrder2D3</span><span class=cF0> *state,</span><span class=cF9>COrder2D3</span><span class=cF0> *DstateDt)
|
|
<a name="l159"></a>{</span><span class=cF2>//The forces due to springs and drag are</span><span class=cF0>
|
|
<a name="l160"></a></span><span class=cF2>//automatically handled by the</span><span class=cF0>
|
|
<a name="l161"></a> </span><span class=cF2>//ode code. We can add new forces</span><span class=cF0>
|
|
<a name="l162"></a> </span><span class=cF2>//here.</span><span class=cF0>
|
|
<a name="l163"></a> </span><span class=cF1>no_warn</span><span class=cF0> t,state,DstateDt;
|
|
<a name="l164"></a> MyMass *tmpm1=ode->next_mass;
|
|
<a name="l165"></a> </span><span class=cF1>while</span><span class=cF0> (tmpm1!=&ode->next_mass) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l166"></a> </span><span class=cF1>if</span><span class=cF0> (tmpm1->type==MT_HOSE) {
|
|
<a name="l167"></a> </span><span class=cF1>if</span><span class=cF0> (tmpm1->state->y+tmpm1->radius>GROUND_Y)
|
|
<a name="l168"></a> tmpm1->DstateDt->DyDt-=</span><span class=cF5>Sqr</span><span class=cF0>(</span><span class=cF5>Sqr</span><span class=cF7>(</span><span class=cF0>tmpm1->state->y+
|
|
<a name="l169"></a> tmpm1->radius-GROUND_Y</span><span class=cF7>)</span><span class=cF0>)*tmpm1->mass;
|
|
<a name="l170"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l171"></a> tmpm1->DstateDt->DyDt+=500*tmpm1->mass;
|
|
<a name="l172"></a> </span><span class=cF1>if</span><span class=cF0> (tmpm1==nozzle || tmpm1==faucet) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l173"></a> tmpm1->DstateDt->DxDt=0;
|
|
<a name="l174"></a> tmpm1->DstateDt->DyDt=0;
|
|
<a name="l175"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l176"></a> } </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (tmpm1->type==MT_DROPLET)
|
|
<a name="l177"></a> tmpm1->DstateDt->DyDt=500*tmpm1->mass;
|
|
<a name="l178"></a> tmpm1=tmpm1->next;
|
|
<a name="l179"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l180"></a>}
|
|
<a name="l181"></a>
|
|
<a name="l182"></a>MyMass *PlaceMass(</span><span class=cF9>I64</span><span class=cF0> type,</span><span class=cF9>I64</span><span class=cF0> x, </span><span class=cF9>I64</span><span class=cF0> y,</span><span class=cF1>F64</span><span class=cF0> r,
|
|
<a name="l183"></a> </span><span class=cF1>F64</span><span class=cF0> dx,</span><span class=cF1>F64</span><span class=cF0> dy,</span><span class=cF1>F64</span><span class=cF0> mass,</span><span class=cF9>CTask</span><span class=cF0> *mem_task)
|
|
<a name="l184"></a>{
|
|
<a name="l185"></a> MyMass *tmpm=</span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>MyMass</span><span class=cF7>)</span><span class=cF0>,mem_task);
|
|
<a name="l186"></a> tmpm->type=type;
|
|
<a name="l187"></a> tmpm->mass=mass;
|
|
<a name="l188"></a> tmpm->drag_profile_factor=250.0;
|
|
<a name="l189"></a> tmpm->x=x;
|
|
<a name="l190"></a> tmpm->y=y;
|
|
<a name="l191"></a> tmpm->DxDt=dx;
|
|
<a name="l192"></a> tmpm->DyDt=dy;
|
|
<a name="l193"></a> tmpm->radius=r;
|
|
<a name="l194"></a> </span><span class=cF5>QueIns</span><span class=cF0>(tmpm,ode->last_mass);
|
|
<a name="l195"></a> </span><span class=cF1>return</span><span class=cF0> tmpm;
|
|
<a name="l196"></a>}
|
|
<a name="l197"></a>
|
|
<a name="l198"></a>MySpring PlaceSpring(MyMass *tmpm1,MyMass *tmpm2)
|
|
<a name="l199"></a>{
|
|
<a name="l200"></a> MySpring *tmps=</span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>MySpring</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l201"></a> tmps->end1=tmpm1;
|
|
<a name="l202"></a> tmps->end2=tmpm2;
|
|
<a name="l203"></a> tmps->const=20000;
|
|
<a name="l204"></a> </span><span class=cF5>QueIns</span><span class=cF0>(tmps,ode->last_spring);
|
|
<a name="l205"></a> </span><span class=cF1>return</span><span class=cF0> tmps;
|
|
<a name="l206"></a>}
|
|
<a name="l207"></a>
|
|
<a name="l208"></a></span><span class=cF1>U0</span><span class=cF0> HoseNew()
|
|
<a name="l209"></a>{
|
|
<a name="l210"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
|
<a name="l211"></a> MyMass *tmpm1=</span><span class=cF3>NULL</span><span class=cF0>,*tmpm;
|
|
<a name="l212"></a> MySpring *tmps;
|
|
<a name="l213"></a> </span><span class=cF1>for</span><span class=cF0> (i=FAUCET_X;i<</span><span class=cF3>GR_WIDTH</span><span class=cF0>;i+=LINK_SIZE) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l214"></a> tmpm=PlaceMass(MT_HOSE,i/2,GROUND_Y-HOSE_RADIUS,HOSE_RADIUS,0,0,1.0,</span><span class=cF5>Fs</span><span class=cF0>);
|
|
<a name="l215"></a> </span><span class=cF1>if</span><span class=cF0> (tmpm1) {
|
|
<a name="l216"></a> tmps=PlaceSpring(tmpm,tmpm1);
|
|
<a name="l217"></a> tmps->rest_len=LINK_SIZE;
|
|
<a name="l218"></a> tmps->type=ST_HOSE;
|
|
<a name="l219"></a> nozzle=tmpm;
|
|
<a name="l220"></a> } </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l221"></a> faucet=tmpm;
|
|
<a name="l222"></a> tmpm1=tmpm;
|
|
<a name="l223"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l224"></a> faucet->y=FAUCET_Y;
|
|
<a name="l225"></a> nozzle->y=NOZZLE_START_Y;
|
|
<a name="l226"></a> nozzle_theta=0;
|
|
<a name="l227"></a>}
|
|
<a name="l228"></a>
|
|
<a name="l229"></a></span><span class=cF1>U0</span><span class=cF0> AnimateTask(</span><span class=cF9>I64</span><span class=cF0>)
|
|
<a name="l230"></a>{
|
|
<a name="l231"></a> MyMass *tmpm,*tmpm1;
|
|
<a name="l232"></a> </span><span class=cF1>F64</span><span class=cF0> dx,dy;
|
|
<a name="l233"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l234"></a> dx=</span><span class=cF5>Cos</span><span class=cF0>(nozzle_theta);
|
|
<a name="l235"></a> dy=</span><span class=cF5>Sin</span><span class=cF0>(nozzle_theta);
|
|
<a name="l236"></a> PlaceMass(MT_DROPLET,
|
|
<a name="l237"></a> nozzle->x+NOZZLE_LEN*dx,nozzle->y+NOZZLE_LEN*dy,HOSE_RADIUS,
|
|
<a name="l238"></a> 500*dx,500*dy,100.0,</span><span class=cF5>Fs</span><span class=cF0>->parent_task);
|
|
<a name="l239"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Rand</span><span class=cF0><0.05) </span><span class=cF2>//faucet drip</span><span class=cF0>
|
|
<a name="l240"></a> PlaceMass(MT_DROPLET,
|
|
<a name="l241"></a> faucet->x,faucet->y,HOSE_RADIUS,
|
|
<a name="l242"></a> 0,0,100.0,</span><span class=cF5>Fs</span><span class=cF0>->parent_task);
|
|
<a name="l243"></a>
|
|
<a name="l244"></a> tmpm=ode->next_mass;
|
|
<a name="l245"></a> </span><span class=cF1>while</span><span class=cF0> (tmpm!=&ode->next_mass) {
|
|
<a name="l246"></a> tmpm1=tmpm->next;
|
|
<a name="l247"></a> </span><span class=cF1>if</span><span class=cF0> (tmpm->type==MT_DROPLET && tmpm->y+tmpm->radius>GROUND_Y) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l248"></a> </span><span class=cF5>QueRem</span><span class=cF0>(tmpm);
|
|
<a name="l249"></a> </span><span class=cF5>Free</span><span class=cF0>(tmpm);
|
|
<a name="l250"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l251"></a> tmpm=tmpm1;
|
|
<a name="l252"></a> }
|
|
<a name="l253"></a> </span><span class=cF5>Refresh</span><span class=cF0>;
|
|
<a name="l254"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l255"></a>}
|
|
<a name="l256"></a>
|
|
<a name="l257"></a>#</span><span class=cF1>define</span><span class=cF0> NOZZLE_MOVE_STEPS 5
|
|
<a name="l258"></a>#</span><span class=cF1>define</span><span class=cF0> NOZZLE_MOVE 15.0
|
|
<a name="l259"></a></span><span class=cF1>U0</span><span class=cF0> MoveNozzleTaskX(</span><span class=cF9>I64</span><span class=cF0> sign)
|
|
<a name="l260"></a>{
|
|
<a name="l261"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
|
<a name="l262"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<NOZZLE_MOVE_STEPS;i++) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l263"></a> nozzle->x=</span><span class=cF5>Clamp</span><span class=cF0>(nozzle->x+sign*NOZZLE_MOVE/NOZZLE_MOVE_STEPS,
|
|
<a name="l264"></a> HOSE_RADIUS*3,</span><span class=cF3>GR_WIDTH</span><span class=cF0>-HOSE_RADIUS*3);
|
|
<a name="l265"></a> </span><span class=cF5>Refresh</span><span class=cF0>;
|
|
<a name="l266"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l267"></a>}
|
|
<a name="l268"></a>
|
|
<a name="l269"></a></span><span class=cF1>U0</span><span class=cF0> MoveNozzleTaskY(</span><span class=cF9>I64</span><span class=cF0> sign)
|
|
<a name="l270"></a>{
|
|
<a name="l271"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
|
<a name="l272"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<NOZZLE_MOVE_STEPS;i++) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l273"></a> nozzle->y=</span><span class=cF5>Clamp</span><span class=cF0>(nozzle->y+sign*NOZZLE_MOVE/NOZZLE_MOVE_STEPS,
|
|
<a name="l274"></a> HOSE_RADIUS*3,GROUND_Y);
|
|
<a name="l275"></a> </span><span class=cF5>Refresh</span><span class=cF0>;
|
|
<a name="l276"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l277"></a>}
|
|
<a name="l278"></a>
|
|
<a name="l279"></a></span><span class=cF1>U0</span><span class=cF0> Init()
|
|
<a name="l280"></a>{
|
|
<a name="l281"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
|
|
<a name="l282"></a> </span><span class=cF6>"$BG,LTCYAN$%h*c"</span><span class=cF0>,</span><span class=cF5>ToI64</span><span class=cF0>(GROUND_Y/</span><span class=cF3>FONT_HEIGHT</span><span class=cF0>),</span><span class=cF6>'\n'</span><span class=cF0>;
|
|
<a name="l283"></a>
|
|
<a name="l284"></a> </span><span class=cF2>//Allow hose to settle.</span><span class=cF0>
|
|
<a name="l285"></a> start_up_timeout=</span><span class=cF5>tS</span><span class=cF0>+0.5;
|
|
<a name="l286"></a>
|
|
<a name="l287"></a> ode=</span><span class=cF5>ODENew</span><span class=cF0>(0,5e-2,</span><span class=cF3>ODEF_HAS_MASSES</span><span class=cF0>);
|
|
<a name="l288"></a> ode->derive=&MyDerivative;
|
|
<a name="l289"></a> ode->acceleration_limit=5e3;
|
|
<a name="l290"></a>
|
|
<a name="l291"></a> HoseNew;
|
|
<a name="l292"></a> </span><span class=cF5>QueIns</span><span class=cF0>(ode,</span><span class=cF5>Fs</span><span class=cF0>->last_ode);
|
|
<a name="l293"></a>}
|
|
<a name="l294"></a>
|
|
<a name="l295"></a></span><span class=cF1>U0</span><span class=cF0> CleanUp()
|
|
<a name="l296"></a>{
|
|
<a name="l297"></a> </span><span class=cF5>Refresh</span><span class=cF0>(NOZZLE_MOVE_STEPS); </span><span class=cF2>//Let nozzle move tasks die</span><span class=cF0>
|
|
<a name="l298"></a> </span><span class=cF5>QueRem</span><span class=cF0>(ode);
|
|
<a name="l299"></a> </span><span class=cF5>QueDel</span><span class=cF0>(&ode->next_mass,</span><span class=cF3>TRUE</span><span class=cF0>);
|
|
<a name="l300"></a> </span><span class=cF5>QueDel</span><span class=cF0>(&ode->next_spring,</span><span class=cF3>TRUE</span><span class=cF0>);
|
|
<a name="l301"></a> </span><span class=cF5>ODEDel</span><span class=cF0>(ode);
|
|
<a name="l302"></a> </span><span class=cF5>DocClear</span><span class=cF0>;
|
|
<a name="l303"></a>}
|
|
<a name="l304"></a>
|
|
<a name="l305"></a></span><span class=cF1>U0</span><span class=cF0> SongTask(</span><span class=cF9>I64</span><span class=cF0>)
|
|
<a name="l306"></a>{
|
|
<a name="l307"></a> </span><span class=cF5>Fs</span><span class=cF0>->task_end_cb=&</span><span class=cF5>SndTaskEndCB</span><span class=cF0>;
|
|
<a name="l308"></a> </span><span class=cF5>MusicSettingsRst</span><span class=cF0>;
|
|
<a name="l309"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l310"></a> </span><span class=cF5>Play</span><span class=cF0>(</span><span class=cF6>"5sDCDC4qA5DetDFFeDG4etA5EF4qG5eFC"</span><span class=cF0>);
|
|
<a name="l311"></a> </span><span class=cF5>Play</span><span class=cF0>(</span><span class=cF6>"5sDCDC4qA5DetDFFeDG4etA5EF4qG5eFC"</span><span class=cF0>);
|
|
<a name="l312"></a> </span><span class=cF5>Play</span><span class=cF0>(</span><span class=cF6>"5DCsG4A5G4AqBeBA5qEE4B5eC4B"</span><span class=cF0>);
|
|
<a name="l313"></a> </span><span class=cF5>Play</span><span class=cF0>(</span><span class=cF6>"5DCsG4A5G4AqBeBA5qEE4B5eC4B"</span><span class=cF0>);
|
|
<a name="l314"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l315"></a>}
|
|
<a name="l316"></a>
|
|
<a name="l317"></a></span><span class=cF1>U0</span><span class=cF0> Squirt()
|
|
<a name="l318"></a>{
|
|
<a name="l319"></a> </span><span class=cF9>I64</span><span class=cF0> sc;
|
|
<a name="l320"></a> </span><span class=cF5>SettingsPush</span><span class=cF0>; </span><span class=cF2>//See </span><a href="/Wb/Adam/TaskSettings.HC.HTML#l3"><span class=cF4>SettingsPush</span></a><span class=cF0>
|
|
<a name="l321"></a> </span><span class=cF5>Fs</span><span class=cF0>->text_attr=</span><span class=cF3>YELLOW</span><span class=cF0><<4+</span><span class=cF3>BLUE</span><span class=cF0>;
|
|
<a name="l322"></a> </span><span class=cF5>Fs</span><span class=cF0>->song_task=</span><span class=cF5>Spawn</span><span class=cF0>(&SongTask,</span><span class=cF3>NULL</span><span class=cF0>,</span><span class=cF6>"Song"</span><span class=cF0>,,</span><span class=cF5>Fs</span><span class=cF0>);
|
|
<a name="l323"></a> </span><span class=cF5>AutoComplete</span><span class=cF0>;
|
|
<a name="l324"></a> </span><span class=cF5>WinBorder</span><span class=cF0>;
|
|
<a name="l325"></a> </span><span class=cF5>WinMax</span><span class=cF0>;
|
|
<a name="l326"></a> </span><span class=cF5>DocCursor</span><span class=cF0>;
|
|
<a name="l327"></a>
|
|
<a name="l328"></a> </span><span class=cF5>MenuPush</span><span class=cF0>(
|
|
<a name="l329"></a> </span><span class=cF6>"File {"</span><span class=cF0>
|
|
<a name="l330"></a> </span><span class=cF6>" Abort(,CH_SHIFT_ESC);"</span><span class=cF0>
|
|
<a name="l331"></a> </span><span class=cF6>" Exit(,CH_ESC);"</span><span class=cF0>
|
|
<a name="l332"></a> </span><span class=cF6>"}"</span><span class=cF0>
|
|
<a name="l333"></a> </span><span class=cF6>"Play {"</span><span class=cF0>
|
|
<a name="l334"></a> </span><span class=cF6>" Restart(,'\n');"</span><span class=cF0>
|
|
<a name="l335"></a> </span><span class=cF6>" Left(,,SC_CURSOR_LEFT);"</span><span class=cF0>
|
|
<a name="l336"></a> </span><span class=cF6>" Right(,,SC_CURSOR_RIGHT);"</span><span class=cF0>
|
|
<a name="l337"></a> </span><span class=cF6>" Up(,,SC_CURSOR_UP);"</span><span class=cF0>
|
|
<a name="l338"></a> </span><span class=cF6>" Down(,,SC_CURSOR_DOWN);"</span><span class=cF0>
|
|
<a name="l339"></a> </span><span class=cF6>"}"</span><span class=cF0>
|
|
<a name="l340"></a> );
|
|
<a name="l341"></a>
|
|
<a name="l342"></a> Init;
|
|
<a name="l343"></a> </span><span class=cF5>Fs</span><span class=cF0>->animate_task=</span><span class=cF5>Spawn</span><span class=cF0>(&AnimateTask,</span><span class=cF3>NULL</span><span class=cF0>,</span><span class=cF6>"Animate"</span><span class=cF0>,,</span><span class=cF5>Fs</span><span class=cF0>);
|
|
<a name="l344"></a> </span><span class=cF5>Fs</span><span class=cF0>->draw_it=&</span><span class=cF5>DrawIt</span><span class=cF0>;
|
|
<a name="l345"></a>
|
|
<a name="l346"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l347"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) {
|
|
<a name="l348"></a> </span><span class=cF1>switch</span><span class=cF0> (</span><span class=cF5>GetKey</span><span class=cF7>(</span><span class=cF0>&sc</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l349"></a> </span><span class=cF1>case</span><span class=cF0> 0:
|
|
<a name="l350"></a> </span><span class=cF1>switch</span><span class=cF0> (sc.u8[0]) {
|
|
<a name="l351"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_LEFT</span><span class=cF0>:
|
|
<a name="l352"></a> </span><span class=cF5>Spawn</span><span class=cF0>(&MoveNozzleTaskX,-1,</span><span class=cF6>"Move Nozzle"</span><span class=cF0>,,</span><span class=cF5>Fs</span><span class=cF0>);
|
|
<a name="l353"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l354"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_RIGHT</span><span class=cF0>:
|
|
<a name="l355"></a> </span><span class=cF5>Spawn</span><span class=cF0>(&MoveNozzleTaskX,1,</span><span class=cF6>"Move Nozzle"</span><span class=cF0>,,</span><span class=cF5>Fs</span><span class=cF0>);
|
|
<a name="l356"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l357"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_UP</span><span class=cF0>:
|
|
<a name="l358"></a> </span><span class=cF5>Spawn</span><span class=cF0>(&MoveNozzleTaskY,-1,</span><span class=cF6>"Move Nozzle"</span><span class=cF0>,,</span><span class=cF5>Fs</span><span class=cF0>);
|
|
<a name="l359"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l360"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_DOWN</span><span class=cF0>:
|
|
<a name="l361"></a> </span><span class=cF5>Spawn</span><span class=cF0>(&MoveNozzleTaskY,1,</span><span class=cF6>"Move Nozzle"</span><span class=cF0>,,</span><span class=cF5>Fs</span><span class=cF0>);
|
|
<a name="l362"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l363"></a> }
|
|
<a name="l364"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l365"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\n'</span><span class=cF0>:
|
|
<a name="l366"></a> CleanUp;
|
|
<a name="l367"></a> Init;
|
|
<a name="l368"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l369"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0>:
|
|
<a name="l370"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_ESC</span><span class=cF0>:
|
|
<a name="l371"></a> </span><span class=cF1>goto</span><span class=cF0> sq_done;
|
|
<a name="l372"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l373"></a> }
|
|
<a name="l374"></a>sq_done: </span><span class=cF2>//Don't goto out of try</span><span class=cF0>
|
|
<a name="l375"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>catch</span><span class=cF0>
|
|
<a name="l376"></a> </span><span class=cF5>PutExcept</span><span class=cF0>;
|
|
<a name="l377"></a> </span><span class=cF5>SettingsPop</span><span class=cF0>;
|
|
<a name="l378"></a> CleanUp;
|
|
<a name="l379"></a> </span><span class=cF5>MenuPop</span><span class=cF0>;
|
|
<a name="l380"></a>}
|
|
<a name="l381"></a>
|
|
<a name="l382"></a>Squirt;
|
|
</span></pre></body>
|
|
</html>
|