Class: DXRuby::Tiled::FlippedTile

Inherits:
Object
  • Object
show all
Defined in:
lib/dxruby_tiled/tile.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tile, tileid, hex = false) ⇒ FlippedTile

Returns a new instance of FlippedTile.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/dxruby_tiled/tile.rb', line 61

def initialize(tile, tileid, hex = false)
  @tile = tile
  if hex
    @scale_x, @scale_y, @angle = case tileid & 0xf0000000
    when 0x10000000 then [ 1,  1, 120]
    when 0x20000000 then [ 1,  1,  60]
    when 0x30000000 then [-1, -1,   0]
    when 0x40000000 then [ 1, -1,   0]
    when 0x50000000 then [-1,  1, 300]
    when 0x60000000 then [-1,  1, 240]
    when 0x70000000 then [-1,  1,   0]
    when 0x80000000 then [-1,  1,   0]
    when 0x90000000 then [-1,  1, 120]
    when 0xa0000000 then [-1,  1,  60]
    when 0xb0000000 then [ 1, -1,   0]
    when 0xc0000000 then [-1, -1,   0]
    when 0xd0000000 then [ 1,  1, 300]
    when 0xe0000000 then [ 1,  1, 240]
    when 0xf0000000 then [ 1,  1,   0]
    end
  else
    @scale_x, @scale_y, @angle = case tileid & 0xe0000000
    when 0x20000000 then [ 1, -1, 90]
    when 0x40000000 then [ 1, -1,  0]
    when 0x60000000 then [-1, -1, 90]
    when 0x80000000 then [-1,  1,  0]
    when 0xa0000000 then [ 1,  1, 90]
    when 0xc0000000 then [-1, -1,  0]
    when 0xe0000000 then [-1,  1, 90]
    end
  end
  extend DXRuby::Tiled::DiagonallyFlippedTile if @angle == 90
end

Instance Attribute Details

#angleObject (readonly)

Returns the value of attribute angle.



59
60
61
# File 'lib/dxruby_tiled/tile.rb', line 59

def angle
  @angle
end

#scale_xObject (readonly)

Returns the value of attribute scale_x.



59
60
61
# File 'lib/dxruby_tiled/tile.rb', line 59

def scale_x
  @scale_x
end

#scale_yObject (readonly)

Returns the value of attribute scale_y.



59
60
61
# File 'lib/dxruby_tiled/tile.rb', line 59

def scale_y
  @scale_y
end

#tileObject (readonly)

Returns the value of attribute tile.



59
60
61
# File 'lib/dxruby_tiled/tile.rb', line 59

def tile
  @tile
end

Instance Method Details

#adjusted_offset_yObject



107
# File 'lib/dxruby_tiled/tile.rb', line 107

def adjusted_offset_y; @tile.adjusted_offset_y; end

#collisionObject



111
# File 'lib/dxruby_tiled/tile.rb', line 111

def collision; @tile.collision; end

#collision=(value) ⇒ Object



112
# File 'lib/dxruby_tiled/tile.rb', line 112

def collision=(value); @tile.collision = value; end

#collision_enableObject



113
# File 'lib/dxruby_tiled/tile.rb', line 113

def collision_enable; @tile.collision_enable; end

#collision_enable=(value) ⇒ Object



114
# File 'lib/dxruby_tiled/tile.rb', line 114

def collision_enable=(value); @tile.collision_enable = value; end

#heightObject



102
# File 'lib/dxruby_tiled/tile.rb', line 102

def height; @tile.height; end

#imageObject



103
# File 'lib/dxruby_tiled/tile.rb', line 103

def image; @tile.image; end

#offset_xObject



105
# File 'lib/dxruby_tiled/tile.rb', line 105

def offset_x; @tile.offset_x; end

#offset_yObject



106
# File 'lib/dxruby_tiled/tile.rb', line 106

def offset_y; @tile.offset_y; end

#original_imageObject



104
# File 'lib/dxruby_tiled/tile.rb', line 104

def original_image; @tile.original_image; end

#render(x, y, target = DXRuby::Window, z_index = 0) ⇒ Object Also known as: draw



95
96
97
98
# File 'lib/dxruby_tiled/tile.rb', line 95

def render(x, y, target=DXRuby::Window, z_index = 0)
  target.draw_ex(x + offset_x, y + adjusted_offset_y, @tile.image,
                 { scale_x: @scale_x, scale_y: @scale_y, angle: @angle, z: z_index })
end

#tilesetObject



108
# File 'lib/dxruby_tiled/tile.rb', line 108

def tileset; @tile.tileset; end

#to_sprite(x, y) ⇒ Object



116
117
118
# File 'lib/dxruby_tiled/tile.rb', line 116

def to_sprite(x, y)
  TileObject.new(x, y, self, rotation: @angle)
end

#typeObject



109
# File 'lib/dxruby_tiled/tile.rb', line 109

def type; @tile.type; end

#type=(value) ⇒ Object



110
# File 'lib/dxruby_tiled/tile.rb', line 110

def type=(value); @tile.type = value; end

#widthObject



101
# File 'lib/dxruby_tiled/tile.rb', line 101

def width; @tile.width; end