Page 1 of 1

Connection Paint

Posted: Fri Jan 06, 2012 12:43 am
by Mkalo
Image

A picture is worth a thousand words.

Click to able or disable connections.

If you like change the configurations of the game and put it full screen :) I like that...

Re: Connection Paint

Posted: Fri Jan 06, 2012 2:05 am
by MarekkPie
I like it. I attempted to make the check 2 squares instead of 1 and almost got it, but then some stupid bugs got in the way and I realized I should be debugging my game instead. :)

Re: Connection Paint

Posted: Fri Jan 06, 2012 2:44 am
by Mkalo
Hmm there is, i think.

Re: Connection Paint

Posted: Fri Jan 06, 2012 3:07 am
by MarekkPie
I was thinking more along the lines of something you could change via a menu. Set the size of the spatial hash (I think that's the name for what you are doing, but maybe not), then the game will build the "dirs".

Something like:

Code: Select all

for i = -size, size do
  for j = -size, size do
    table.insert(dirs, {i,j})
  end
end

Re: Connection Paint

Posted: Fri Jan 06, 2012 12:06 pm
by Nixola
I've got an Intel graphic card and I can't see 1-pixel-wide horizontal or vertical lines...

Re: Connection Paint

Posted: Fri Jan 06, 2012 12:16 pm
by Nixola
P.S: try changing this

Code: Select all

local GAME_GRID = {

{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

}
with this:

Code: Select all

local GAME_GRID = {}
for y = 1, math.ceil(love.graphics.getHeight() / 20) do
	GAME_GRID[y] = {}
	for x = 1, math.ceil(love.graphics.getWidth() / 20) do
		GAME_GRID[y][x] = 0
	end
end
I'm playing on my 1024x600 netbook monitor now ^^

Re: Connection Paint

Posted: Tue Jan 10, 2012 8:44 am
by ivan
Pretty cool. I have a prototype that's quite similar to your app.
Just a small suggestion:

Code: Select all

function checkAround(px, py)
    local dirs = {
    [1] = {0, -1},
    [2] = {1, -1},
...
It's usually better to allocate tables that don't change only once.
Lua is an interpreted language so it doesn't know that 'dirs' is constant so it will recreate the table each time you call checkAround.
Secondly, you might want to look into neightbor valuing to represent the grid:
http://www.saltgames.com/2010/a-bitwise ... -tilemaps/
In short, instead of 0 and 1, each tile could have a value between 0-256 (2^8) to represent which adjacent nodes it's connected to.