alias mato { if (!$2) tokenize 32 50 50 if (!$window(@mato)) window -pdoBf @mato -1 -1 $calc($1 * 10) $calc($2 * 10) if ($hget(mato)) hfree mato hmake mato $ceil($calc($1 * $2 / 100)) var %i = 1,%j = 1 while (%i <= $1) { pallero add 1 %i 1 pallero add 1 %i $2 inc %i } while (%j <= $2) { pallero add 1 1 %j pallero add 1 $1 %j inc %j } hadd mato w $1 hadd mato h $2 var %x = $round($calc($1 / 2),0),%y = $round($calc($2 / 2),0) pallero add 3 $calc(%x - 1) %y pallero add 3 %x %y pallero add 3 $calc(%x + 1) %y hadd mato mato.x $calc(%x - 1) %x $calc(%x + 1) hadd mato mato.y %y %y %y hadd mato dir 0 1 .timermato -h 0 100 timer.mato .timeryum 0 2.5 timer.yum } ; syntax /pallero <1|2|3> ; or $pallero(x-coord,y-coord) ; hopefully incorporating almost everything to this alias in the future. ; This changes the picture window graphically and somewhat changes the ; hash table accordingly. Still to be added stuff. ; 1 = block ; 2 = yum ; 3 = worm itself alias pallero { if (!$isid) { var %x = $calc(10 * $3 - 10), %y = $calc(10 * $4 - 10),%color if (!$5) { if ($2 == 1) %color = $rgb(0,0,0) if ($2 == 2) %color = $rgb(255,0,0) if ($2 == 3) %color = $rgb(0,0,0) } else %color = $5 if ($1 == add) { if ($2 != 1) drawrect -fre @mato %color 10 %x %y 10 10 else drawrect -fr @mato %color 10 %x %y 10 10 hadd mato $3 $+ . $+ $4 $2 } else { drawrect -r @mato $rgb(255,255,255) 10 %x %y 10 10 hdel mato $3 $+ . $+ $4 } } else return $hget(mato,$1 $+ . $+ $2) } alias timer.mato { tokenize 32 $hget(mato,dir) var %new.x,%new.y,%cur.x.all = $hget(mato,mato.x),%cur.y.all = $hget(mato,mato.y) var %cur.x = $gettok(%cur.x.all,-1,32), %cur.y = $gettok(%cur.y.all,-1,32) if ($1 == 0) { %new.x = $calc(%cur.x + $2) %new.y = %cur.y } if ($2 == 0) { %new.x = %cur.x %new.y = $calc(%cur.y + $1) } var %next.block = $pallero($calc(%cur.x + $2),$calc(%cur.y + $1)) if (%next.block isin 13) end.game pallero add 3 %new.x %new.y var %num = $numtok(%cur.x.all,32) if (%next.block != 2) { pallero del 3 $gettok(%cur.x.all,1,32) $gettok(%cur.y.all,1,32) var %i = 2,%dec = $calc(255 / (%num - 1)),%j = 255 while (%i < %num) { dec %j %dec pallero add 3 $gettok(%cur.x.all,%i,32) $gettok(%cur.y.all,%i,32) $rgb(%j,%j,%j) inc %i } } hadd mato mato.x $gettok(%cur.x.all,$iif(%next.block == 2,1,2) $+ - $+ %num,32) %new.x hadd mato mato.y $gettok(%cur.y.all,$iif(%next.block == 2,1,2) $+ - $+ %num,32) %new.y } on *:KEYDOWN:@mato:37,38,39,40:{ var %cur.x.all = $hget(mato,mato.x),%cur.y.all = $hget(mato,mato.y),%i,%new.x,%new.y var %cur.x = $gettok(%cur.x.all,-1,32), %cur.y = $gettok(%cur.y.all,-1,32) var %old.x = $gettok(%cur.x.all,-2,32), %old.y = $gettok(%cur.y.all,-2,32) if ($keyval == 37) %i = 0 -1 if ($keyval == 38) %i = -1 0 if ($keyval == 39) %i = 0 1 if ($keyval == 40) %i = 1 0 %new.x = $calc(%cur.x + $gettok(%i,2,32)) %new.y = $calc(%cur.y + $gettok(%i,1,32)) if (%old.x == %new.x && %old.y == %new.y) return hadd mato dir %i } on *:CLOSE:@mato:{ .timermato off .timeryum off } alias end.game { .timermato off .timeryum off window -c @mato halt } alias timer.yum { if ($hget(mato,yum) == 0) { var %x = $rand(2,$hget(mato,w)), %y = $rand(2,$hget(mato,h)) while ($pallero(%x,%y) isin 123) { %x = $rand(2,$hget(mato,w)) %y = $rand(2,$hget(mato,h)) } hadd mato yumticker $ticks hadd mato yum.x %x hadd mato yum.y %y hadd mato yum 1 pallero add 2 %x %y } elseif ($calc($ticks - $hget(mato,yumticker)) >= 5000) { pallero del 2 $hget(mato,yum.x) $hget(mato,yum.y) hadd mato yum 0 } }