Game Development Reference
In-Depth Information
tile
.
draw(map_x, map_y,
0
)
else
@water
.
draw(map_x, map_y,
0
)
end
else
@water
.
draw(map_x, map_y,
0
)
end
end
end
end
# ...
private
# ...
def
tile_at
(x, y)
t_x
=
((x
/
TILE_SIZE
)
%
TILE_SIZE
)
.
floor
t_y
=
((y
/
TILE_SIZE
)
%
TILE_SIZE
)
.
floor
row
=
@map
[
t_x
]
row ? row
[
t_y
]
:
@water
end
# ...
end
Now the edge looks much better:
Map edge
Generating Tree Clusters
To make the map more fun to play at, we will generate some trees. Let's start with
Tree
class:
09-polishing/entities/tree.rb
1
class
Tree
<
GameObject
2
attr_reader
:x
,
:y
,
:health
,
:graphics
3