#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
# This class handles the map. It includes scrolling and passable determining
# functions. Refer to "$game_map" for the instance of this class.
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias glitchfinder_classic_screensize_initialize initialize
def initialize
glitchfinder_classic_screensize_initialize
@size = 1
@width = 20
@height = 15
end
#--------------------------------------------------------------------------
# * Scroll Down
# distance : scroll distance
#--------------------------------------------------------------------------
def scroll_down(distance)
@display_y = [@display_y + distance, ((self.height - @height) *
(64 * @size).to_i)].min
end
#--------------------------------------------------------------------------
# * Scroll Right
# distance : scroll distance
#--------------------------------------------------------------------------
def scroll_right(distance)
@display_x = [@display_x + distance, ((self.width - @width) *
(64 * @size).to_i)].min
end
#--------------------------------------------------------------------------
# * Start Scroll
# direction : scroll direction
# distance : scroll distance
# speed : scroll speed
#--------------------------------------------------------------------------
def start_scroll(direction, distance, speed)
@scroll_direction = direction
@scroll_rest = distance * (64 * @size).to_i
@scroll_speed = speed
end
end
#==============================================================================
# ** Game_Character
#------------------------------------------------------------------------------
# This class deals with characters. It's used as a superclass for the
# Game_Player and Game_Event classes.
#==============================================================================
class Game_Character
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias glitchfinder_classic_screensize_gchar_initialize initialize
def initialize
glitchfinder_classic_screensize_gchar_initialize
@size = 1
width = 640 / 2
height = 480 / 2
@move_speed = 4 + (((@size / 2 ).to_i - 1) * 2)
@center_x = (((width / 2).to_i * @size).to_i - (8 * @size).to_i) * 4
@center_y = (((height / 2).to_i * @size).to_i - (8 * @size).to_i) * 4
end
#--------------------------------------------------------------------------
# * Determine if Moving
#--------------------------------------------------------------------------
def moving?
# If logical coordinates differ from real coordinates,
# movement is occurring.
return (@real_x != @x * (64 * @size).to_i or
@real_y != @y * (64 * @size).to_i)
end
#--------------------------------------------------------------------------
# * Move to Designated Position
# x : x-coordinate
# y : y-coordinate
#--------------------------------------------------------------------------
def moveto(x, y)
@x = x % $game_map.width
@y = y % $game_map.height
@real_x = @x * (64 * @size).to_i
@real_y = @y * (64 * @size).to_i
@prelock_direction = 0
end
#--------------------------------------------------------------------------
# * Get Screen X-Coordinates
#--------------------------------------------------------------------------
def screen_x
# Get screen coordinates from real coordinates and map display position
return (@real_x - $game_map.display_x + 3) / 4 + (16 * (@size / 2).to_i)
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias glitchfinder_classic_screensize_update update
def update
glitchfinder_classic_screensize_update
# If animation count exceeds maximum value
# * Maximum value is move speed * 1 taken from basic value 18
if @anime_count > 18 - @move_speed * ((@size / 2 ).to_i - 1)
# If stop animation is OFF when stopping
if not @step_anime and @stop_count > 0
# Return to original pattern
@pattern = @original_pattern
# If stop animation is ON when moving
else
# Update pattern
@pattern = (@pattern + 1) % 4
end
# Clear animation count
@anime_count = 0
end
@zoom = (0.50 * @size.to_f)
end
#--------------------------------------------------------------------------
# * Frame Update (jump)
#--------------------------------------------------------------------------
def update_jump
# Reduce jump count by 1
@jump_count -= 1
# Calculate new coordinates
@real_x = ((@real_x * @jump_count + @x * (128 * @size / 2).to_i) /
(@jump_count + 1))
@real_y = ((@real_y * @jump_count + @y * (128 * @size / 2).to_i) /
(@jump_count + 1))
end
#--------------------------------------------------------------------------
# * Update frame (move)
#--------------------------------------------------------------------------
def update_move
# Convert map coordinates from map move speed into move distance
distance = 2 ** @move_speed
# If logical coordinates are further down than real coordinates
if @y * ((128 * @size).to_i / 2) > @real_y
# Move down
@real_y = [@real_y + distance, @y * (64 * @size).to_i].min
end
# If logical coordinates are more to the left than real coordinates
if @x * ((128 * @size).to_i / 2) < @real_x
# Move left
@real_x = [@real_x - distance, @x * (64 * @size).to_i].max
end
# If logical coordinates are more to the right than real coordinates
if @x * ((128 * @size).to_i / 2) > @real_x
# Move right
@real_x = [@real_x + distance, @x * (64 * @size).to_i].min
end
# If logical coordinates are further up than real coordinates
if @y * ((128 * @size).to_i / 2) < @real_y
# Move up
@real_y = [@real_y - distance, @y * (64 * @size).to_i].max
end
# If move animation is ON
if @walk_anime
# Increase animation count by 1.5
@anime_count += 1.5
# If move animation is OFF, and stop animation is ON
elsif @step_anime
# Increase animation count by 1
@anime_count += 1
end
end
end
#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
# This class handles the player. Its functions include event starting
# determinants and map scrolling. Refer to "$game_player" for the one
# instance of this class.
#==============================================================================
class Game_Player < Game_Character
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias glitchfinder_classic_screensize_initialize initialize
def initialize
glitchfinder_classic_screensize_initialize
@size = 1
@width = 20
@height = 15
end
#--------------------------------------------------------------------------
# * Set Map Display Position to Center of Screen
#--------------------------------------------------------------------------
def center(x, y)
max_x = ($game_map.width - @width) * (64 * @size).to_i
max_y = ($game_map.height - @height) * (64 * @size).to_i
$game_map.display_x = [0,
[x * (64 * @size).to_i - @center_x, max_x].min].max
$game_map.display_y = [0,
[y * (64 * @size).to_i - @center_y, max_y].min].max
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Remember whether or not moving in local variables
last_moving = moving?
# If moving, event running, move route forcing, and message window
# display are all not occurring
unless moving? or $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing
# Move player in the direction the directional button is being pressed
case Input.dir4
when 2
move_down
when 4
move_left
when 6
move_right
when 8
move_up
end
end
# Remember coordinates in local variables
last_real_x = @real_x
last_real_y = @real_y
super
# 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
# If not moving
unless moving?
# If player was moving last time
if last_moving
# Event determinant is via touch of same position event
result = check_event_trigger_here([1,2])
# If event which started does not exist
if result == false
# Disregard if debug mode is ON and ctrl key was pressed
unless $DEBUG and Input.press?(Input::CTRL)
# Encounter countdown
if @encounter_count > 0
@encounter_count -= 1
end
end
end
end
# If C button was pressed
if Input.trigger?(Input::C)
# Same position and front event determinant
check_event_trigger_here([0])
check_event_trigger_there([0,1,2])
end
end
end
end
#==============================================================================
# ** Sprite_Character
#------------------------------------------------------------------------------
# This sprite is used to display the character. It observes the Game_Character
# class and automatically changes sprite conditions.
#==============================================================================
class Sprite_Character < RPG::Sprite
#--------------------------------------------------------------------------
# * Object Initialization
# viewport : viewport
# character : character (Game_Character)
#--------------------------------------------------------------------------
def initialize(viewport, character = nil)
@size = 1
@current_size = 2
super(viewport)
@character = character
update
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
# If tile ID, file name, or hue are different from current ones
if @tile_id != @character.tile_id or
@character_name != @character.character_name or
@character_hue != @character.character_hue
# Remember tile ID, file name, and hue
@tile_id = @character.tile_id
@character_name = @character.character_name
@character_hue = @character.character_hue
# If tile ID value is valid
if @tile_id >= 384
self.bitmap = RPG::Cache.tile($game_map.tileset_name,
@tile_id, @character.character_hue)
self.src_rect.set(0, 0, 32, 32)
self.ox = (8 * ((@size * 2) - 2)).to_i
self.oy = (64 * (1 / @size)).to_i
# If tile ID value is invalid
else
self.bitmap = RPG::Cache.character(@character.character_name,
@character.character_hue)
@cw = bitmap.width / 4
@ch = bitmap.height / 4
self.ox = (@cw / 2) - ((8 * ((@size * 2) - 4) * -1).to_i)
self.oy = @ch + ((16 * ((@size * 2) - 4) * -1).to_i)
end
end
# Set visible situation
self.visible = (not @character.transparent)
# If graphic is character
if @tile_id == 0
# Set rectangular transfer
sx = @character.pattern * @cw
sy = (@character.direction - 2) / 2 * @ch
self.src_rect.set(sx, sy, @cw, @ch)
end
# Set sprite coordinates
self.x = @character.screen_x
self.y = @character.screen_y
self.z = @character.screen_z(@ch)
# Set opacity level, blend method, and bush depth
self.opacity = @character.opacity
self.blend_type = @character.blend_type
self.bush_depth = @character.bush_depth
# Animation
if @character.animation_id != 0
animation = $data_animations[@character.animation_id]
animation(animation, true)
@character.animation_id = 0
end
if @current_size != @size
@zoom = (0.50 * @size.to_f)
self.zoom_x = @zoom
self.zoom_y = @zoom
x = @character.screen_x
x = x * @zoom
y = @character.screen_y
y = y * @zoom
self.x = x
self.y = y
@current_size = @size
end
end
end
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
# This class brings together map screen sprites, tilemaps, etc.
# It's used within the Scene_Map class.
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# * Viewport Initialization
#--------------------------------------------------------------------------
def init_viewports
width = 640
height = 480
size = 1
@viewport1 = Viewport.new(0, 0, (width * size).to_i, (height * size).to_i)
@viewport2 = Viewport.new(0, 0, (width * size).to_i, (height * size).to_i)
@viewport3 = Viewport.new(0, 0, (width * size).to_i, (height * size).to_i)
end
end