So i wanted to get into this and stuff so i followed Headchants tutorial on how to make a space invaders clone.
It was a meager success, i can move the player around, the enemies move. However when i shoot an enemy
another goes. Its really weird and I dont know how to fix it yet know what is going wrong because i learned nothing from the tutorial.
So if anybody could help me figure out what is going wrong and maybe point me to a better tutorial i will be happy.
Heres the code so far: http://pastebin.com/eM8wHJZn
The wrong enemy disappears when I shoot it
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
The wrong enemy disappears when I shoot it
Last edited by Eclectic on Tue Jan 21, 2014 12:57 pm, edited 1 time in total.
Re: The wrong enemy disappears when I shoot it
Uhh, I think the problem is that your code is racist. Line 71. What the fuck?
Re: The wrong enemy disappears when I shoot it
Which one is disappearing? I'm assuming it isn't random; knowing which one goes is probably the first step to figuring it out
(If it's the one directly to the left or right of the hit one, you're probably suffering an offset problem or doing something wrong in detecting the collision.)
(If it's the one directly to the left or right of the hit one, you're probably suffering an offset problem or doing something wrong in detecting the collision.)
Re: The wrong enemy disappears when I shoot it
The problem with removing entries from is table is that the other entries get rearranged every time. So if you have a list of indices and remove one of them, then the following indices are not correct anymore.
Solve this by traversing the table backwards (make sure the indices in the list of dead enemies is decreasing)
Solve this by traversing the table backwards (make sure the indices in the list of dead enemies is decreasing)
Check out my blog on gamedev
Re: The wrong enemy disappears when I shoot it
Whoops i dont know how that ended up in my code, fixed the rather expletitive comments. I have nothing against different ethnicities, but apparently my alcohol triggered alter-ego does. Fahk. New link in the OP for you guys.
Re: The wrong enemy disappears when I shoot it
That Line 71... That was unexpected to see such stuff in a source code of a game.
Github: https://github.com/chroteus
Who is online
Users browsing this forum: Bing [Bot] and 0 guests