-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtileclasses.rb
More file actions
58 lines (53 loc) · 1.29 KB
/
Copy pathtileclasses.rb
File metadata and controls
58 lines (53 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
class Tile
attr_accessor :x, :y, :width, :height
def initialize(window, x, y, width, height)
@x = x
@y = y
@width = width
@height = height
end
def tile_position( mouse_x, mouse_y )
@x = (mouse_x / 40).floor * 40
@y = (mouse_y / 40).floor * 40
end
def draw
@image.draw(@x, @y, ZOrder::UI)
end
def warp(x, y)
@x, @y = x, y
end
def under_point?(mouse_x, mouse_y)
mouse_x > @x and mouse_x < @x + 40 and
mouse_y > @y and mouse_y < @y + 40
end
end
class GrassTile < Tile
def initialize(window)
super(window, x, y, width, height)
@image = Gosu::Image.new(window, "media/grass.png", false)
end
end
class WaterTile < Tile
def initialize(window)
super(window, x, y, width, height)
@image = Gosu::Image.new(window, "media/water.png", false)
end
end
class DirtTile < Tile
def initialize(window)
super(window, x, y, width, height)
@image = Gosu::Image.new(window, "media/dirt.png", false)
end
end
class TilledDirtTile < Tile
def initialize(window)
super(window, x, y, width, height)
@image = Gosu::Image.new(window, "media/tilled_dirt.png", false)
end
end
class WetDirtTile < Tile
def initialize(window)
super(window, x, y, width, height)
@image = Gosu::Image.new(window, "media/wet_dirt.png", false)
end
end