Camera functionality added

With this we can now fix the camera to a set position.  I also added
script functions to get the X and Y of an npc, which is useful for
events.
This commit is contained in:
Michael Shirt 2016-09-28 22:43:14 -06:00
parent 6c1f0f8bf4
commit 5d30984821
2 changed files with 51 additions and 24 deletions

View file

@ -56,7 +56,9 @@ class Game_Player < Game_Character
def moveto(x, y)
super
# Centering
center(x, y)
if !$game_switches[100]
center(x, y)
end
end
#--------------------------------------------------------------------------
# * Increaase Steps
@ -227,29 +229,31 @@ class Game_Player < Game_Character
else
@footstep_timer = 8
end
# If character moves down and is positioned lower than the center
# of the screen
if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
# Scroll map down
$game_map.scroll_down(@real_y - last_real_y)
end
# If character moves left and is positioned more let on-screen than
# center
if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
# Scroll map left
$game_map.scroll_left(last_real_x - @real_x)
end
# If character moves right and is positioned more right on-screen than
# center
if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
# Scroll map right
$game_map.scroll_right(@real_x - last_real_x)
end
# If character moves up and is positioned higher than the center
# of the screen
if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
# Scroll map up
$game_map.scroll_up(last_real_y - @real_y)
if !$game_switches[100]
# If character moves down and is positioned lower than the center
# of the screen
if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
# Scroll map down
$game_map.scroll_down(@real_y - last_real_y)
end
# If character moves left and is positioned more let on-screen than
# center
if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
# Scroll map left
$game_map.scroll_left(last_real_x - @real_x)
end
# If character moves right and is positioned more right on-screen than
# center
if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
# Scroll map right
$game_map.scroll_right(@real_x - last_real_x)
end
# If character moves up and is positioned higher than the center
# of the screen
if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
# Scroll map up
$game_map.scroll_up(last_real_y - @real_y)
end
end
# If not moving
unless moving?

View file

@ -7,6 +7,24 @@ module Script
logpos($game_player.y, $game_player.real_y, $game_player.direction == 2)
end
def self.eve_x(name)
for event in $game_map.events.values
if event.name == name
return logpos(event.x, event.real_x, event.direction == 6)
end
end
return 0
end
def self.eve_y(name)
for event in $game_map.events.values
if event.name == name
return logpos(event.y, event.real_y, event.direction == 2)
end
end
return 0
end
# Temporary switch assignment
def self.tmp_s1=(val)
$game_switches[TMP_INDEX+0] = val
@ -44,6 +62,11 @@ module Script
end
return pos
end
def self.set_cam(x, y)
$game_map.display_x = x
$game_map.display_y = y
end
end
def has_lightbulb?