Beginner Questions: Drawing with Lua and syntax
Posted: Mon Aug 06, 2012 9:24 pm
Hi, I'm pretty new to Lua and love2d but have used other programming languages (PHP, Javascript and Powershell) for a bit.
I'm planning to programm a little game for practise that is like draw something. I hope to get some more knowledge in a coordinate system and some networking.
I imagined it like this:
Spawn a coordinate system that looks something like this: grid[x][y] = set (for the start with set/unset, later maybe with colors)
On love.mousepressed get x and y and set the surrounding positions in the coordination system.
When the image is finished find some way to send it to a server with a sender a recipient name. As soon as the recipient connects to the server the data gets pushed or downloaded.
Well, that is the plan but I kinda already have problems with the coordinate system.
I tried several ways to create one in the love.load with every position set to "unset".
If this is a bad idea please tell me how to do it better.
What I tried so far:
Also some other variations but they were all kinda unsuccessful.
If there is another thread for trivial syntax questions like this one, please redirect me there.
I'm planning to programm a little game for practise that is like draw something. I hope to get some more knowledge in a coordinate system and some networking.
I imagined it like this:
Spawn a coordinate system that looks something like this: grid[x][y] = set (for the start with set/unset, later maybe with colors)
On love.mousepressed get x and y and set the surrounding positions in the coordination system.
When the image is finished find some way to send it to a server with a sender a recipient name. As soon as the recipient connects to the server the data gets pushed or downloaded.
Well, that is the plan but I kinda already have problems with the coordinate system.
I tried several ways to create one in the love.load with every position set to "unset".
If this is a bad idea please tell me how to do it better.
What I tried so far:
Code: Select all
grid = { }
for xInit = 0, 799, 1 do
for yInit = 0, 599, 1 do
grid.xInit = {}
grid.xInit.yInit = "unset"
end
end
Code: Select all
grid = { }
xtemp = 0
ytemp = 0
for xInit = 0, 799, 1 do
ytemp = 0
for yInit = 0, 599, 1 do
line = {[xtemp] = {[ytemp] = "unset"}}
table.insert(line, grid)
ytemp = ytemp + 1
end
xtemp = xtemp + 1
end
If there is another thread for trivial syntax questions like this one, please redirect me there.