Bullet Tracking

TheTTheT Member Posts: 80
edited November -1 in Working with GS (Mac)
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 ?

Comments

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    In my game I have the player shooting hundreds of bullets and I don't really ever run into a problem. I have my bullets as actors, and when they collide with an an enemy they both get destroyed.
  • TheTTheT Member Posts: 80
    IPhone ?
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    yea, I'm playing on the iPhone 3gs.

    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.
  • TheTTheT Member Posts: 80
    Mh, okay. But I heard it was really hard on resources on the IPhone, so maybe with a regular Iphone 1G or Ipod there would be more problems ? I have like about 15 actors continuos moving + the bullets, would be about 20-25 moving actors + particle actors, well would make up to about 30-35.
    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) ?
  • JGary321JGary321 Member Posts: 1,246
    Bullets should spawn fine. Spawning works very easily with actors that only have a few rules. When your actor has 15-20 rules, it chugs. But if it has like 1-5 rules you would be fine.

    I noticed this when I was doing spell effects. The effects spawn effortlessly, but the monsters that I spawn slug somewhat.
  • TheTTheT Member Posts: 80
    Alright, that's cool. Thanks. How's about spawning enemies with like more rules, because I have about up to 10 enemies which are continuos respawning ?
    PS: Non the less would be stilll inteerested in a technique to for bullet tracking without actual bullets, any more thoughts ?
  • quantumsheepquantumsheep Member Posts: 8,188
    Non-bullet bullet tracking?

    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

  • TheTTheT Member Posts: 80
    Yes, excatly. But it´s like firing, just without bullet actors flying around :)
Sign In or Register to comment.