Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Tilemap
- TILESIZE = 32
- def initialize(viewport, width, height, layer_count)
- @viewport = Viewport.new(0, 0, 544, 416) # // You probably don't need this...
- @data = Array.new(width).map! { Array.new(height).map! { Array.new(layer_count).map! { 0 } } }
- @width = width
- @height = height
- @layer_count = layer_count
- @layers = []
- @layer_count.times { |i|
- @layers[i] = Plane.new( @viewport )
- @layers[i].bitmap = Bitmap.new(TILESIZE*width, TILESIZE*height) # // Normally wurks under 2000 x 2000 pixels
- }
- end
- def draw_tile(layer, x, y, bitmap, sourcerect)
- layer.bitmap.blt(x, y, bitmap, sourcerect)
- end
- def update_tiles
- for x in 0...@width
- for y in 0...@height
- for z in 0...@layer_count
- tileid = @data[x][y][z]
- draw_tile(@layers[z], x*TILESIZE, y*TILESIZE, tile_bitmap(tileid), tile_rect(tileid))
- end
- end
- end
- end
- def tile_bitmap(tileid)
- return Bitmap.new # // Need to edit this
- end
- def tile_rect(tileid)
- return Rect.new() # // Need to edit this
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment