Aesica
951 posts
|
Topic: Game Programming /
Bullet Hell
Originally posted by benmaster545:
Hey guys. So I am trying to make a bullet hell game in as2, but I have come to a problem where I do not know how other bullet hell games make certain enemies pop up at certain times. I only know how to make it randomly generate enemies. Any ideas? Thanks.
First all, go learn AS3 right now if you plan on making a bullet hell game. All you’ll end up making in AS2 is a lag hell, because it simply can’t handle all of the bullets that will need to be on the screen in order to qualify the game as, well, bullet hell.
Having said that, here’s how I handled spawn waves:
1) Each enemy-to-spawn will need at least this much information: EnemyToSpawn, x, y, delayUntilSpawn
2) Each “wave” will be several of objects containing this data.
3) Each “level” will be several of these waves.
4) How you store this data is up to you—XML, arrays/vectors, etc.
Let’s say you have a wave that looks like this: (GreenSlime, 100, 1, 60), (BlueSlime, 500, 1, 120), (PinkSlime, 300, 100, 60)
The game should interpret this as "after 60 frames, spawn a green slime at coords (100, 1). Then, 120 frames after spawning the green slime, spawn a blue slime at coords (500, 1). Finally, 60 frames after spawning the blue slime, spawn the pink slime at coords (300, 100). Once everything from that wave is killed, skip to the next wave and repeat the process. If that was the last wave, end the level.
|
|
|
Aesica
951 posts
|
Topic: Game Programming /
Show us a screenshot of what you're working on!
Originally posted by GameBuilder15:
Originally posted by VBCPP:
Originally posted by Feffers:
Originally posted by chachon2:
Originally posted by zzulian:
Originally posted by VBCPP:

Looking pretty classy
It is a game?
That’r a game that looking pretty classy
But it a game is?
Yes yes and yes although {SPOILERS} this is just concept art
Maybe you mean placeholders? :/
How do you know he doesn’t mean concept art? Perhaps once the game is live, the boxes will be shinier and more colorful.
|
|
|
Aesica
951 posts
|
Topic: Game Programming /
GiTD [#32] Entries and Discussion
Originally posted by Solsund:
- A game where you play as the Devil and you are trying to get as many people to sign away their souls as you possibly can.
Hmm, part of me really wants to bring that idea to life. Of course, instead of the devil, I’d have the players playing as god and, as his hunger for souls and fresh converts is limitless, your goal would be to convert as many people as possible, then harvest/collect their souls when they die. Om nom nom nom. :D
But alas, my history of completing gitd projects on time is…not encouraging.
|
|
|
Aesica
951 posts
|
Topic: Game Programming /
Type Coercion failure when pulling class from byteArray
I suspect “Point” needs a registerClassAlias as well. It’s probably getting written as an object, but when you try to retrieve it, it can’t figure out what type of object. Since point is a pretty simple object type, why not just save the coordinates as two Numbers instead?
Edit: Posted “a few seconds from now?” I guess I posted this from the future or something. :O
|
|
|
Aesica
951 posts
|
Topic: Game Programming /
Respecting OOP a bit better this time around...
@Ace_Blue: Yeah, I think events will be the way to go for the seldom-called things that I mentioned, as none of them are called multiple times a second. When I think back on it, I even recall having to make certain private variables/functions in the game container class public to allow the boss to change the background image and speed. (Not something I was thrilled about doing, but I felt it necessary at the time)
@Secretmapper: Reflecting a bit, there were common patterns, despite each enemy being unique: Small slimes would descend downward usually while shooting something, big slimes (and several other things) would sit in place and shoot, several different enemies would bounce around the screen, some would spawn and grow continuously until they (or you) died. Is that what you mean by creating just a few behaviors instead of 114? Sure, each boss would need its own special behavior, but the common enemies…hmm. I’ve always liked seeing other people’s approach to doing things. Thanks, I’m going to play around with that I think.
|
|
|
Aesica
951 posts
|
Topic: Game Programming /
About curly braces
Yeah, entirely preference. Personally, I like:
public function CreateCupcake():void
{
trace("Yaay! I now have a cupcake!");
}
My reason being is that it’s faster (for me) to, at a glance, mentally identify and isolate which logic is part of which block, as well as ensure that there aren’t any brace/bracket failures going on.
This for single-liners, because (unless I’m missing something) the braces aren’t necessary:
if (cupcake.flavor == Cupcake.CHOCOLATE) trace("*Squeals in delight*");
|
|
|
Aesica
951 posts
|
Topic: Game Programming /
Clicking an object to execute a function and grab values
try event.currentTarget instead, then cast that as whatever your tile class is.
private function OnTileClick(e:MouseEvent):void
{
var currentTile:Tile = e.currentTarget as Tile;
if (currentTile.propertyYouWantToCheckFor == "Cupcake")
{
trace("yum!");
}
}
|
|
|
Aesica
951 posts
|
Topic: Game Programming /
mouse events actionscript 2
Originally posted by Senekis93:

I guess this image is relevant once more, so I might as well quote it.
|
|
|
Aesica
951 posts
|
Topic: Game Programming /
Respecting OOP a bit better this time around...
Originally posted by Vontremort:
You have 114 separate classes all running the same hard-wired static call? Good lord! Right there, your code is so tightly coupled you can’t even change the method without a huge overhaul. If you really want to improve your architecture that right there should be the first thing you fix. I can’t even fathom how that would work. Having an entirely separate class for each game object sounds nuts.
It’s not as bad as you seem to think, but it absolutely could be better—hence why I want to optimize the engine a bit first. Those 114 classes all extend a basic enemy object class which does most of the work (I’d be insane if I didn’t set it up like that!) But since each enemy behaves in its own, unique way with its own, unique list of stats, I can’t think of a more logical way than to give each one its own class. So when I want to change the way yellow slimes behave, I just open up the yellow slime class and it’s all right in front of me. While sure, I could just make a bunch of preset behavior patterns, but unless I make a lot of them, I introduce “mmo enemy syndrome” or “hp, damage, and appearance aside, these enemies are all the same.”
|
|
|
Aesica
951 posts
|
Topic: Game Programming /
[AS3] OOP Question
Originally posted by Secretmapper:
Well I’m not sure you can do that, mouseEvents by default accept events as parameters.
Let the buttons call functions that generateItems. Like this:
solar.addEventListener(MouseEvent.CLICK , onSolar);
beam.addEventListener(MouseEvent.CLICK , onBeam);
function onSolar(e:Event)
{
generateItem("Solar");
}
function onBeam(e:Event)
{
generateItem("Beam");
}
function generateItem(item:String)
{
var test:Item;
switch(item)
case("Beam"): test = new Beam(); break;
case("Solar"): test = new Solar(); break;
}
IMO this is safer
I’d suggest cutting out the strings and case stuff, and try it like this instead:
solar.addEventListener(MouseEvent.CLICK , onSolar);
beam.addEventListener(MouseEvent.CLICK , onBeam);
function onSolar(e:Event)
{
generateItem(Solar);
}
function onBeam(e:Event)
{
generateItem(Beam);
}
function generateItem(newItem:Class)
{
var newItem:Item = new newItem(); // no case blocks needed for the same result. :D
// ...rest of code here
}
|
|
|
Aesica
951 posts
|
Topic: Game Programming /
Respecting OOP a bit better this time around...
Originally posted by Ace_Blue:
I think the problem is that you have the logic backward. Your enemy object is calling the main game object saying it wants to create a bullet, when it should be the game calling the enemy and asking if he’s ready to spawn bullets now. The game contains the enemies, therefore the game calls the enemies. Soldiers don’t grab stuff on their general’s desk.
Anyway, so the game queries, and the enemy replies with an Array. If the answer is [] it means no bullet to spawn, and otherwise each element has one bullet info (type, bearing, speed, damage, homing, etc… all nicely packed in a bullet object). The game then pushes that array at the bullet array so all bullets will get displayed and get henceforth to live their bullet lives, fully dissociated from the enemy that spawned them.
I thought about doing it that way in the beginning, actually. The problem arises in the occasional special case, where an enemy needs to interact with the game container in ways that involve more than just shooting bullets. For example, the last boss changes and accelerates the background when she spawns, and then reverses its direction on the last phase. When a boss is killed or switches phases, it needs some way to tell the game container to wipe out all of the spawned enemies/bullets. The dialog sequences and tutorial overlay text are also initiated by “enemy” objects with no graphic that immediately terminate themselves afterward. (Weird, I know, but it flows pretty well!) There’s a few others that don’t immediately come to mind, but you get the idea. Because of those odd exceptions, it seemed more logical to let the enemies tell the world how they wanted to interact with it.
Originally posted by Secretmapper:
Optimizing is grand, but often these early architectural foundations of your game is very hard to change once most of the game is built.
I disagree. It is incredibly easy to change.
To be fair, I think “easy” is an ambiguous term in this particular case. Based on my last game, if I were to go in and change the singleton game container reference spawning technique with another, such as callbacks, I’d be requiring myself to (after making sure the initial implementation worked properly, of course) go back into every single enemy. My last game had about 114 enemies, bosses, and special bullets (even the bullets shoot bullets!) that would all need to be checked. Now that might be easy in that it isn’t a coding challenge, but it’s still a fair amount of work, and such a large, sweeping change carries with it the possibility of introducing new bugs. Not something I’d want to mess with once most of the game was built.
|
|
|
Aesica
951 posts
|
Topic: Game Programming /
Respecting OOP a bit better this time around...
I see, so basically, I was pretty much on the right track performancewise, with the exception Secretmapper mentioned—which I plan on including this time around, of course. I’ll save the proper OOP stuff for something less picky about performance, such an RPG. Thanks guys. :D
Edit: Would the same thing apply to classes as objects? Because I abuse the hell out of that. :O
|
|
|
Aesica
951 posts
|
Topic: Game Programming /
Respecting OOP a bit better this time around...
Oh bummer, so it is in fact slower. I had a feeling it was, since in theory, it would be doing several other things in addition to making the game container add a bullet, compared to…well just telling the game container to add a bullet directly. That’s (unfortunately) reason enough to stick with my current method, even if it makes encapsulation cry. Thanks. :)
Edit: Hmm, callbacks might not be a bad idea at all. I’m going to play with that and see what I can do. :)
|
|
|
Aesica
951 posts
|
Topic: Game Programming /
Respecting OOP a bit better this time around...
So I'm (semi) hard at work on my previous game's sequel, but I want to clean up the engine a bit, first. For starters, I'd like to be more OOP-friendly this time around. I've got a few questions though in particular:
1) Previously, enemy AI would do the following when it wanted to shoot:
GameContainer.singletonReferenceToCurrentGameContainer.AddBullet(new [Bullet class here--there are many different types!](...various params here);
(Names changed for clarity's sake) Yeah I know, pretty ugly. I know that another option is to have the game container listen for custom events, and dispatch an event. I'm considering that, but my main question is this: Would it be faster than my current method? Or slower? I suck at setting up speed tests and such, so I figured I'd ask here and see if anyone knows off the top of their head before I try to cobble some sort of (probably fairly inaccurate) speed test together.
2) (Only really relevant if the answer to #1 being "faster or about the same" is "yes") I'm pretty unfamiliar with custom events. With the reach-across-the-classes function, it was easy to initialize everything when instantiating a new bullet: (initialX, initialY, direction, speed, bulletCreator, ...etc), with etc being special parameters that only a few actually needed. How will I get all of that information to a new bullet if I use events?
|
|
|
Aesica
951 posts
|
Topic: Game Programming /
How would you do this
Originally posted by evan999333:
Also I don’t really understand what NineFiveThree is saying with
“if the sum is bigger than the random Number, pick the current element.”
He probably means that you'll want to make a loop that checks for something like this: [0] > randomNumber, [0]+[1] > randomNumber, [0]+[1]+[2] > randomNumber, ...etc. Make a variable that keeps track of the sum of the previous array elements as you iterate through the loop, and check that sum against the random number, thus: if (sum > randomNumber) break out of loop and return the current array index, because it corresponds with the selected color.
|
|
|
Aesica
951 posts
|
Topic: Game Programming /
Show us a screenshot of what you're working on!
Originally posted by feartehstickman:
Originally posted by Aesica:
Originally posted by RTL_Shadow:
Optimizing trig is probably not super effective way to speed up the game, since if you are doing it right, you only need to do 1 trig calculation per bullet (at it’s spawn).
Still, awesome to get that fps with that many objects.
That depends on whether the bullets are just going to fly straight (straight of course being whatever their starting direction set to) or take on more advanced behaviors, such as homing. If homing bullets become a thing in that game, I highly suggest limiting the trig to maybe 5 or so times per second instead of every single frame. Probably pretty obvious, I know, but in case it wasn’t, I wanted to throw it out there. Were you blitting in Eisydian Saga or just using optimised display objects?
They’re just optimized displayobjects.
|
|
|
Aesica
951 posts
|
Topic: Game Programming /
Show us a screenshot of what you're working on!
Originally posted by RTL_Shadow:
Optimizing trig is probably not super effective way to speed up the game, since if you are doing it right, you only need to do 1 trig calculation per bullet (at it’s spawn).
Still, awesome to get that fps with that many objects.
That depends on whether the bullets are just going to fly straight (straight of course being whatever their starting direction set to) or take on more advanced behaviors, such as homing. If homing bullets become a thing in that game, I highly suggest limiting the trig to maybe 5 or so times per second instead of every single frame. Probably pretty obvious, I know, but in case it wasn’t, I wanted to throw it out there.
|
|
|
Aesica
951 posts
|
|
|
|
Aesica
951 posts
|
Topic: Game Programming /
What is wrong with this AS3 code?
Another thing that should be classified as “bad” in that tutorial is putting enterframe events on every single displayobject, such as each and every bullet. It’s okay for the purposes of the tutorial, but don’t latch onto that and use it for serious projects.
The LaserBlue’s removeSelf function is pretty weird, too. if (parent != null) parent.removeChild(this); will also get the job done, and it doesn’t require any sort of silly stage reference. In fact, if that’s the entirety of the LaserBlue class, it shouldn’t need the stageRef variable at all.
|
|
|
Aesica
951 posts
|
Topic: Game Programming /
Pausing a Game with Timers
It might be easier to handle all your timer needs through an enter-frame event. Then, when you kill the framerate to pause your game, everything will properly pick up where it’s supposed to when the game resumes.
|
|
|
Aesica
951 posts
|
Topic: Game Programming /
Questions about classes
Originally posted by austin_farmer90:
My question is why not just make all of the variables public, even if they dont get accessed why not leave the door open just in case?
Why not just start the questionable variables out as private/protected, and then change them to public when the need arises? Making everything public from the start is messy. Let’s say you have a class for an enemy that shoots every 10 frames. One of your variables is going to be the counter used to track this; no outside class is ever going to need access to something like that, so making that public would be stupid.
Besides, I seem to recall that private variables perform a bit faster than public ones.
|
|
|
Aesica
951 posts
|
Topic: Game Programming /
Game not playing properly once published.
When you run it on your computer, are you running it in the browser or via a stand-alone/debug client?
|
|
|
Aesica
951 posts
|
Topic: Game Programming /
How to make a pseudorandom generator?
If I recall, the original Final Fantasy NES game used something tacky like a pre-generated array of numbers. While such an approach is obviously not suitable for most random number needs, it’s very simple to create and, for the purposes of ensuring that a given forest screen has the same grass tile arrangement each time the player enters, it’s good enough.
|
|
|
Aesica
951 posts
|
Topic: Game Programming /
GiTD [#31] Game Reviewing and Critiquing
Well something isn’t getting cleaned up. Do you have an array of sorts that tracks all of those actors, be they water drops or the player’s bullets? Unless expired displayobjects are properly removed from such arrays, things can really slow down as they continue to grow in length.
|
|
|
Aesica
951 posts
|
Topic: Game Programming /
GiTD [#31] Winners Announced!
Originally posted by lavaflame2:
I couldn’t help but notice there were only three entries… was that because of the theme? (I know that is the reason I didnt enter anything)
Not a lot of people seemed to like the theme, but I did. :( The only thing that kept me from entering is my track record of being a very slow and overly thorough developer. 10 days is hard. D:
|