Search found 24 matches
- Sun Nov 06, 2011 8:13 pm
- Forum: Support and Development
- Topic: Moving the enemies
- Replies: 22
- Views: 7470
Re: Moving the enemies
Ok i see, thanks.
- Sun Nov 06, 2011 2:47 pm
- Forum: Support and Development
- Topic: Moving the enemies
- Replies: 22
- Views: 7470
Re: Moving the enemies
Thank you, this is working great.
Just to clear out things, this could be done also in the end of each level, like clear all table when it reaches the end right?
Just to clear out things, this could be done also in the end of each level, like clear all table when it reaches the end right?
Code: Select all
if level end then
table.remove(shot)
end
- Fri Nov 04, 2011 8:17 pm
- Forum: Support and Development
- Topic: Moving the enemies
- Replies: 22
- Views: 7470
Re: Moving the enemies
well, i did this: instead of ammo i changed to shot, and this works if only i shot once at a time and let the bullet get off the screen, but if i shot more times in a row then it gives an error saying. attempt to index field '?' (a nil value) for i = 1, #shot do shot[i].y = shot[i].y + 2 <---- here ...
- Thu Nov 03, 2011 3:45 pm
- Forum: Support and Development
- Topic: Moving the enemies
- Replies: 22
- Views: 7470
Re: Moving the enemies
Hello coders, i have a one more question related to this piece of code: for i = 1, #ammo do ammo[i].x = ammo[i].x + (dt * 300) end I have this code and to clear the items inside so the table doesn t get to big and slow i must clear those items as soon as they get off the screen, right? so to do that...
- Sat Oct 01, 2011 6:42 pm
- Forum: Support and Development
- Topic: Moving the enemies
- Replies: 22
- Views: 7470
Re: Moving the enemies
Ok, i think i got it, this piece of code:
is the part that is responsable for increase the number of items inside the table wright?
So I have to do the same at my var maxEnemies i think.
Here is my love file to see what i have done so far.
Code: Select all
ammo=[#ammo + 1]
So I have to do the same at my var maxEnemies i think.
Here is my love file to see what i have done so far.
- Sat Oct 01, 2011 4:54 pm
- Forum: Support and Development
- Topic: Moving the enemies
- Replies: 22
- Views: 7470
Re: Moving the enemies
So to have a slot of bullets in ammo table a should do something like this to work: ammo = {30} <------ or 50 or 300 wrigth? This way i have 30 shots, but this way when i reach the 30 bullets don't i have to do this? If #ammo >=30 then #ammo = 0 Does this work? #ammo or ammo[1] is the same thing? Or...
- Sat Oct 01, 2011 4:09 pm
- Forum: Support and Development
- Topic: Moving the enemies
- Replies: 22
- Views: 7470
Re: Moving the enemies
Thanks for this explanation and for the code, i didn´t try it yet, i'm trying to understand it first, but i don't understand this piece of code: for i = 1, #ammo do ammo[i].x = ammo[i].x + (dt * 300) end If you declare ammo = {}, isn't this an empty table? how can i have as enemys as i want? and thi...
- Thu Sep 29, 2011 4:19 pm
- Forum: Support and Development
- Topic: Moving the enemies
- Replies: 22
- Views: 7470
Re: Moving the enemies
Here is my little code:
Code: Select all
bullet = love.graphics.newImage("bullet.png")
fired = false
if keyboard.isDown('space') then
bulletX = playerX
bulletY = playerY
fired = true
end
if fired == true then
love.image.draw (x,y,bullet)
x=x+3
if x>= 630 then
fired=false
end
end
- Thu Sep 29, 2011 3:13 pm
- Forum: Support and Development
- Topic: Moving the enemies
- Replies: 22
- Views: 7470
Re: Moving the enemies
That worked great, this way i can change the number of enemies i want too, by the way, is there in love a good function to shoot that can be adapted to any kind of shooting game?
I have one but it doens't seem too eficient.
Thanks
I have one but it doens't seem too eficient.
Thanks
- Wed Sep 28, 2011 2:07 pm
- Forum: Support and Development
- Topic: Moving the enemies
- Replies: 22
- Views: 7470
Re: Moving the enemies
Ok i think i got it, one thing i notice is that after some loop thru the screen the enemies slows down like a pixel thru screen and it takes too much to get off.