I'm quite new to programming, this is my first time working with Lua, I just have a bit of experience with VB - by which I mean no more then the spam bot type stuff you'd expect. So don't expect anything clean or efficient, much less both. Anyway, my issue isn't so much of an issue as it is an optimization that doesn't work for some reason - love.graphics.newQuad shouldn't be called every single frame. I tried that on my netbook... just no. But I can't figure out how to make it only update on block changes. I have a boolean, newQuads, that is set to true for the first frame. It gets set to true if there's a block change and false at the end of love.draw(). If it's true, it sets up new quads with love.graphics.newQuad and renders them with love.graphics.drawq. If it's false, it just does love.graphics.drawq. I have a 3D table named quad_tiles with the tile layer, X axis, and Y axis respectively. I did this in a giant loop
Code: Select all
quad_tiles[k][i][j] = love.graphics.newQuad((string.byte(world_blocks[k][i][j]))*16,0,16,16,1024,16)
But for some reason, that strip of code has to be done every single frame, or else it crashes. Change line 47 of world_draw.lua to newQuads = false to reset it to false every frame to see what I mean. If you do that and hold left click in the top left corner somewhere immediately after opening the program, it'll constantly be placing a block and thus set newQuads to true every frame, so it won't crash until you let go of the left click.
A few things about the program:
It's not programmed well at all.
Up and down change layers, left and right pick blocks. Left click places, right removes. All blocks are placeable on all layers, and the collision layer will later have it's own unique gfx, with possibilities such as solid, swimmable, hurts, kills, and so on, which obviously won't get rendered in the game itself.
The level format is kinda weird, it's converted from 1-1.rtf to a table, but that's not always what's used. Here are some tips about world_data[x]:
Code: Select all
world_data[x]: ¦ Description
----------------------------------
1 ¦ Background tile data
2 ¦ Mainground tile data
3 ¦ Foreground tile data
4 ¦ Collision tile data
5 ¦ Map size X, in blocks
6 ¦ Map size Y, in blocks
7 ¦ Player starting block X
8 ¦ Player starting block Y
9 ¦ Background image file (as in, the full-size background, not the tiles)
10 ¦ Tile image file (as in, the tiles)
11 ¦ Width of tile set, in blocks (so the image size X / 16)
12 ¦ If 1 then background is static with blocks, if 2 it moves a bit (might have to be tilable)
I'm not 100% sure if that's accurate, (and not all values do anything yet, and I need to add more, like the music location which is hard coded atm) I have changed the format a bit several times. Also, string.byte(255) is the separator. The map was made in a hex editor, which explains the insanely small 4x4 placement grid, but it can be made into any size - I just haven't made a level creator just yet. You can change the BG tile data in a hex editor to 256 letters each and set the map size X and Y from 4 to 16 (I haven't tested different map sizes yet though.)
Finally, a few random things -
The IT module doesn't loop, I don't know how to get it to, I don't think B00 works.
esc quits, but now in 0.8.0 it throws an error, how do I make it quit now?
It used to have a frame limiter of 30 FPS, frame skipping is way beyond me, how do I implement that in 0.8.0 since the example on the wiki doesn't work?