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 » Thu May 28, 2015 10:40 pm

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 » Fri May 29, 2015 9:10 pm

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: 712
Joined: Sat Apr 26, 2014 7:46 pm

Re: How i delete and create a new object

Post by bobbyjones » Fri May 29, 2015 11:12 pm

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/
Check out my most recent medium post, please give feedback.
Link

vitail
Prole
Posts: 26
Joined: Thu Apr 09, 2015 8:37 pm

Re: How i delete and create a new object

Post by vitail » Sat May 30, 2015 5:22 pm

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 » Sat May 30, 2015 5:22 pm

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: 712
Joined: Sat Apr 26, 2014 7:46 pm

Re: How i delete and create a new object

Post by bobbyjones » Sat May 30, 2015 5:29 pm

The link works for me.
Check out my most recent medium post, please give feedback.
Link

bobbyjones
Party member
Posts: 712
Joined: Sat Apr 26, 2014 7:46 pm

Re: How i delete and create a new object

Post by bobbyjones » Sat May 30, 2015 5:32 pm

Google headchant invaders and you should find it.
Check out my most recent medium post, please give feedback.
Link

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 » Sat May 30, 2015 6:11 pm

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: 712
Joined: Sat Apr 26, 2014 7:46 pm

Re: How i delete and create a new object

Post by bobbyjones » Sat May 30, 2015 6:31 pm

Oh that sorry didn't understand.
Check out my most recent medium post, please give feedback.
Link

vitail
Prole
Posts: 26
Joined: Thu Apr 09, 2015 8:37 pm

Re: How i delete and create a new object

Post by vitail » Sat May 30, 2015 10:25 pm

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 7 guests