Having a great time playing with the toolkit. Its a lot of fun and pretty easy too. What I'm trying to do is generate a maze using tiles and dumping it into a pass. Then I'll scroll around and look at it. Everything works but the origin I'm getting for my pass is not in the bottom left (my pass is bigger than the window) so I need to add a "strange_yoffset" variable on the y axis to fix it. I'm sure I'm doing something wrong as I'm guessing at how to do things but it seems correct.
pass = Outputs.new pass.height = 32*44 pass.width = 32*80 strange_yoffset = -32*22+16 pass.solids << [0, strange_yoffset, pass.width, pass.height, black]
Basically in the snipit above I want to make the entire pass black. To cover it I needed to hunt around to find the origin . In this case it was on the y axis a little more than half way up.
My questions are. Am I allowed to change the size of passes? Is this an intended/supported way to do things? If so should the origin reset itself or is there a way for me to reset the origin of the pass?
Full Source
$dragon.reset
def tick args
game, inputs, outputs, grid = args.game, args.inputs, args.outputs, args.grid
grid.origin_bottom_left!
game.maze ||= generate_maze
game.dx ||= 0
game.dy ||= 0
if game.tick_count == 1
pass = Outputs.new
pass.height = 32*44 # Making pass twice as big as the window
pass.width = 32*80
strange_yoffset = -32*22+16 # Why doesn't this = 0
pass.solids << [0, strange_yoffset, 32*80,32*44, black]
pass.target = 'maze'
44.times do |r|
80.times do |c|
pass.sprites << [c*32,r*32+strange_yoffset, 32, 32,"metadata/#{tile(game.maze[r][c])}.png"]
end
end
args.passes << pass
end
outputs.solids << [grid.rect, black]
outputs.sprites << [0+game.dx,0+game.dy,32*80,32*44,'maze']
game.dx += 10 if inputs.keyboard.key_held.left
game.dx -= 10 if inputs.keyboard.key_held.right
game.dy += 10 if inputs.keyboard.key_held.down
game.dy -= 10 if inputs.keyboard.key_held.up
end
def generate_maze
m = 44.map do |r|
r = 80.map do |c|
c = rand 100
end
end
end
def tile i
case i
when 0..50
'brown_tile'
when 51..60
'grey_tile'
when 61..95
'dgrey_tile'
when 96..99
'ship'
end
end
def white
[255,255,255]
end
def black
[0,0,0]
end