[XP] Game Map Simple AddOns

Started by Wecoc, August 23, 2014, 08:29:54 pm

Previous topic - Next topic

Wecoc

Game Map Simple AddOns
Authors: Wecoc
Version: 1.0
Type: Map / Picture Add-on
Key Term: Misc Add-on



Introduction

It gives more usable methods for Game_Map, especially useful new calls for Call Script. And that's it.
Put over main and don't give credits for it.



Features


  • Manage scrolls and zooms more efficiently

  • Parallax variable




Screenshots

N/A for this type of script


Script

Spoiler: ShowHide

#==============================================================================
# ** Game Map Simple AddOns
#==============================================================================

#==============================================================================
# ** Game_System
#==============================================================================

class Game_System
  attr_accessor :parallax_game
  alias parallax_game_initialize initialize unless $@
  def initialize
    parallax_game_initialize
    @parallax_game = false
  end
end

#==============================================================================
# ** Game_Map
#==============================================================================

class Game_Map

  attr_accessor :tilemap_display_x
  attr_accessor :tilemap_display_y
  attr_accessor :weather_display_x
  attr_accessor :weather_display_y

  attr_accessor :panorama_zoom_x
  attr_accessor :panorama_zoom_y
  attr_accessor :panorama_display_x
  attr_accessor :panorama_display_y

  attr_accessor :fog_zoom_x
  attr_accessor :fog_zoom_y
  attr_accessor :fog_display_x
  attr_accessor :fog_display_y

  alias wecoc_addons_setup setup unless $@
  def setup(map_id)
    wecoc_addons_setup(map_id)
    if $game_system.parallax_game == true
      set_parallax_display
    else
      set_default_display
    end
    @panorama_zoom_x = 100.0
    @panorama_zoom_y = 100.0
    @fog_zoom_x = @fog_zoom
    @fog_zoom_y = @fog_zoom
  end

  def tilemap_display
    return @tilemap_display_x
  end

  def tilemap_display=(value)
    @tilemap_display_x = value
    @tilemap_display_y = value
  end

  def weather_display
    return @weather_display_x
  end

  def weather_display=(value)
    @weather_display_x = value
    @weather_display_y = value
  end

  def panorama_zoom
    return @panorama_zoom_x
  end

  def panorama_zoom=(zoom)
    @panorama_zoom_x = zoom
    @panorama_zoom_y = zoom
  end

  def panorama_display
    return @panorama_display_x
  end

  def panorama_display=(value)
    @panorama_display_x = value
    @panorama_display_y = value
  end

  def fog_zoom=(zoom)
    @fog_zoom = zoom
    @fog_zoom_x = zoom
    @fog_zoom_y = zoom
  end

  def fog_display
    return @fog_display_x
  end

  def fog_display=(value)
    @fog_display_x = value
    @fog_display_y = value
  end

  def set_default_display
    @tilemap_display_x = 4
    @tilemap_display_y = 4
    @weather_display_x = 4
    @weather_display_y = 4
    @panorama_display_x = 8
    @panorama_display_y = 8
    @fog_display_x = 4
    @fog_display_y = 4
  end

  def set_parallax_display
    @tilemap_display_x = 4
    @tilemap_display_y = 4
    @weather_display_x = 4
    @weather_display_y = 4
    @panorama_display_x = 4
    @panorama_display_y = 4
    @fog_display_x = 4
    @fog_display_y = 4
  end
end

#==============================================================================
# ** Game_Picture
#==============================================================================

class Game_Picture

  attr_accessor  :display_x
  attr_accessor  :display_y

  alias wecoc_display_ini initialize unless $@
  def initialize(number)
    wecoc_display_ini(number)
    @display_x = 0
    @display_y = 0
  end

  def display
    return @display_x
  end

  def display=(value)
    @display_x = value
    @display_y = value
  end

  def erase
    @name = ""
    self.display = 0
  end
end

class Sprite_Picture
  def display
    return @picture.display
  end

  def display=(value)
    @picture.display = value
  end

  def display_x
    return @picture.display_x
  end

  def display_y
    return @picture.display_y
  end

  def display_x=(value)
    @picture.display_x = value
  end

  def display_y=(value)
    @picture.display_y = value
  end
end

#==============================================================================
# ** Spriteset_Map
#==============================================================================

class Spriteset_Map
  def update
    if @panorama_name != $game_map.panorama_name or
      @panorama_hue != $game_map.panorama_hue
      @panorama_name = $game_map.panorama_name
      @panorama_hue = $game_map.panorama_hue
      if @panorama.bitmap != nil
        @panorama.bitmap.dispose
        @panorama.bitmap = nil
      end
      if @panorama_name != ""
        @panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
      end
      Graphics.frame_reset
    end

    if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue
      @fog_name = $game_map.fog_name
      @fog_hue = $game_map.fog_hue
      if @fog.bitmap != nil
        @fog.bitmap.dispose
        @fog.bitmap = nil
      end
      if @fog_name != ""
        @fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
      end
      Graphics.frame_reset
    end

    @tilemap.ox = $game_map.display_x / $game_map.tilemap_display_x
    @tilemap.oy = $game_map.display_y / $game_map.tilemap_display_y
    @tilemap.update

    @panorama.ox = $game_map.display_x / $game_map.panorama_display_x
    @panorama.oy = $game_map.display_y / $game_map.panorama_display_y
    @panorama.zoom_x = $game_map.panorama_zoom_x / 100.0
    @panorama.zoom_y = $game_map.panorama_zoom_y / 100.0
   
    @fog.zoom_x = $game_map.fog_zoom_x / 100.0
    @fog.zoom_y = $game_map.fog_zoom_y / 100.0
    @fog.opacity = $game_map.fog_opacity
    @fog.blend_type = $game_map.fog_blend_type
    @fog.ox = $game_map.display_x / $game_map.fog_display_x + $game_map.fog_ox
    @fog.oy = $game_map.display_y / $game_map.fog_display_y + $game_map.fog_oy
    @fog.tone = $game_map.fog_tone

    for sprite in @character_sprites
      sprite.update
    end

    @weather.type = $game_screen.weather_type
    @weather.max = $game_screen.weather_max
    @weather.ox = $game_map.display_x / $game_map.weather_display_x
    @weather.oy = $game_map.display_y / $game_map.weather_display_y
    @weather.update

    for sprite in @picture_sprites
      sprite.update
      if sprite.display_x != 0
        sprite.x -= $game_map.display_x / sprite.display_x
        sprite.y -= $game_map.display_y / sprite.display_y
      end
    end

    @timer_sprite.update

    @viewport1.tone = $game_screen.tone
    @viewport1.ox = $game_screen.shake

    @viewport3.color = $game_screen.flash_color

    @viewport1.update
    @viewport3.update
  end
end



Instructions

In the very beginning of the script you can see this line:
@parallax_game = false
Set it true and panoramas will automatically scroll in the map speed (parallax mapping)

You can change that in-game using $game_system.parallax_game = true // false

$game_map.tilemap_display = value
$game_map.tilemap_display_x = value
$game_map.tilemap_display_y = value

Changes the tileset's scroll speed when the player moves around the map. The higher value, the slower it goes. Default value: 4
The other methods are the same but for specific axis.

$game_map.weather_display = value
$game_map.weather_display_x = value
$game_map.weather_display_y = value

Changes the weather's scroll speed. Default value: 4

$game_map.panorama_display = value
$game_map.panorama_display_x = value
$game_map.panorama_display_y = value

Changes the panorama's scroll speed. Default value: 8 (or 4 if @parallax_game is activated)

$game_map.fog_display = value
$game_map.fog_display_x = value
$game_map.fog_display_y = value

Changes the fog's scroll speed. Default value: 4

$game_screen.pictures[id].display = value
$game_screen.pictures[id].display_x = value
$game_screen.pictures[id].display_y = value

Changes the scroll speed of an specific picture. Default value: 0 (it doesn't scroll by default)

$game_map.panorama_zoom = value
$game_map.panorama_zoom_x = value
$game_map.panorama_zoom_y = value

Changes the panorama zoom. Default value: 100

$game_map.fog_zoom = value
$game_map.fog_zoom_x = value
$game_map.fog_zoom_y = value

Changes the fog zoom. It works like on default but with the axis-specific implementation. Default value: 100



Compatibility

It's a simple Add-on so it should not have huge incompatibility problems.


Credits and Thanks


  • Wecoc - But don't give me credits for this.