Script Name: walkgame + com speaker
Author: kerst
Script Description: a tell alias + a walkgame game
Script Version: 1.0
Written on mIRC version: 6.3
Release Notes: use /tell text to say something, and play the game(he says something then too)
its my first com practice :P
alias walkgame {
;name the alias;
tell Lets play!
;use speak alias to say something :P;
window -p @walking-game
;open the window the -p switch to create a picture window;
drawreplace @walking-game $color(bground) 1
drawreplace @walking-game 14 1
drawreplace @walking-game 4 1
;make sure the background of the window is black, $color(bground) returns the standard background color 14 is the color of the path, 4 is the color of possible end game text(of games before);
var %t = $window(@walking-game).w,%^ = $window(@walking-game).h, %i = 1
;save the vars;
drawline @walking-game 14 20 $calc(%t /2) $calc(%^ -40) $calc(%t /2) $calc(%^ - 100)
;draw first path line;
var %l = $calc(%t /2) $calc(%^ - 100)
;save end of old path;
while (%i <= 100) {
;while loop start;
var %f = $iif(%i != 100,$calc($gettok(%l,1,32) $iif($r(1,2) == 1,-,+) $r(50,130)) $calc($gettok(%l,2,32) - $r(5,15)),$calc(%t /2) 0)
;get new info for a random different location;
drawline @walking-game 14 20 %l %f
;draw the line;
var %l = %f
;change %f to %l;
inc %i
;inc %i for the var;
}
;the while draws the path;
%& = 4 6 $round($calc(%t /2),0) $calc(%^ -50)
;save info for destionation dot;
drawdot @walking-game %&
;draw the dot;
}
on *:keydown:@walking-game:37,38,39,40:{
;when pressed key if $keyval is:;
;37 go left;
;38 go up;
;39 go right;
;40 go down;
if ($keyval == 37) {
drawreplace @walking-game 4 14
;replace the old dot to the background.
set %& 4 6 $calc($gettok(%&,3,32) - 3) $gettok(%&,4,32)
;replace var info to new info;
checkhit $gettok(%&,3,32) $gettok(%&,4,32)
;use alias to check if the dot hits the sides;
}
if ($keyval == 38) {
drawreplace @walking-game 4 14
;replace the old dot to the background.
set %& 4 6 $gettok(%&,3,32) $calc($gettok(%&,4,32) - 3)
;replace var info to new info;
checkhit $gettok(%&,3,32) $gettok(%&,4,32)
;use alias to check if the dot hits the sides;
}
if ($keyval == 39) {
drawreplace @walking-game 4 14
;replace the old dot to the background.
set %& 4 6 $calc($gettok(%&,3,32) + 3) $gettok(%&,4,32)
;replace var info to new info;
checkhit $gettok(%&,3,32) $gettok(%&,4,32)
;use alias to check if the dot hits the sides;
}
if ($keyval == 40) {
drawreplace @walking-game 4 14
;replace the old dot to the background.
set %& 4 6 $gettok(%&,3,32) $calc($gettok(%&,4,32) +3)
;replace var info to new info;
checkhit $gettok(%&,3,32) $gettok(%&,4,32)
;use alias to check if the dot hits the sides;
}
}
alias checkhit {
if ($getdot(@walking-game,$calc($1 - 3),$2) == 0) || ($getdot(@walking-game,$1,$calc($2 - 3)) == 0) || ($getdot(@walking-game,$calc($1 + 3),$2) == 0) || ($getdot(@walking-game,$1,$calc($2 + 3)) == 0) {
;check if dot is in the black;
clear @walking-game
;if so clear the window;
drawtext @walking-game 4 200 200 GAME OVER!, YOU HIT THE BLACK!
;let the player know :P ;
tell lol you suck
;tell him he sucks :D;
}
elseif ($1 < 0 || $1 > $window(@walking-game).w || $2 < 0 || $2 > $window(@walking-game).h) {
;check if the dot is outside the screen;
clear @walking-game
;if so clear the window;
drawtext @walking-game 4 200 200 YOU MADE IT, WELL DONE!
;congratulate the player;
tell well done $me
;use speak alias to tell him;
}
else {
drawdot @walking-game %&
;draw the dot;
}
}
menu @walking-game {
sclick: walkgame
abort: unset %&
}
menu * {
walkgame: walkgame
}
alias tell { .comopen k SAPI.SpVoice
;open the com;
.comclose k $com(k,Speak,1,bstr,$1-)
;close the com :P ;
}