Bullet Clumps and similar patterns (Having trouble with em)

A place for people with an interest in developing new shmups.
Post Reply
User avatar
ForteMP3
Posts: 178
Joined: Tue Feb 01, 2005 3:15 pm
Location: Somewhere in the Midwest.

Bullet Clumps and similar patterns (Having trouble with em)

Post by ForteMP3 »

Ah, once again I come across the issue of bullet patterns. I'm just not as good as the guys over at Cave and Raizing, eh?

Anyway, today I come asking about some more complex bullet patterns. I've begun to better grasp some of the simple ones, such as n-way spreads, criss crossing spreads, and lines, but I can't grasp some of the more complex spreads and clumps that are out there, and how one creates them.

Take the boss of DDP, Stage 2, for example.
http://www.shmups.com/beepreying/old/st ... 2boss.html
The unique shapes that come from that tank's main battery, as well as those needle/laser spreads, I'm trying to learn the basics behind creating bullet patterns like these. Ones that could almost be considered not just bullets, but an art form. Just what is the secret to coming up with unique stuff like this? Hell, IS there a secret?
YOU ARE APPROACHING THE TARGET OF ATTACK! THE MISSION STARTS NOW! ARE YOU READY?!
User avatar
russ
Posts: 177
Joined: Thu Apr 21, 2005 3:38 am
Location: Dallas area, TX

Post by russ »

I'm sort of in the same boat as you - not only are ideas for cool-looking patterns hard to come up with, you have to figure out how to program them, how to test them and adjust their difficulty for the section of the game that they appear in, and also how to effectively mix them with the type of boss you're fighting... i.e. DDP DOJ Stage 4 boss, how it has those side pods that contribute to the patterns, as well as the rotating discs in the middle.

Though the shooter I'm "developing" right now (I'm still learning, plus its far from being in an a playable state) is in Flash, which is a bit more visual than what you might be using (c++, java?). I wish I could help more. But good job with the game so far - it runs really smooth, graphics and controls are great, gameplay is excellent, the difficulty advances just right, and overall its wonderful. I've definitely got something to aspire to for my game :roll:
"No beer until you've finished your tequila!"
User avatar
raiden
Posts: 862
Joined: Tue Jan 25, 2005 11:41 pm
Location: Cologne
Contact:

Post by raiden »

I´ll try to describe the algorithm to develop bullet patterns by "painting":

you have a circle-shaped web, for example with 60 concentric circles, crossed with straight lines from the center leading outward spread across. Every circle represents a timeframe, so if your game is running with 60 frames per second, in this example you can create a pattern that is shot within 1 second. The lines just represent the direction in which bullets are shot.
Now, you can place bullets on the crossing points between the circles and lines, which the program stores in an array. I´d recommend bit-coding the pattern, otherwise memory usage will explode.
The pattern you created is then assigned to an enemy, who will shoot it at the time it is programmed to. The program counts timeframes through the array, and each frame the enemy shoots the bullets stored "on the circle" of that frame. To make things more interesting, you can vary bullet speed depending on the # of frames passed, creating "whiplash" bullets or patterns where the later parts overtake the early parts.

Regarding the 2nd pattern of your example:

this pattern needs a whole area from which it is shot to function. So you define a section on the boss, and for each bullet you determine a random (better: pseudo-random) position from which it is fired in an angle between -45 degrees and +45 degrees (if 0 means vertically down), with a random speed influenced by rank (if you want the DDP pattern, otherwise you can take a straight random number). The pattern moves extremely slow. I suspect they used a trick back then to move some bullets only every 2nd or 3rd frame, saving performance.
User avatar
nullpointer
Posts: 66
Joined: Tue Jan 25, 2005 11:12 pm

Post by nullpointer »

Bullet patterns arent too hard to code once you have written a system for hanldling bullets correctly. Its useful to have a look at how particle systems work to do this. Bullets have several key values, x,y position on screen and x,y velocity (the position increases by this velocity each frame), you may also want each bullet to hold a timer in itself that count each frame since its birth (for things like direction change or exploding into further patterns). Once you have set up this for a bullet object you can create bullet ojects using simple commands like

addbullet(startx,starty,velx,vely,type)

the only extra value used here is type, which allows you to specifiy a differnt graphic/size etc for the bullet created.

you can hen create simple bullet patterns by looping the creation of bullets
for instnce

for(i=1;i<10;i++)
{
addbullet(enemyx,enemyy,0,i,type);
}

this will make 10 bullets in a line that travel at increasing speed across the screen (making the line spread out as it fires)

Once you have managed this sort of trick it is easy to use different directions and speeds to create more complex bullet patterns.

If you want to make more circular patterns then u are going to need to use a bit of trigonometry to get them

velocityx=.1*sin(angleinradians);
velocityy=.1*cos(angleinradians);

this will calculate movement values for a bullet heading off at .1 speed in the angle direction specified in the brackets. Using this you can make loops where you send out bullets in subdivisions of a circle (every 10 degrees for inst) and endless other tricks to make spiral patterns and other type attacks.

If you are interested you can chek out my game demo endless fire (see the other post in the forum) to see how this might work

hope this helps.
User avatar
raiden
Posts: 862
Joined: Tue Jan 25, 2005 11:41 pm
Location: Cologne
Contact:

Post by raiden »

just a tiny detail concerning the trigonometry issue: you should store often used values, like the sin and cos values for angles between 0 and 360 in an array when starting the game. Calculating angles in real time while the game is running will slow it down considerably, especially when there are a lot of bullets. For the same reason, you should go for integer variables instead of floating point wherever possible. To reach a suitably fine scale of movement, you can take something like 100 times the X and Y screen size for coordinates, displaying it at 1/100 in your rendering engine. Division is another math function that takes a little longer, so multiplying with .01 might be more effective, but .01 is a floating point value, so it´s best to experiment with both options.
User avatar
TGK
Posts: 275
Joined: Mon Jun 27, 2005 6:15 am
Location: Canada

Post by TGK »

raiden wrote:just a tiny detail concerning the trigonometry issue: you should store often used values, like the sin and cos values for angles between 0 and 360...
Adding to this, I wonder if BulletML (is that what you use?) support bullets with varrying speed?

Much of Cave's patterns are possible only if the bullet speed follows a time based formula.

E.g.

... // somewhere inside the update function of bullet
this->UpdatePos(this->getSpeed(timestamp), this->getHeading())
This causes to me a sensation of badness. - Stormwatch
User avatar
TGK
Posts: 275
Joined: Mon Jun 27, 2005 6:15 am
Location: Canada

Re: Bullet Clumps and similar patterns (Having trouble with

Post by TGK »

ForteMP3 wrote:The unique shapes that come from that tank's main battery, as well as those needle/laser spreads, I'm trying to learn the basics behind creating bullet patterns like these.
The main atlry pink pattern is probably a bow shape pattern, with the middle part being semi random withing a certain width, these bullets all goes straight.

The main atlry blue pattern composes of 2 patterns, one of big bullet and one of slow bullet, further breaking this down you got smaller arc shaped spreads. In movement the speed of those bullets closer to you is slightly faster.

The laser spread is likely a cone spread with *slight* randomization in the angle of each needle.
This causes to me a sensation of badness. - Stormwatch
User avatar
ED-057
Posts: 1560
Joined: Fri Jan 28, 2005 7:21 am
Location: USH

Post by ED-057 »

To reach a suitably fine scale of movement, you can take something like 100 times the X and Y screen size for coordinates, displaying it at 1/100 in your rendering engine. Division is another math function that takes a little longer, so multiplying with .01 might be more effective
The 1337 way is to use not 100 but a power of two (eg. 256). Then you can just shift right x # of bits or drop the low byte.
Post Reply