Bullet Tracking
TheT
Member Posts: 80
Hi,
I'm working on a game where the player is in the center of the screen and enemies are approching from left and right (Platform Shooter). So, at the moment, when the player fires, bullets are spawned and moving towards the enemies, which will collide and destroy the enemies. However I assume that this spawning will take lot of cpu power when it comes to the IPhone so I'm searching for a way by checking which enemies is closed to the player and in which direction the player is looking and hit this enemies. So was going to do something like: substract Player.X from Enemies X and compare it with the other enemies (and if the value is negative it's to the right of the player) and check maybe with a min() which one is closed. However this would require to run through all enemies and check their values. So, does anybody know a better way to check which enemie is closer or may it be even better for performance to use the bullets as actors and check collision than running through the enemies with the math ?
I'm working on a game where the player is in the center of the screen and enemies are approching from left and right (Platform Shooter). So, at the moment, when the player fires, bullets are spawned and moving towards the enemies, which will collide and destroy the enemies. However I assume that this spawning will take lot of cpu power when it comes to the IPhone so I'm searching for a way by checking which enemies is closed to the player and in which direction the player is looking and hit this enemies. So was going to do something like: substract Player.X from Enemies X and compare it with the other enemies (and if the value is negative it's to the right of the player) and check maybe with a min() which one is closed. However this would require to run through all enemies and check their values. So, does anybody know a better way to check which enemie is closer or may it be even better for performance to use the bullets as actors and check collision than running through the enemies with the math ?
Comments
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
how many actors are you trying to have on screen? Check out my game, Z is for Zombie, its up in the game section above, it will give you an idea on how many actors I have on screen at once without any real problems.
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
Another question: How did you do it so that one bullet doesn't destroys two enemies at the same time if they are at almost the same place (if you did so) ?
I noticed this when I was doing spell effects. The effects spawn effortlessly, but the monsters that I spawn slug somewhat.
PS: Non the less would be stilll inteerested in a technique to for bullet tracking without actual bullets, any more thoughts ?
Do you now mean that you want your guy to punch the nearest enemy, rather than shoot them?
@mulcahy - word of warning - If your game will be available for ipod touch/normal iphone users then try and test your game on something *other* than a 3GS. I find it's nice to see it running great on that particular model, but that most games will suffer on lower models without optimisation, sometimes to the point of crashing very soon after starting.
Hope that helps, all,
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io