Author Topic: Realistic bullets via looping a sprite in a line - trouble with shotgun behavior  (Read 1022 times)

NateTheGreatt

  • Member
  • **
  • Posts: 83
  • Karma: +0/-0
  • smell the sound
    • View Profile
    • n8bit
I've been at this for the past few days now. I'm making a top-down zombie shooter and I wanted realistic behaving bullets. I achieved this by iterating a small 1x1px sprite down a line when the mouse is clicked and checking for collisions on each loop-around. This worked beautifully for single-shot weapons and even automatic weapons. The problem I'm running into is shotgun-like behavior. What I did for that was send out this sprite to iterate down 6 different lines. The problem with this is that it lags before every shot, and lags to HELL if spammed. The cleanup is pristine, though, because the FPS goes back up when the shot is done iterating.

I tried something called tunneling, graciously suggested by someone on #flixel, which is basically splitting up the loop into different frames so it doesn't do it all in one frame while retaining most of the bullets instantaneous behavior. I had high hopes for this method, but alas: it still lags when the shotgun bullets go off, this time the lag is a bit more choppy instead of pushing one solid lag spike.

So: Can anyone suggest a way I could get some realistic shotgun shells off? Preferably with this technique but other techniques are perfectly welcome :]
"A designer knows he has achieved perfection not when there is nothing left to add, but when there is nothing left to take away."
-Antoine de Saint-Exupery

ETG

  • Active Member
  • ***
  • Posts: 115
  • Karma: +0/-0
    • View Profile
Why not model a bullet as a line segment?

You'll probably need to insert your own collision check for that, but I can't think of a better way.

NateTheGreatt

  • Member
  • **
  • Posts: 83
  • Karma: +0/-0
  • smell the sound
    • View Profile
    • n8bit
Why not model a bullet as a line segment?

You'll probably need to insert your own collision check for that, but I can't think of a better way.

Yeah, that'll be my next move I guess.
"A designer knows he has achieved perfection not when there is nothing left to add, but when there is nothing left to take away."
-Antoine de Saint-Exupery