def Level
should be class Level
Image.load_tiles(image_name, width, height)
$tile = Image.load_tiles("res/tile.png", 16, 16)
$tile[0].draw(pos_x, pos_y, some_z)
for first tile.tile_id = x % columns + y * columns
, where x/y is the tile you want to get and columns is number of columns in your tileset.
my_tileset = Image.new("tileset.png", 32, 32)
my_tileset
will be array containing tiles. This is how Gosu organizes it:my_tileset[4].draw(tile_x, tile_y, z)
require 'gosu'
$tile = Gosu::Image.load_tiles("res/tile.png", 16, 16)
class GameWindow < Gosu::Window
def initialize()
super(480, 480, false)
self.caption = "Pix2D"
end
def update()
#$level.tick()
end
def draw()
#$level.render()
$tile[ get_tile_index(0, 0) ].draw(0,0,0) #replace 0,0 with the indexes you want to use
end
def needs_cursor?
true
end
def get_tile_index(x,y)
columns = $tile.width / 16
return x % columns + y * columns
end
end
GameWindow.new.show
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill