What would the best solution be for creating patterns for bullets fired in a shoot 'em up game?
Should I hard code values into arrays?
The kind of patterns I want to create are for bosses like in the games Strikers 1945, Aero Fighters etc.
What would the best solution be for creating patterns for bullets fired in a shoot 'em up game?
Should I hard code values into arrays?
The kind of patterns I want to create are for bosses like in the games Strikers 1945, Aero Fighters etc.
Load the values from a file. Do not, do not, hard code them.
Away.
Well those bullet patterns are created by scripts. Think of several different basic bullet movements like move, circle, speed up, etc. Make functions that operate on the bullets in this manner. Then in your boss script you can do this.
MOVE bullet1 TO x,y
CIRCLE bullet1 player
In this fashion you could easily create some complex bullet moves and boss moves. Of course you will have to write a small script interpreter but this should not be too hard.
I've been toying with this equation for a bullet pattern.
It involves a very short period sign wave : /\/\/\/\/\/\/\/\/.
It involves an increasing amplitude of the sign wave over period of time of continuous fire.
Basicly you move the bullets pitch up and down (after every shot from the first [the first should be dead on]) based on the length of time since the player pressed fire, and your sign wave. The amplitude of your sign wave should increase every few frames of continous fire. The left and right yaw of the bullets is controlled via a simler sign wave, that doesnt change. It too has a short periods. You just create random values of time periods. This should create a nice jerky - apparantly random variation of bullet patterns.
c++->visualc++->directx->opengl->c++;
(it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)
You could use a "cone of fire" idea. Basically you make a cone, and the bullet will travel and a random spot through the cone. This is more for a first person shoot (half-life uses this) but you could make it work for other styles of games.
I think I'm gonna use BulletML. I've downloaded a parser, but the thing is I don't know how to use it 'cos the readme file is in Japanese, so I was wandering if there's anyone who can translate the for me? (It's not that much)
Here's a link to the file:
http://user.ecc.u-tokyo.ac.jp/~s3155...tml/README.txt
Possibly, but my japanese is bad so it would take a long time. If I run out of things to do this weekend I will.
You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.
Has anybody thought of precalculating an xyz coord table based on rand() and sin() and cos() for the coordinates at program startup? This would generate a conical pattern. Simply increase the randomness the further you go in the table. How many holes do you need? Do 30. then whenever you need bullet holes, you can start at the beginning of the table and go through it until the user lets go of the "trigger".
Since shot randomness is based on grade of ammunition and primarily thermal effects of the barrel warming up and the length of the barrel, a cooler barrel is more accurate, while a hot barrel might generate more "flyers".
It is not the spoon that bends, it is you who bends around the spoon.
one also cannot forget how good the rifling of the barrel is, how clean it is, and the different gas exhaust systems help determine the trajectory of a round, as well as the person stance(which include how he is holding and operating the firearm). one could theoretically make a huge C++ library based on nothing except firearms.length of the barrel,
EDIT:
or one could simply include as part of the guns struct all these different parameters.
And all of this is much too complex simply to emulate shots being fired at an object which will happen millions of times in a game. You could emulate a good bullet with a simplified model and w/o all the extremely slow and cumbersome physics equations. Who cares what gravity really is - just increase the y component of the bullet and each object in the game by a pre-set amount and call it gravity. No one will ever know the diff.
Bullet drop is so minimal over short distances that most games don't even bother. Spray pattern is a very good idea though and could produce some very quick shotgun-like patterns on your walls.
You could create a bitmap mask out of this pattern and then blit it to the texture or combine it with the texture or you could draw the pattern in real time and alpha blend or do some other blending function with the wall texture.Code:for (int i=0;i<MAXPATTERN;i++) { int radius=random(MAXRADIUS); int angle=random(360); //or rand() % 360 if no random() shotgun(i).x=cos(angle*PI/180)*radius; shotgun(i).y=sin(angle*PI/180)*radius; }
then in the game:
Data types are prob conflicting but you get the idea.Code:for (int i=0;i<MAXPATTERN;i++) { bx=WhereBulletHitWall.x; by=WhereBulletHitWall.y; int sprayx=(double)bx+shotgun(i).x; int sprayy=(double)by+shotgun(i).y; int texturex=(int)sprayx % texturemaxx; int texturey=(int)sprayy % texturemaxy; AlphaBlend (TextureWeHit,BulletHoleColor,AlphaCoef,texturex,texturey); }
To make the pattern fade after time simply decrease the AlphaCoef to 0 and the BulletHole will not be visible. Then when the bullet pattern has faded - de-activate it so you don't continually update an old pattern.
Sheesh, all of this has got me thinking. I like it.....yes, yes I do. Off to the drawing board.
Last edited by VirtualAce; 10-30-2003 at 03:35 PM.