Grid placing...
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Grid placing...
Hello! I am new to love2d but I have been messing with it for about 2 weeks or so, so I kind of know the basics. but is there any way to make a grid type thing where you can place images and make them line up like sprites? thanks!
Re: Grid placing...
You'd probably have to draw one yourself.
I draw grids from time to time, and it's usually a simple operation. You need two FOR loops, and you increment either based on a fraction of the screen size or a number of pixels, depending on your intent.
So if your window is 1920x1080, and you want a 32x32 grid...
To actually place objects on the grid, you'll need to multiply by the grid column. So if you want a sprite in column 3, row 5:
or, in a more proper style:
of course, you'll probably want to make Grid an object, so
I draw grids from time to time, and it's usually a simple operation. You need two FOR loops, and you increment either based on a fraction of the screen size or a number of pixels, depending on your intent.
So if your window is 1920x1080, and you want a 32x32 grid...
Code: Select all
gridSize=32
for x=0, 1920, gridSize do
love.graphics.line(x, 9, x, 1080)
end
for y=0, 1080, gridSize do
love.graphics.line(0, y, 1920, y)
end
Code: Select all
sprite.x = 3 * 32
sprite.y = 5 * 32
Code: Select all
sprite.x = sprite.gridX * gridSize
sprite.y = sprite.gridY * gridSize
Code: Select all
sprite.x = sprite.gridX * Grid.width
sprite.y = sprite.gridY * Grid.height
Who is online
Users browsing this forum: Bing [Bot] and 8 guests