Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #=======================================================
- # Akea Battle Camera
- # Author: Raizen
- # Community: http://www.centrorpg.com/
- # Compatibility: RMVXAce
- #
- #=======================================================
- # =========================Don't Modify==============================
- $included ||= Hash.new
- $included[:akea_battlecamera] = true
- module Akea_BattleCamera
- Camera_Config = []
- # =========================Don't Modify==============================
- # Important!: This is optimized for Victor's Animated Battle,
- # get the other version for Akea!
- # Instructions:
- # The camera system allows zoom and camera movement as you wish, you can
- # adjust it to be the target or the user and to where the camera will move.
- # To make the call script just:
- # Script Call: akea_camera(n), where n is the id in the configuration below.
- # This script call can be used either in battle events, or in battle systems that do allows
- # Script calls.(Akea Animated Battle System, Victor Animated Battle and others)
- # For some battle system, you might need to put this before the script call
- # SceneManager.scene, so for example it can be SceneManager.scene.akea_camera(n)
- # Below is configured the camera moves, follow the instructions :)
- # :focus is where the camera will be moved, it can be absolute movement, enemy movement,
- # or user movement.
- # To absolute movement use the following
- # :focus => [x, y, type]
- # x is the x position, y is the y position, and type is the type of movement where.
- # 0 will move the camera to x axis and y axis, and 1 will move x pixels and y pixels,
- # Example [300, 200, 0] will move the camera to position 300, 200
- # [300, 200, 1] will move the camera 300 pixels to the left, 200 pixels down.
- # The other tags for focus are:
- # 'none' => no camera movement
- # 'target' => target camera movement(Note, it will only work on Akea Animated Battle System!).
- # 'user' => The camera focus the user
- # 'center' => return the camera to its original position
- # :zoom_x/:zoom_y is the camera zoom, where 1 would be 100%
- # So if I want 2 times smaller(50%) I would just... :zoom_x => 0.5,
- # :time in frames that will happen the camera movement
- # :time => 20, would mean 20 frames (1/3 seconds)
- # :offset_x/:offset_y would simply mean if you want to make an adjust on final
- # camera positions, this is more for the 'user'/'target' focus
- #==============================================================================
- # Camera_Config[0] => camera moves 300 to the left and
- # zooms 200%
- #==============================================================================
- Camera_Config[0] = {
- :focus => 'target',
- :zoom_x => 1.5,
- :zoom_y => 1.5,
- :time => 20,
- :offset_x => 0,
- :offset_y => 0,
- }
- #==============================================================================
- # Camera_Config[1] => camera returns to center position
- # and zoom is reseted
- #==============================================================================
- Camera_Config[1] = {
- :focus => 'center',
- :zoom_x => 1,
- :zoom_y => 1,
- :time => 20,
- :offset_x => 0,
- :offset_y => 0,
- }
- #==============================================================================
- # Camera_Config[2] => camera goes toward the target with 20% larger sprites
- #==============================================================================
- Camera_Config[2] = {
- :focus => 'target',
- :zoom_x => 1.2,
- :zoom_y => 1.2,
- :time => 20,
- :offset_x => 0,
- :offset_y => 0,
- }
- #==============================================================================
- # Camera_Config[3] => camera just zooms 200%
- #==============================================================================
- Camera_Config[3] = {
- :focus => 'none',
- :zoom_x => 2,
- :zoom_y => 2,
- :time => 60,
- :offset_x => 0,
- :offset_y => 0,
- }
- #==============================================================================
- # Camera_Config[3] => camera goes to the user with 200% zoom
- #==============================================================================
- Camera_Config[4] = {
- :focus => 'user',
- :zoom_x => 2,
- :zoom_y => 2,
- :time => 20,
- :offset_x => 0,
- :offset_y => 0,
- }
- end
- #==============================================================================
- #==============================================================================
- # Here Starts the Script!
- #==============================================================================
- #==============================================================================
- #==============================================================================
- # ** Scene_Battle
- #------------------------------------------------------------------------------
- # Esta classe executa o processamento da tela de batalha.
- #==============================================================================
- class Scene_Battle < Scene_Base
- alias :akea_bcamera_update_basic :update_basic
- alias :akea_bcamera_start :start
- #--------------------------------------------------------------------------
- # * Inicialização do processo
- #--------------------------------------------------------------------------
- def start
- @akea_camera_time = 0
- @akea_camera_config = Hash.new
- akea_bcamera_start
- end
- #--------------------------------------------------------------------------
- # * Atualização das animações de camera
- #--------------------------------------------------------------------------
- def update_akea_camera
- @akea_camera_time -= 1
- time = @akea_camera_config[:time] - @akea_camera_time
- @spriteset.move_camera(@akea_camera_config[:final_x] * time/@akea_camera_config[:time], @akea_camera_config[:final_y] * time/@akea_camera_config[:time])
- @spriteset.make_zoom(@akea_camera_config[:speed_zoom_x], @akea_camera_config[:speed_zoom_y])
- if @akea_camera_time == 0
- @spriteset.set_zoom(@akea_camera_config[:zoom_x], @akea_camera_config[:zoom_y])
- end
- end
- #--------------------------------------------------------------------------
- # * Atualização
- #--------------------------------------------------------------------------
- def update_basic
- akea_bcamera_update_basic
- update_akea_camera if @akea_camera_time > 0
- end
- #--------------------------------------------------------------------------
- # * Método de definição da configuração
- #--------------------------------------------------------------------------
- def akea_camera(n)
- @akea_camera_config = Akea_BattleCamera::Camera_Config[n].dup
- @akea_camera_time = @akea_camera_config[:time]
- get_akea_camera_speed
- get_akea_camera_zoom
- end
- #--------------------------------------------------------------------------
- # * Método que obtém a velocidade da camera
- #--------------------------------------------------------------------------
- def get_akea_camera_speed
- @akea_camera_config[:final_y] = @akea_camera_config[:offset_y] + camera_akea_position_y(@akea_camera_config[:focus])
- @akea_camera_config[:final_x] = @akea_camera_config[:offset_x] + camera_akea_position_x(@akea_camera_config[:focus])
- @spriteset.set_ox_oy_camera
- end
- #--------------------------------------------------------------------------
- # * Método que obtem o zoom da camera
- #--------------------------------------------------------------------------
- def get_akea_camera_zoom
- @akea_camera_config[:speed_zoom_y] = (@akea_camera_config[:zoom_y] - @spriteset.zoom_sprites_y).to_f/@akea_camera_time.to_f
- @akea_camera_config[:speed_zoom_x] = (@akea_camera_config[:zoom_x] - @spriteset.zoom_sprites_x).to_f/@akea_camera_time.to_f
- @spriteset.set_ox_oy_zoom
- end
- #--------------------------------------------------------------------------
- # * Método de verificação da posição y
- #--------------------------------------------------------------------------
- def camera_akea_position_y(type)
- if type.is_a?(Array)
- if type[2] == 0
- return type[1] - @spriteset.get_viewport1_oy
- else
- return type[1]
- end
- end
- case type
- when 'none'
- return 0
- when 'target'
- return @subject.poses.last_targets[0].screen_y - Graphics.height/2 - @spriteset.get_viewport1_ox
- when 'user'
- return @subject.screen_y - Graphics.height/2 - @spriteset.get_viewport1_ox
- when 'center'
- return -@spriteset.get_viewport1_oy
- end
- end
- #--------------------------------------------------------------------------
- # * Método de verificação da posição x
- #--------------------------------------------------------------------------
- def camera_akea_position_x(type)
- if type.is_a?(Array)
- if type[2] == 0
- return type[0] - @spriteset.get_viewport1_ox
- else
- return type[0]
- end
- end
- case type
- when 'none'
- return 0
- when 'target'
- return @subject.poses.last_targets[0].screen_x - Graphics.width/2 - @spriteset.get_viewport1_oy
- when 'user'
- return @subject.screen_x - Graphics.width/2 - @spriteset.get_viewport1_oy
- when 'center'
- return -@spriteset.get_viewport1_ox
- end
- end
- end
- #==============================================================================
- # ** Spriteset_Battle
- #------------------------------------------------------------------------------
- # Esta classe reune os sprites da tela de batalha. Esta classe é usada
- # internamente pela classe Scene_Battle.
- #==============================================================================
- class Spriteset_Battle
- alias :akea_bcamera_initialize :initialize
- attr_reader :zoom_sprites_x
- attr_reader :zoom_sprites_y
- #--------------------------------------------------------------------------
- # * Inicialização do objeto
- #--------------------------------------------------------------------------
- def initialize
- @akea_bcamera_x = 0
- @akea_bcamera_y = 0
- @zoom_sprites_x = 1
- @zoom_sprites_y = 1
- akea_bcamera_initialize
- end
- #--------------------------------------------------------------------------
- # * Método que retem os valores de camera
- #--------------------------------------------------------------------------
- def move_camera(x, y)
- @akea_bcamera_x = x + @viewport_cam_1_ox
- @akea_bcamera_y = y + @viewport_cam_1_oy
- end
- #--------------------------------------------------------------------------
- # * Método que realiza os zooms
- #--------------------------------------------------------------------------
- def make_zoom(x, y)
- @actor_sprites.each{|sprt| sprt.zoom_x += x; sprt.zoom_y += y}
- @enemy_sprites.each{|sprt| sprt.zoom_x += x; sprt.zoom_y += y}
- @back1_sprite.zoom_x += x
- @back1_sprite.zoom_y += y
- @back2_sprite.zoom_x += x
- @back2_sprite.zoom_y += y
- @zoom_sprites_x += x
- @zoom_sprites_y += y
- end
- #--------------------------------------------------------------------------
- # * Método quue seta os valores de zoom(correção de bug)
- #--------------------------------------------------------------------------
- def set_zoom(x, y)
- @actor_sprites.each{|sprt| sprt.zoom_x = x; sprt.zoom_y = y}
- @enemy_sprites.each{|sprt| sprt.zoom_x = x; sprt.zoom_y = y}
- @back1_sprite.zoom_x = x
- @back1_sprite.zoom_y = y
- @back2_sprite.zoom_x = x
- @back2_sprite.zoom_y = y
- @zoom_sprites_x = x
- @zoom_sprites_y = y
- end
- #--------------------------------------------------------------------------
- # * Obtenção do ox do viewport1
- #--------------------------------------------------------------------------
- def get_viewport1_ox
- @viewport1.ox
- end
- #--------------------------------------------------------------------------
- # * Obtenção do oy do viewport1
- #--------------------------------------------------------------------------
- def get_viewport1_oy
- @viewport1.oy
- end
- #--------------------------------------------------------------------------
- # * Setar os valores iniciais de zoom
- #--------------------------------------------------------------------------
- def set_ox_oy_zoom
- @zoom_sprites_x = @back1_sprite.zoom_x
- @zoom_sprites_y = @back1_sprite.zoom_y
- end
- #--------------------------------------------------------------------------
- # * Setar a posção inicial da camera
- #--------------------------------------------------------------------------
- def set_ox_oy_camera
- @viewport_cam_1_ox = @viewport1.ox
- @viewport_cam_1_oy = @viewport1.oy
- end
- #--------------------------------------------------------------------------
- # * Atualização do viewports
- #--------------------------------------------------------------------------
- def update_viewports
- @viewport1.tone.set($game_troop.screen.tone)
- @viewport1.ox = $game_troop.screen.shake
- @viewport1.ox += @akea_bcamera_x
- @viewport1.oy = @akea_bcamera_y
- @viewport2.color.set($game_troop.screen.flash_color)
- @viewport3.color.set(0, 0, 0, 255 - $game_troop.screen.brightness)
- @viewport1.update
- @viewport2.update
- @viewport3.update
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement