How i delete and create a new object

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
vitail
Prole
Posts: 26
Joined: Thu Apr 09, 2015 8:37 pm

How i delete and create a new object

Post 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
User avatar
Kingdaro
Party member
Posts: 395
Joined: Sun Jul 18, 2010 3:08 am

Re: How i delete and create a new object

Post 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.
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

Re: How i delete and create a new object

Post 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/
vitail
Prole
Posts: 26
Joined: Thu Apr 09, 2015 8:37 pm

Re: How i delete and create a new object

Post 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
vitail
Prole
Posts: 26
Joined: Thu Apr 09, 2015 8:37 pm

Re: How i delete and create a new object

Post 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:
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

Re: How i delete and create a new object

Post by bobbyjones »

The link works for me.
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

Re: How i delete and create a new object

Post by bobbyjones »

Google headchant invaders and you should find it.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: How i delete and create a new object

Post by Robin »

The link to the next part is broken and should be http://www.headchant.com/2010/12/31/lov ... 2-pew-pew/
Help us help you: attach a .love.
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

Re: How i delete and create a new object

Post by bobbyjones »

Oh that sorry didn't understand.
vitail
Prole
Posts: 26
Joined: Thu Apr 09, 2015 8:37 pm

Re: How i delete and create a new object

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 137 guests