$tile = new Image("tile.png")
$size = 20
$w = 31
$h = 20
$blocks = {
:stone : [2, 0],
:air : [0, 0],
:dirt : [1, 0]
}
class Block
def new(id)
@id = id
end
def getId()
return @id
end
def setId(id)
@id = id
end
end
class Level
def new(w, h)
@map = []
@w = w
@h = h
initLevel()
//generateLevel()
end
def initLevel()
@map = []
@w.times() do |x|
@map[x] = []
@h.times() do |y|
@map[x][y] = new Block($blocks[:stone])
if rand(10) >= 5
@map[x][y] = new Block($blocks[:dirt])
end
end
end
end
def generateLevel()
@w.times() do |x|
@h.times() do |y|
if x == y
@map[x][y].setId($blocks[:stone])
end
end
end
end
def tick()
end
def render()
@w.times() do |x|
@h.times() do |y|
id = @map[x][y].getId()
drawImage( $tile, id[0]*$size, id[1]*$size, $size, $size, x*$size, y*$size )
end
end
end
end
level = new Level($w, $h)
onEachFrame() do
fill( :blue )
level.tick()
level.render()
end
Do you know Lua? If so, simply translate the code from Quby to Lua and you'll be 90% there, and we can help you with the final 10%. If not, you'll need to learn Lua first. I suggest reading Programming in Lua.
yes, i can, and i will: here.
Let me give you a hint, you will need to use the same thing for the classes as well... at least, that would be the easiest solution.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
I just think I'll second Robin's advice, and strongly insist upon it.
Robin wrote:Do you know Lua? If so, simply translate the code from Quby to Lua and you'll be 90% there, and we can help you with the final 10%. If not, you'll need to learn Lua first. I suggest reading Programming in Lua.
Yeah, go learn Lua first. At least, the basics.
Learn a bit about programmng, in general.
Then, come back on your game, and try to port it to Lua. At this time we can help. Otherwise, you will keep asking everytime to translate portions of your code for you, and obviously you are not going to learn anything.