Making enemy's Die

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.
Post Reply
roggie12
Prole
Posts: 13
Joined: Sat May 25, 2013 6:00 pm
Location: The Matrix

Making enemy's Die

Post by roggie12 »

SkyWalker.zip
It's still really early in development. I'm adding in camera movement soon
(63.3 KiB) Downloaded 133 times
I've been having trouble with making enemy's and making them Die. To make enemy's I do:

Code: Select all

enemy={}
enemy.x =0
enemy.y =600
enemy.speed=3
enemy.health =20
enemy.damage =2
enemy.pic = love.graphics.newImage("textures/enemy.png")
But i don't know how to make it so that the player can hit the enemy and the enemy dies(Keeping in mind that i'm trying to make a game where there's unlimited enemies but i can figure out how to do that my self). I haven't required the enemy yet cuz i'm not done with the code.
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: Making enemy's Die

Post by Davidobot »

roggie12 wrote:
SkyWalker.zip
I've been having trouble with making enemy's and making them Die. To make enemy's I do:

Code: Select all

enemy={}
enemy.x =0
enemy.y =600
enemy.speed=3
enemy.health =20
enemy.damage =2
enemy.pic = love.graphics.newImage("textures/enemy.png")
But i don't know how to make it so that the player can hit the enemy and the enemy dies(Keeping in mind that i'm trying to make a game where there's unlimited enemies but i can figure out how to do that my self). I haven't required the enemy yet cuz i'm not done with the code.
When you add enemies add them to a table, that will make it easier to draw, move and remove since it is just a matter of called table.remove to remove them.
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
roggie12
Prole
Posts: 13
Joined: Sat May 25, 2013 6:00 pm
Location: The Matrix

Re: Making enemy's Die

Post by roggie12 »

Davidobot wrote:
roggie12 wrote:
SkyWalker.zip
I've been having trouble with making enemy's and making them Die. To make enemy's I do:

Code: Select all

enemy={}
enemy.x =0
enemy.y =600
enemy.speed=3
enemy.health =20
enemy.damage =2
enemy.pic = love.graphics.newImage("textures/enemy.png")
But i don't know how to make it so that the player can hit the enemy and the enemy dies(Keeping in mind that i'm trying to make a game where there's unlimited enemies but i can figure out how to do that my self). I haven't required the enemy yet cuz i'm not done with the code.
When you add enemies add them to a table, that will make it easier to draw, move and remove since it is just a matter of called table.remove to remove them.
Thanx for the advice
User avatar
Eamonn
Party member
Posts: 550
Joined: Sat May 04, 2013 1:29 pm
Location: Ireland

Re: Making enemy's Die

Post by Eamonn »

To make enemies die, remove them from the table! Problem solved! Add them into an index of the table, so you'd have enemy[1], then check to see if the player collided with the enemy, then remove them from the table! :D
"In those quiet moments, you come into my mind" - Liam Reilly
roggie12
Prole
Posts: 13
Joined: Sat May 25, 2013 6:00 pm
Location: The Matrix

Re: Making enemy's Die

Post by roggie12 »

Eamonn wrote:To make enemies die, remove them from the table! Problem solved! Add them into an index of the table, so you'd have enemy[1], then check to see if the player collided with the enemy, then remove them from the table! :D
Thanx
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 3 guests