Flixel Forums

development => help => Topic started by: NateTheGreatt on Wed, Aug 3, 2011

Title: Realistic bullets via looping a sprite in a line - trouble with shotgun behavior
Post by: NateTheGreatt on Wed, Aug 3, 2011
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 :]
Title: Re: Realistic bullets via looping a sprite in a line - trouble with shotgun behavior
Post by: ETG on Thu, Aug 4, 2011
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.
Title: Re: Realistic bullets via looping a sprite in a line - trouble with shotgun behavior
Post by: NateTheGreatt on Fri, Aug 5, 2011
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.