# Vertical Scrolling Shooter in Theory

11 posts

 Hi everyone, n00b flash programmer here. :( I’m trying to develop a “bullet hell” vertical scrolling shooter on Flash ( Example of “bullet hell”: [http://www.youtube.com/watch?v=nscP9QpXoFM](http://www.youtube.com/watch?v=nscP9QpXoFM) ). The entire thing will be coded with AS3.0. I’ve consulted various tutorials and purchased a couple of books to get some ideas. I understand that the basics can be expanded to fit what I’m working on, but I’m sometimes confused by conflicting messages about the “optimal” way of doing things. Thus I wish to toss some thoughts out here to get some opinions. Some of the things that I’m asking about are somewhat related. 1. Although some of the enemy attacks will be random, a significant number of attacks (especially from bosses) will have distinct patterns to them. I understand that most of these patterns can be achieved with bullets that move in linear motions, but I would really like to incorporate non-linear movements as well. Yes, there are sine or cosine functions or parametric equations that I could experiment with, but there are some attack patterns that I have a hard time modeling, such as a whirlpool or vortex effect. Would it be more efficient for me to manually place MC instances of bullets on the frames and motion tween all of the bullets for this attack? Or am I stuck writing equations to tween every single bullet? 2. The game is set to run at 12 FPS. However those with slower computers will experience a lower FPS, giving them an unfair advantage over those with fast computers. One recommendation was to use time-based animation rather than frame-based animation. If I use time-based animation, would there be any use for multiple frames in my scenes (bearing in mind that ingame story events need to happen during or after specific enemy attacks)? 3. Each enemy bullet deals a certain amount of raw damage to the player. Damage modifiers are then applied to find the final damage that is applied on the player. Different shapes of bullets are represented by different MovieClips, however each bullet MovieClip will be used in multiple scenes with different amounts of raw damage for each scene. A similar idea can be applied to enemies (with varying amounts of health, who will be taking damage from the player’s weapon, which also varies). I heard about using Arrays to organize all of this, but I’m unsure as to how to actually organize this information for HitTest purposes. Also, should I organize all of the information into one array (eg: all of the enemy bullet damage rates), or should I use different arrays for each Scene (eg: All of the damage rates of enemy bullets that are actually used in a certain scene)? That’s all for now. Thanks for your opinions. It’s fairly easy to model a radial pattern like a “whirlpool” effect. Start with a circle, and multiply it by some function of time. If you decide to go for time-based animation, I’d keep one frame for each “level”, then one for a story sequence, then another frame for the next “level”, and so on. As for #3: You’re thinking in a linear programming style. OOP makes things much easier. You’ll do much better to write a seperate Bullet class and have it keep track of how much damage it deals, its current location, its motion path, what image it will use to draw itself, and basically everything else associated with one particular bullet. Then you use a single array in your program to keep track of all the Bullets currently in play. 1. It’ll be _far_ more efficient to figure out the math you need than to try to do anything remotely complex with Flash’s animation tweening. (If you want some examples, you could try looking up BulletML…) 2. I’d suggest using frame-based animation, while keeping track of how fast the game is running compared to how fast it should be running, and disallow high scores if the game is running much more slowly than it should be. Using frames or not is purely dependant on how you want to structure your game. Personally, I ignore the timeline. Frames are for movies, not games! ;) 3. Listen to Jabor. You may want to take some time to learn better programming, if this kind of stuff is new to you. For whirl pool or vortex attacks, you should use polar corrdinate style of positioning them. Simple have it move along a center that is linear, which would follow a normal straight line, or you could even curve and whirl this one really. Then, using the current position of that as the origin, specify how far you want it to be and at what direction (which is what polar coordinates are). This would be rsin(theta), rcos(theta) parametrically(I THINK, been a while, might have to flip sin and cos). Or it would be r(distnace from origin), theta, which is an angle. You could create a function that automatically does the \ and just pass to it what you want r and theta to be. The end function(mathmatical note code) would be something like **x(final position)= x(of dynamic origin)+rSin(theta)** with y being **y=y+rCos(theta)**. the y and x f the dynamic origin would be figured with a regular linear function(math) like, x=-y, which would have x be incremented each call to this function by one. Then using a bunch of algebra you could actually compress this all into one giant single line of code that just has the engine doing one thing each time. A vortex(well spiral really) is simply f®=theta (much like f(x)=y, whatever value x is y, whatever value r is theta is) This says as r gets bigger, so does theta. So at 0, it is zero, then at 180, r is 180 units away and at 180 degrees and then at 360. All you would have to do is modify where it starts from and it would spiral out in bigger and bigger circles till you tell it to go away from that point. As for frames, you could have it check each frame how much time has passed since the last frame. You want 12fps, this is .0833333333 seconds per frame. So on the first frame of play, get the last frame, save it, then on the next frame, get the time again and compare it to the previous saved time. If it is greater than .0833333(or however many 3’s you want, it goes forever), then their fps is lower than 12. Now if it is greated, divide it by .0833333, which will give you the percentage that this players time per frame is over what you want it to be. Save this value and multiply it into every position of every bullet, which will move it to where it should be as though the game were at 12fps. Anyhow, hope that makes any sense, I tend to not structure posts like this very well because I type them like I think them. 12FPS is not run. it’s choke. you need 30FPS for smooth movement. 30 is good. Some people might tell you 60 though. That’s a little overkill, imho. Stay away from Tweening. You’re working in AS3.0, so you’re a big boy now. Having the exact location of every bullet will make your life easier without using hitTest() every frame on every bullet. 1. Don’t use tweens, that’s going to make it so much more complicated than using a formula. 2. I believe that Flash Player 10 will skip frames instead of running at a lower FPS. (I’m not sure). Phantasmagoria: Disallowing high scores for slower computers would ruin the game and make everyone mad, since if he is attempting to have that many bullets on screen, nearly everyone’s computer will be slow. 3. Yeah. Go with Object Oriented. Also, don’t use hitTest. It’s much faster just to test the distance between the bullet and player ship. It won’t be as exact, but it will be much faster. It is going to be extremely hard to get that many bullets onscreen, and run at an acceptable FPS. Especially with Flash. That game was probably written in C++ or something akin to that language. Flash is about 10 times slower than that. I like tweens for specific animations, but to move something, i find it easier to use formulas to move things. And OOP is the way to go for anything as big as a shooting game. Makes it nice and modular. do NOT user 12 fps! At least 30 fps or the game will be unplayable. > *Originally posted by **[spaceplant](/forums/4/topics/11399?page=1#posts-191204):*** > > do NOT user 12 fps! > > At least 30 fps or the game will be unplayable. no i actually recommend around 24-25FPS @Heylon: You might want to look at the post dates before replying. This thread was over a year old.