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

View File

@ -7,6 +7,24 @@ module Script
logpos($game_player.y, $game_player.real_y, $game_player.direction == 2) logpos($game_player.y, $game_player.real_y, $game_player.direction == 2)
end 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 # Temporary switch assignment
def self.tmp_s1=(val) def self.tmp_s1=(val)
$game_switches[TMP_INDEX+0] = val $game_switches[TMP_INDEX+0] = val
@ -44,6 +62,11 @@ module Script
end end
return pos return pos
end end
def self.set_cam(x, y)
$game_map.display_x = x
$game_map.display_y = y
end
end end
def has_lightbulb? def has_lightbulb?