[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[OpenVerse] Sliding objects
# slide_object who name x1 y1 x2 y2 steps delay
#
# For $who, slide $name object from ($x1, $y1) to ($x2, $y2) in $steps
#steps with a $delay microsecond delay in between
proc slide_object {who name x1 y1 x2 y2 steps delay} {
slide_object_callback $who $name [expr $x1 * 1.0] [expr $y1 * 1.0] $x1
$y1 [expr ($x2 - $x1) / ($steps * 1.0)] [expr ($y2 - $y1) / ($steps *
1.0)] $steps $delay
unset who name x1 y1 x2 y2 steps delay
}
# slide_object_callback who name x_f y_f x_i y_i x_delta y_delta
# steps_remaining delay
#
# Workhorse for slide_object
proc slide_object_callback {who name x_f y_f x_i y_i x_delta y_delta
steps_remaining delay} {
# Increment the real locations
set x_f [expr $x_f + $x_delta]
set y_f [expr $y_f + $y_delta]
# Derive the integral locations
set x [expr round($x_f) * 1]
set y [expr round($y_f) * 1]
# Send the movement message
if {[string compare $who "all"] == 0} {
send_to_all_users "MOVE_OBJ $name [expr $x - $x_i] [expr $y - $y_i]
0 0"
} else {
send_to_user $who "MOVE_OBJ $name [expr $x - $x_i] [expr $y - $y_i]
0 0"
}
incr steps_remaining -1
if {$steps_remaining > 0} {
# Do it again in a bit
after $delay "slide_object_callback $who $name $x_f $y_f $x $y
$x_delta $y_delta $steps_remaining $delay"
}
unset who name x_f y_f x_i y_i x_delta y_delta x y
}
This little piece of code might be useful for making avatars slide in a
straight line (and also for adding different kinds of MOVE_OBJ motion).
__ _ _ __ _ _ __ _ ___ _ _
/_\ |\ | | \ \ / / __ / \ | |__|
/ \ | \| |_/ | \__| \_/ | | |
unununium@openverse.org zap.to/andygoth/
andygoth@ectisp.net 35256413
-----------------------------------------
Please sign the Linux Driver Petition!
<http://www.libranet.com/petition.html>
-------------------------------------------------------
--
Cruise -
OpenVerse Visual Chat - http://openverse.org/
-----------------------------------------------------------------
To unsubscribe to the OpenVerse mailing list send a message
to openverse-request@openverse.org with the following word
in the BODY of the message.
UNSUBSCRIBE
If you need assistance from a human, email cruise@openverse.org
-----------------------------------------------------------------