Omnimaga

General Discussion => Computer Programming => Technology and Development => Other Programming Languages => Topic started by: hellninjas on July 01, 2012, 08:24:58 pm

Title: [LOVE]Help with spawning boxes
Post by: hellninjas on July 01, 2012, 08:24:58 pm
Boxes don't spawn inside each other (They Spawn inside of each other, I need that to NOT happen)
Any suggestions on what I can do??

Later on im hoping to make it where:
1. all boxes are highlighted on mouse-over
2. you can drag your mouse around and create boxes
3. boxes don't spawn inside of each other (Working on)
4. selecting specific boxes and tell them where to move
5. animation for the movement of the boxes and them colliding with each other
6. boxes having specific properties
7. sprites instead of boxes xD.

Download is below!
Current Version 2
Title: Re: [LOVE]Help with highlighting
Post by: Juju on July 01, 2012, 08:32:07 pm
Yeah I see.

Move the for i=1,25 do line before when you check if the mouse is in a rectangle.
Title: Re: [LOVE]Help with highlighting
Post by: hellninjas on July 01, 2012, 08:38:50 pm
Yeah I see.

Move the for i=1,25 do line before when you check if the mouse is in a rectangle.
Moved it to the beginning of the love.draw() command, but still doesn't work. D:
Title: Re: [LOVE]Help with highlighting
Post by: Juju on July 01, 2012, 08:46:08 pm
Code: [Select]
function love.draw()
local mouseX,mouseY=love.mouse.getPosition()
love.graphics.draw(mouse,mouseX,mouseY)
for i=1,25 do
if mouseX>=varx[i] and mouseY>=vary[i] and mouseY<vary[i]+varh[i] and mouseX<varx[i]+varw[i] then
love.graphics.setColor(255,0,0,255)
love.graphics.rectangle("fill",varx[i],vary[i],varw[i],varh[i])
end
love.graphics.setColor(0,255,0,255)
love.graphics.rectangle("line",varx[i],vary[i],varw[i],varh[i])
end
end
It should look like this, it works for me.
Title: Re: [LOVE]Help with spawning boxes
Post by: hellninjas on July 01, 2012, 09:18:37 pm
Thanks Juju!
Now onto the next part!
I need to make it where boxes DON'T spawn inside each other.