From 5d30984821f118cf025ae4f9855b41a0a2f73fc8 Mon Sep 17 00:00:00 2001 From: Michael Shirt Date: Wed, 28 Sep 2016 22:43:14 -0600 Subject: [PATCH] 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. --- scripts/Game_Player.rb | 52 +++++++++++++++++++++++------------------- scripts/Script.rb | 23 +++++++++++++++++++ 2 files changed, 51 insertions(+), 24 deletions(-) diff --git a/scripts/Game_Player.rb b/scripts/Game_Player.rb index 46ef7ed..67d1eff 100644 --- a/scripts/Game_Player.rb +++ b/scripts/Game_Player.rb @@ -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? diff --git a/scripts/Script.rb b/scripts/Script.rb index 5cf57c7..b60a252 100644 --- a/scripts/Script.rb +++ b/scripts/Script.rb @@ -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?