Class: Yuki::Building_Object

Inherits:
Object
  • Object
show all
Defined in:
scripts/01450 Systems/00003 Map Engine/00001 Graphics/00400 Particles/00505 Building_Object.rb

Overview

Object that describe a building on the Map as a Particle

Author:

  • Nuri Yuri

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(image, x, y, oy) ⇒ Building_Object

Create a new Building_Object

Parameters:

  • image (String)

    name of the image in Graphics/Autotiles/

  • x (Integer)

    x coordinate of the building

  • y (Integer)

    y coordinate of the building

  • oy (Integer)

    offset y coordinate of the building in native resolution pixel



16
17
18
19
20
21
22
23
24
25
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/00400 Particles/00505 Building_Object.rb', line 16

def initialize(image, x, y, oy)
  @sprite = ::Sprite.new(Particles.viewport, true)
  @sprite.bitmap = ::RPG::Cache.autotile(image)
  @sprite.oy = @sprite.bitmap.height - oy - 16
  @x = (x + MapLinker.get_OffsetX) * 16
  @y = (y + MapLinker.get_OffsetY) * 16
  @real_y = (y + MapLinker.get_OffsetY) * 128
  @map_id = $game_map.map_id
  update
end

Instance Attribute Details

#disposedBoolean (readonly) Also known as: disposed?

If the building is disposed

Returns:

  • (Boolean)


7
8
9
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/00400 Particles/00505 Building_Object.rb', line 7

def disposed
  @disposed
end

#spriteSprite

The building sprite

Returns:



10
11
12
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/00400 Particles/00505 Building_Object.rb', line 10

def sprite
  @sprite
end

Instance Method Details

#dispose

Dispose the building



40
41
42
43
44
45
46
47
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/00400 Particles/00505 Building_Object.rb', line 40

def dispose
  return if disposed?

  @sprite.dispose unless @sprite.disposed?
  @sprite = nil
  @disposed = true
  Yuki::Particles.clean_stack
end

#update

Update the building position (x, y, z)



28
29
30
31
32
33
34
35
36
37
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/00400 Particles/00505 Building_Object.rb', line 28

def update
  return if disposed?
  return dispose if @map_id != $game_map.map_id

  dx = $game_map.display_x / 8
  dy = $game_map.display_y / 8
  @sprite.x = (@x - dx)
  @sprite.y = (@y - dy)
  @sprite.z = (@real_y - $game_map.display_y + 4) / 4 + 94
end