Lacking Information II

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
AWizardDidIt
Prole
Posts: 14
Joined: Wed Sep 16, 2009 9:55 am

Lacking Information II

Post by AWizardDidIt »

Awhile back, I posted my original "Lacking Information" topic and got this reply, among others:
http://love2d.org/forums/viewtopic.php? ... 902#p19456

Now to humiliate myself a bit: After getting the time I needed to try out this mapping approach, I attempted a map with four 16*16 tiles with this method, putting everything into the main.lua file to try and see if it would work 'out-of-box', but what I ended up with is a completely blank window, and while it is a very nice window, I'm hoping I'll get some sort of idea of why it didn't contain the intended testmap. I apologize for how ridiculous my mistake/whatever will undoubtedly be, but I haven't had a great deal of time to work with LÖVE (or Lua, really, though I have a bit of experience with Python and C, not that I'd use pygame or c to do this stuff).

If I can get this resolved, it should end my troubles once and for all, since I've already got a fair idea of how to manage other things (and can more-easily find samples/tutorials/etc for the things I don't). I'd rather not stoop to using a generic tilemap editor such as Tiled or Mappy or whatever, since I seriously dislike relying on things like that when I can do without, so I'm very grateful for any information I can get. :D
User avatar
nevon
Commander of the Circuloids
Posts: 938
Joined: Thu Feb 14, 2008 8:25 pm
Location: Stockholm, Sweden
Contact:

Re: Lacking Information II

Post by nevon »

Tiled is pretty great. You should consider using it once you've gotten further.

As for your problem, it'd be helpful if you would post your code.
AWizardDidIt
Prole
Posts: 14
Joined: Wed Sep 16, 2009 9:55 am

Re: Lacking Information II

Post by AWizardDidIt »

Understood, sorry, here's the main.lua test-file I was using (just to try and get a map to appear):

Code: Select all

tileimages = {
    love.graphics.newImage("tile1.png"),  --Wall tile
    love.graphics.newImage("tile2.png"),  --Floor tile
    love.graphics.newImage("tile8.png"),  --Window tile
    love.graphics.newImage("tile5.png"),  --Column tile
}
tilesize = 16
map = {
   {1,1,3,1,1,1,3,1,1},
   {1,2,2,2,2,2,2,2,1},
   {1,2,2,2,2,2,2,2,1},
   {1,2,2,4,2,4,2,2,1},
   {3,2,2,2,2,2,2,2,3},
   {1,2,2,4,2,4,2,2,1},
   {1,2,2,2,2,2,2,2,1},
   {1,2,2,2,2,2,2,2,1},
   {1,1,3,1,1,1,3,1,1},
}
function love.draw()
   for x, row in pairs(map) do
      for y, tile in pairs (row) do
         love.graphics.draw(tileimages[tile], x*tilesize, y*tilesize)
      end
   end
end
I wouldn't be surprised if this were wrong on five or more levels, honestly. As for Tiled, I am rather familiar with it, but I don't care much for map editors in general (otherwise, I'd probably be using something more like Sphere RPG Engine or something w/ Wine or whatever). Basically, it's just a roughly-assembled/changed copypasta of what I was shown before, just to see if it works. Since it obviously doesn't (but doesn't cough out any errors), I felt the need to ask. I also tried it as two separate files with the function love.draw() in its own file, but that doesn't necessarily work either.
User avatar
bmelts
Party member
Posts: 380
Joined: Fri Jan 30, 2009 3:16 am
Location: Wiscönsin
Contact:

Re: Lacking Information II

Post by bmelts »

A few pieces of advice:

The way your table's laid out, I'd recommend switching the order of your for loops - each subtable is a row, and the row's index corresponds to its y value, so it'd be better to iterate over y and then x.

Don't use pairs here. Pairs is for unordered tables using non-array keys. That is not the usage case here. Use ipairs instead - that guarantees the map will be iterated over in order.

The changes:

Code: Select all

function love.draw()
   for y, row in ipairs(map) do
      for x, tile in ipairs(row) do
         love.graphics.draw(tileimages[tile], x*tilesize, y*tilesize)
      end
   end
end
Try that.
AWizardDidIt
Prole
Posts: 14
Joined: Wed Sep 16, 2009 9:55 am

Re: Lacking Information II

Post by AWizardDidIt »

No effect can be seen from that change. There are still no errors or whatever, but it still just shows the same window-of-emptiness from before. @_@; I don't know quite what it is, but I'm apparently missing something here.
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Lacking Information II

Post by tentus »

Are you certain that you haven't set the color to black or something? It's pretty easy to overlook a small rendering mistake like that.
Kurosuke needs beta testers
AWizardDidIt
Prole
Posts: 14
Joined: Wed Sep 16, 2009 9:55 am

Re: Lacking Information II

Post by AWizardDidIt »

All the code I was using is right there in what I put in my post, plus the changes I made based on the response below that. I now realise I must have needed more than that to get the map to display (which was all I'm attempting with this code and its images at the moment). What might I be missing if all I used was that code and some images? @_@;
User avatar
nevon
Commander of the Circuloids
Posts: 938
Joined: Thu Feb 14, 2008 8:25 pm
Location: Stockholm, Sweden
Contact:

Re: Lacking Information II

Post by nevon »

Are the images all 16x16px?
User avatar
Lafolie
Inner party member
Posts: 809
Joined: Tue Apr 05, 2011 2:59 pm
Location: SR388
Contact:

Re: Lacking Information II

Post by Lafolie »

I downloaded your code and adapted it to use my personal images. It works fine with the changes suggested here. I'll upload the .love file and a screenshot.

Image

Edit: Yeah, you could be suffering from http://love2d.org/wiki/PO2_Syndrome

But then, in your code you specify the tile size to be 16 x 16. Hmm.
Attachments
awizarddidit.love
(54.56 KiB) Downloaded 172 times
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
AWizardDidIt
Prole
Posts: 14
Joined: Wed Sep 16, 2009 9:55 am

Re: Lacking Information II

Post by AWizardDidIt »

Yours seems to show up as black nothingness as well. I'm on a dell inspiron desktop 570 running linux mint 64 bit (was running debian testing 64, but figured that might be affecting it so I installed mint to discover there is no change). There's definitely something wrong with my computer, huh?

I've attached my maptest this time, does it work for any of you?
Attachments
maptest.love
(1.92 KiB) Downloaded 153 times
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 5 guests