Page 1 of 2

How i delete and create a new object

Posted: Thu May 28, 2015 10:40 pm
by vitail
i want to create a bullet and if the bullet keep off the screen, it deletes.

i'm noob help me :(

Code: Select all

	timer = timer - 1 * dt
	if timer = 0 then
		canShoot = true
	end

	if love.keyboard.isDown(" ","z") and canShoot then
		canShoot = false
		timer = 100
		bullet = {x = player.x + player.img:getWidth() / 2, y = player.y, img = bulletImg }
	end

end

function love.draw()
	love.graphics.draw(player.img, player.x, player.y)
end
i'm noob programming. :c

Re: How i delete and create a new object

Posted: Fri May 29, 2015 9:10 pm
by Kingdaro
Post the entire .love file for your game? If you're unsure of how to make that, look here. That's the best way for us to help you, to be able to see the entirety of your code and run it as well.

Re: How i delete and create a new object

Posted: Fri May 29, 2015 11:12 pm
by bobbyjones
You need a table to store your objects. And then you would iterate through the table and draw and update those objects. Follow this brief tutorial series it will show you the basics of objects and arrays
http://www.headchant.com/2010/11/27/lov ... -must-die/

Re: How i delete and create a new object

Posted: Sat May 30, 2015 5:22 pm
by vitail
Kingdaro wrote:Post the entire .love file for your game? If you're unsure of how to make that, look here. That's the best way for us to help you, to be able to see the entirety of your code and run it as well.
i want to create and delete objects, i want to make a bullet in my first game with LÖVE2D

Re: How i delete and create a new object

Posted: Sat May 30, 2015 5:22 pm
by vitail
bobbyjones wrote:You need a table to store your objects. And then you would iterate through the table and draw and update those objects. Follow this brief tutorial series it will show you the basics of objects and arrays
http://www.headchant.com/2010/11/27/lov ... -must-die/
Not Found

The requested URL /2010/12/31/love2d-–-tutorial-part-2-pew-pew/ was not found on this server.

deleted page :cry:

Re: How i delete and create a new object

Posted: Sat May 30, 2015 5:29 pm
by bobbyjones
The link works for me.

Re: How i delete and create a new object

Posted: Sat May 30, 2015 5:32 pm
by bobbyjones
Google headchant invaders and you should find it.

Re: How i delete and create a new object

Posted: Sat May 30, 2015 6:11 pm
by Robin
The link to the next part is broken and should be http://www.headchant.com/2010/12/31/lov ... 2-pew-pew/

Re: How i delete and create a new object

Posted: Sat May 30, 2015 6:31 pm
by bobbyjones
Oh that sorry didn't understand.

Re: How i delete and create a new object

Posted: Sat May 30, 2015 10:25 pm
by vitail
Robin wrote:The link to the next part is broken and should be http://www.headchant.com/2010/12/31/lov ... 2-pew-pew/
Nice, thanks.