Re: jumping tutorial?
Posted: Wed Nov 10, 2010 11:01 pm
I dont really want to use array maps, too cumbersome IMO. Can I just draw a rectangle for the ground?
Code: Select all
function draw_map()
for y=1, map_display_h do
for x=1, map_display_w do
love.graphics.draw(tile[map[y] [x]], x*tile_w, y*tile_h)
end
end
end
Mmm... I don't see map_x or map_y there. Not sure why you need them anywhere else.toaster468 wrote:uh sure, im guessing you are asking for draw_map() not love.draw()
Code: Select all
function draw_map() for y=1, map_display_h do for x=1, map_display_w do love.graphics.draw(tile[map[y] [x]], x*tile_w, y*tile_h) end end end
Code: Select all
-- given the coordinates of a cell on the map, return the x,y coordinates of it's top-left corner in world/screen maps.
-- example of use: x, y = map2world(x,y)
function map2world(mx,my)
-- fill this in
end
-- given an x,y coordinate on the screen/world, return the mx,my coordinates of the cell containing that point
-- example of use: mx, my = world2map(x,y)
function world2map(x,y)
-- fill this in
end
Code: Select all
function draw_map()
for my=1, map_display_h do
for mx=1, map_display_w do
local x,y = map2world(mx,my)
love.graphics.draw(tile[map[my][mx]], x,y)
end
end
end
Code: Select all
##########################################
# #
# #
# #
# # #### #
# #### # #
# 1 # 2 #
##########################################
Code: Select all
tile[map[y] [x]]
No, what's wrong with that?zac352 wrote:Is anyone else wondering about this? >_>Code: Select all
tile[map[y] [x]]