I'm trying to get Trickster's Moving Windows script to work, however, without any documentation I am helpless. The only little bit Trickster says is;
My question is: Where do I call that? Where do I insert that bit of code?
What I want to do is, when you hit ESC, have the menu to slide in from the side of the screen. Then when you exit, the menu slides off.
Thanks for taking pity on my clueless soul and helping.
to move a window just call .move(x, y, speed)
where x is the destination x coordinate
y is the destination y coordinate
speed is the speed of the movement
My question is: Where do I call that? Where do I insert that bit of code?
What I want to do is, when you hit ESC, have the menu to slide in from the side of the screen. Then when you exit, the menu slides off.
Thanks for taking pity on my clueless soul and helping.
class Numeric
def sign
return 0 if self.zero?
return (self / self.abs).to_i
end
end
class Window_Base
#--------------------------------------------------------------------------
# * Move the sprite
# x : x coordinate of the destination point
# y : y coordinate of the destination point
# speed : Speed of movement
#--------------------------------------------------------------------------
def move(x, y, speed = 1)
# Set Destination Points speed and move count set moving flag
@destination_x = x
@destination_y = y
@move_speed = speed
@moving = true
# Get the distance + (negative if to left or up positive if down or right)
@distance_x = (@destination_x - self.x).to_f
@distance_y = (@destination_y - self.y).to_f
# Get slant distance (hypotenuse of the triangle (xf,yi) (xi,yf) and (xf,yf))
@distance = Math.sqrt(@distance_x ** 2 + @distance_y ** 2)
# Calculate angle of movement which is later used to determine direction
# If X distance is 0 (Prevent Infinity Error)
if @distance_x == 0
# The Angle is sign(distance_y) * - π / 2 (90° or 270°)
@angle = @distance_y.sign * Math::PI / 2
# If Y distance is 0 (Prevent Incorrect Direction for later)
elsif @distance_y == 0
# The Angle is sign(distance_x) - 1 * π / 2 (0° or 180°)
@angle = (@distance_x.sign - 1) * Math::PI / 2
else
# The Angle is the Arctangent of @distance_y / @distance_x (slope)
# Returns [-Ï€,Ï€]
@angle = Math.atan2(@distance_y, @distance_x.to_f)
end
# Convert the angle to degrees
@angle *= 180 / Math::PI
end
#--------------------------------------------------------------------------
# * Update Move
#--------------------------------------------------------------------------
alias moving_window_update update
def update
moving_window_update
update_move
end
#--------------------------------------------------------------------------
# * Moving?
#--------------------------------------------------------------------------
def moving?
return @moving
end
#--------------------------------------------------------------------------
# * Update Move
#--------------------------------------------------------------------------
def update_move
# If not moving
if (self.x == @destination_x and self.y == @destination_y) or not @moving
@moving = false
return
end
# move increase x = the cosine of the arctangent of the dist x over dist y
# move increase x = cos(arctan(disty/distx)) simplified by trigonometry
# to distance_x / slant_distance, the sprite moves (move speed)
# along the slanted line (if it is slanted)
movinc_x = @move_speed * @distance_x.abs / @distance
# same reasoning with y increase except it is the sine of the arctangent
# move increase y = sin(arctan(disty/distx)) simplified by trigonometry
# to distance_y / slant_distance
movinc_y = @move_speed * @distance_y.abs / @distance
# Move the sign of the distance left + move increase or the remaining distance
# left if it will go past that point
if @move_speed != 0
# Get distance remaining
remain_x = (@destination_x - self.x).abs
remain_y = (@destination_y - self.y).abs
self.x += (@destination_x - self.x).sign * [movinc_x.ceil, remain_x].min
self.y += (@destination_y - self.y).sign * [movinc_y.ceil, remain_y].min
end
# If Destination Reached stop moving
if self.x == @destination_x and self.y == @destination_y
@moving = false
return
end
end
end
def sign
return 0 if self.zero?
return (self / self.abs).to_i
end
end
class Window_Base
#--------------------------------------------------------------------------
# * Move the sprite
# x : x coordinate of the destination point
# y : y coordinate of the destination point
# speed : Speed of movement
#--------------------------------------------------------------------------
def move(x, y, speed = 1)
# Set Destination Points speed and move count set moving flag
@destination_x = x
@destination_y = y
@move_speed = speed
@moving = true
# Get the distance + (negative if to left or up positive if down or right)
@distance_x = (@destination_x - self.x).to_f
@distance_y = (@destination_y - self.y).to_f
# Get slant distance (hypotenuse of the triangle (xf,yi) (xi,yf) and (xf,yf))
@distance = Math.sqrt(@distance_x ** 2 + @distance_y ** 2)
# Calculate angle of movement which is later used to determine direction
# If X distance is 0 (Prevent Infinity Error)
if @distance_x == 0
# The Angle is sign(distance_y) * - π / 2 (90° or 270°)
@angle = @distance_y.sign * Math::PI / 2
# If Y distance is 0 (Prevent Incorrect Direction for later)
elsif @distance_y == 0
# The Angle is sign(distance_x) - 1 * π / 2 (0° or 180°)
@angle = (@distance_x.sign - 1) * Math::PI / 2
else
# The Angle is the Arctangent of @distance_y / @distance_x (slope)
# Returns [-Ï€,Ï€]
@angle = Math.atan2(@distance_y, @distance_x.to_f)
end
# Convert the angle to degrees
@angle *= 180 / Math::PI
end
#--------------------------------------------------------------------------
# * Update Move
#--------------------------------------------------------------------------
alias moving_window_update update
def update
moving_window_update
update_move
end
#--------------------------------------------------------------------------
# * Moving?
#--------------------------------------------------------------------------
def moving?
return @moving
end
#--------------------------------------------------------------------------
# * Update Move
#--------------------------------------------------------------------------
def update_move
# If not moving
if (self.x == @destination_x and self.y == @destination_y) or not @moving
@moving = false
return
end
# move increase x = the cosine of the arctangent of the dist x over dist y
# move increase x = cos(arctan(disty/distx)) simplified by trigonometry
# to distance_x / slant_distance, the sprite moves (move speed)
# along the slanted line (if it is slanted)
movinc_x = @move_speed * @distance_x.abs / @distance
# same reasoning with y increase except it is the sine of the arctangent
# move increase y = sin(arctan(disty/distx)) simplified by trigonometry
# to distance_y / slant_distance
movinc_y = @move_speed * @distance_y.abs / @distance
# Move the sign of the distance left + move increase or the remaining distance
# left if it will go past that point
if @move_speed != 0
# Get distance remaining
remain_x = (@destination_x - self.x).abs
remain_y = (@destination_y - self.y).abs
self.x += (@destination_x - self.x).sign * [movinc_x.ceil, remain_x].min
self.y += (@destination_y - self.y).sign * [movinc_y.ceil, remain_y].min
end
# If Destination Reached stop moving
if self.x == @destination_x and self.y == @destination_y
@moving = false
return
end
end
end