Recent posts by Aesica on Kongregate

Flag Post

Topic: Game Programming / Totally lost with Bitmaps and BitmapData

Those calculations will be made no matter what you use, since they kind of have to. Standard displayobjects don’t get to rotate for free, but it’s easy to forget that since rotating is so easy to do when working with them. If you’ve ever tried load testing, you’d see that nonrotated displayobjects don’t put as much drag on the flash player as rotating ones do. With blitting, even if you force the calculations every frame, what you end up with is still going to be faster than easy-rotating through standard displayobjects.

I’m working on this right now (crappy graphics are subject to change and are only for testing purposes) and it is 100% blit-based. There are 3 things going on in this image that attempt to optimize rotations in 3 different ways. The shuriken-things use animation frames to fake a rotating appearance, meaning the rotated images have already been drawn out and are part of the sprite sheet. The skulls are rotated only once, when initially fired, and the rotated image is then cached into a bitmapdata that is then rendered through copypixels. Finally, the blue beam segments rotate every frame (creating the arching appearance) through draw, which of course puts the heaviest load on the engine.

Once you get the hard part of figuring it all out and make a good library, you never have to think about the bad stuff again—only the good. :)

Edit: I don’t mean to seem like I’m twisting your arm, by the way. Just that, as someone who used to think displayobjects were fine, I’ve since come to realize that blitting is so much better once you take the time to learn it. I won’t even touch displayobjects for game sprites/particles anymore. Use whatever works for your project (of course) but keep an open mind at the same time.

Flag Post

Topic: Game Programming / Totally lost with Bitmaps and BitmapData

Oh, I assumed ship was a bitmapdata object. You could always cache it to a bitmapdata using draw upon initialize or when rotated, then use copypixels for the frame-based movement. Without using copypixels, you really aren’t taking full advantage of blitting’s performance advantage over standard displayobject manipulation.

Flag Post

Topic: Game Programming / Totally lost with Bitmaps and BitmapData

A few things:

1) I could be wrong, but I read somewhere that using this.someVar is actually a tiny bit slower than just someVar so there’s no real reason to use this at all. While it sounds ridiculous, this is actionscript, so who knows, it could be accurate.

2) Why are you using stageDrawingData.draw instead of stageDrawingData.copyPixels? The copyPixels function is a lot faster, so unless you need the rotation/scaling/increased flexibility (and increased headache when using spritesheets with draw) I advise you to use copypixels. I’ll elaborate below.

With copyPixels, one of the params you pass in is a rectangle representing where in the spritesheet your desired sprite is. It’s easy to use and quite clean. On the other hand, draw’s clipRect works differently and imo, is a fucking nightmare. Draw’s clipping rectangle, when provided, represents a rectangle of what to show on the bitmapdata you’re drawing to, not a rectangle of what to copy from the spritesheet itself. Once you throw in scaling and especially rotation, it becomes a massive headache.

Edit: Here’s how a typical enterframe blitting cycle might appear:

private function FrameHandler(e:Event):void
	bmpCanvas.lock(); // objects referencing this bitmapdata won't be visually updated until unlocked
	bmpCanvas.fillRect(bmpCanvas.rect, 0ff000000); // fill entire canvas with black, wiping last frame's contents away
	bmpCanvas.copyPixels(blitObject.spriteSheetBMD, blitObject.spriteRect, blitObject.screenLocation, null, null, true); // copypixels version
	// or for draw:  bmpCanvas.draw(blitObject.spriteSheetBMD, blitObject.matrix, null, null, blitObject.clippingRect);
	bmpCanvas.unlock(); // objects referencing this bitmapdata will now show the newly updated version
Flag Post

Topic: Game Programming / Is this using too much memory?

@player_03: Damn, I had a feeling compressed png being stored in memory as uncompressed bitmaps was part of the problem. I could change my spritesheet class to disable alpha for sheets that don't need it, such as background tile layouts, but other than that, I make pretty solid use of alpha. The good news though is that many of my spritesheet pngs are quite large (in dimensions) but relatively blank since I left room to add things to them later. Thus, the memory size may not grow as much as I thought it would as I continue to add things.

@EndlessSporadic: I don't have any audio assets implemented yet. That's usually the last thing I add since it slows down compile times by a lot.

@archipel1: Is it? Part of why I posted this is because I'm curious about that. Is ~130mb or so too much for a flash game to be using?
Flag Post

Topic: Game Programming / Is this using too much memory?

First I tried running a copy of the same level with the background graphics omitted and only saw a ~5mb decrease. When I commented out the background spritesheets entirely, it dropped another ~12mb. In light of this, I suspect that a lot of my “memory bloat” is coming from how my assets are being managed.

When the game first loads, basically takes this:

[Embed(source = "../lib/images/ss-background-layouts.png")]
private static const BackgroundLayouts:Class;

And turns it into this:

public static var ssBackgroundLayouts:SpriteSheet;
// ...several other spritesheet vars are initialized in the same manner

public static function Init():void
	ssBackgroundLayouts = new SpriteSheet(new BackgroundLayouts());
	// ...same treatment for the rest of the spritesheet vars

Since each spritesheet instance contains the bitmapdata relevant to it, I can see how that might get pretty big pretty quickly. I’m just unsure how I could make it any smaller since, no matter what I do, an instance of the sprite sheets in question is going to need to exist in some form or another. Even more frustrating is that the entire contents of my lib/images folder is only about 2.7mb.

Flag Post

Topic: Game Programming / Is this using too much memory?

So yeah, as the subject implies, I’m wondering if this is using too much memory. I’ve seen it peak as high as 130mb, but there isn’t any kind of leak going on because eventually (presumably when garbage collection happens) it drops back down to about 80mb.

There’s no lag issues or anything like that, I’m just concerned about the memory usage because, as I add more things (like proper graphics, and later, sound effects and music) I can only see that number growing even larger. What do you guys use to keep a leash on that sort of thing?

Flag Post

Topic: Game Design / [Feedback] Tile Shmup

Since nobody else has responded in this thread, I will.

First of all, the controls are kind of yucky on several levels.

a) I should be able to choose between mouse and keyboard, and for keyboard, should have the choice for custom keybinds. Not every keyboard out there is set up in a way that has the wasd keys in the same place (azerty keyboards, for example) while some prefer arrow keys and others prefer mouse controls.

b) The slippery controls add a sort of heavy-handed difficulty increase. The biggest threat isn’t the level layout itself, but the sloppy nature by which the ship moves through everything.

c) The firing direction changing as the ship moves right or left might make sense from a physics standpoint, but it only further adds to the frustration created by problem B.

Now I realize that, by correcting all of those “issues” the game becomes too easy. This is where you, as the developer, introduce new and interesting tiles/blocks for the player to tackle that will slide the difficulty back up a bit. Blocks that explode when shot at, blocks that split into smaller, faster-falling blocks, etc.

I guess my point is that you want to ramp up the difficulty through creative encounters in each level rather than by making the player controls feel clumsy.

Flag Post

Topic: Game Design / My First Game, Feedback please.

For a first game, this is pretty good, however as others have said, there’s a lot of room for improvement.

1) Foreground/background. These need to be more distinguishable, as I tried to jump on what I thought was a platform but was part of the background instead. Look at how other games makes the two easier to distinguish—typically they employ things such as lower color saturation, lower contrast, darker, a bit of blur, etc. Try them out and see what works.

2) Touching the water kills the player. Sure, that’s fine if a) they fall into a bottomless pit or b) the water is actually flesh-destroying acid or lava. However no, it’s just plain water, but the mere act of touching it makes the player fade and the level restart—even if you manage to wall-jump your way out of it.

3) The graphics aren’t “bad” per say, but they seem unfinished and inconsistent. (This was a mistake I made in my first game, too)

4) Nothing is overly hard except for what feels like game mechanics failures. For example, I keep dying on the second level when I’m supposed to hop from one vine to the next not because I keep missing the second vine, but because I must not be hitting it at just the right angle or…something. Players hate this kind of stuff, so address it.

5) The game needs some kind of backstory, or at least a basic reason we’re here. Who are we controlling and what his/her/its goal?

6) What is the point of collecting the coins and totems? Is there going to be an upgrade shop I can spend them in? Does collecting some arbitrary amount give me an extra life, level me up, or unlock a new area/ability/etc?

7) What about interesting power-ups? Things that changes the gameplay slightly, such as the ability to shoot or fly or explore underwater rather than die instantly can really add to a game like this.

8) Enemies. The one you have so far is good—simple, easy to defeat, yet still has just enough unpredictability to catch you off guard if you’re too lazy. Needs more enemies with varying behavior patterns.

Flag Post

Topic: Game Programming / Adobe's latest IDE questions

If your primary concern is a better coding environment, then you’re going to get more out of FlashDevelop than Flash Pro. I don’t use it much, so someone else feel free to correct me, but it’s my understanding that Adobe’s IDE is only worth using if you need access to the vector graphic tools and timelines, the ability to work with .fla files, or prefer to manage library assets the Adobe way.

Flag Post

Topic: Game Programming / Can you make flash games with gamemaker to put onto kongregate?

This topic is almost 5 years old. Oh well, better late than never!

Flag Post

Topic: Game Programming / What do you use to make a particle engine in openfl

@Shalmezad: 12,000 bullets with no lag, not bad. In your first example, you’re copying them onto the bitmapdata, then the bullet object itself ceases to be relevant, right? (I assume that’s what you mean by “shifting”)

Flag Post

Topic: Game Programming / What do you use to make a particle engine in openfl

Originally posted by player_03:

The draw() function is pretty slow, specifically because of the matrix transformations and blending. I’m not sure how it compares to Flash’s normal sprites, but I imagine it’s about the same or slightly slower.

Have you considered switching over to Starling entirely? As long as all your sprites are Starling sprites, you’ll have full control over which ones are in front.

Back when I first decided to give blitting a try, I made this thing. When I turn on rotations, draw outperforms traditional sprites. Assuming the scale/rotation doesn’t need to change on every single frame, you could use draw only when needed, caching the modification for use with copyPixels

Flag Post

Topic: Game Programming / Best way to store ingame level?

For tile-based games, I like storing the tile placement in bitmaps. For example, this:

and this:

Contain the level data for this and this respectively. (For the latter, that is the level data for the 2nd level, not the first)

Of course, in the end, the bitmaps are converted into 2d arrays, but in terms of storing the data, it works nicely. Just make sure you’re not using lossy image formats to do this.

Flag Post

Topic: Game Programming / How do I change the size of my game?

For AS3, if all you want to do is make everything twice as large, make a central container that will hold all other display objects, then apply the following to it:

myImage.scaleX = myImage.scaleY = 2;

Flag Post

Topic: Game Programming / AS3: Severe FPS drop when mouse hovering over game

Blitting may not be "necessary," however it's something that's worth getting comfortable with. The animation is always going to be smoother and faster compared to the same thing accomplished through DisplayObjects. It's kind of intimidating at first--I know I was rather resistant to trying blitting for the longest time. Now, the thought of using DisplayObjects for anything besides containers or buttons makes me cringe.

The draw function lets you utilize blendmodes, if that's something you need for the method you're using.
Flag Post

Topic: Game Programming / AS3: Severe FPS drop when mouse hovering over game

The objects move even slower when you move the mouse around vs when it's standing still. This leads me to believe that you have a lot of displayobjects that are all firing off (likely unnecessary) mouse events while the mouse is active on the stage. Any DisplayObject (sprites in a game, specifically) that doesn't actually need to receive mouse input should have mouseEnabled = false and any DisplayObjectContainer that won't ever contain things like mouse-interacting objects should have mouseChildren = false.
Flag Post

Topic: Game Programming / {AS3} Game Help ?

The justin bieber track is definitely the most important part. Do not leave it out.

Flag Post

Topic: Game Programming / AS2 Shared Object help

What did the trace statements output?

Flag Post

Topic: Game Programming / Help Out !

Maybe each word is supposed to represent a class.

Flag Post

Topic: Game Programming / AS3: Syntax error

This is why opening curly braces are best used on the line directly below rather than the end of the same line. (In my opinion, anyway)

Flag Post

Topic: Game Programming / Getting exposure on Kongregate guide

I can’t believe you didn’t mention anything about the icon specifically, as icons are pretty important. Also, you’d be surprised, but including a “start muted” option is pleasing to a lot of people and thus, will boost your ratings slightly.

Flag Post

Topic: Game Programming / Separating game logic from drawing logic in canvas

Is it really necessary to subject a player suffering from some kind of lag to 5fps for several seconds when the game logic is still running at full speed? In an mmo perhaps, because the game logic needs to happen at the same rate for everyone playing. In a single player game though, players are (at least I am) more forgiving of games that slow down with lag than games that kill them because their framerate drops so low they can't really tell what's going on--until it's too late.

The comment you're likely referring to raises a good point about the framerate dropping to minimal amounts when tabbed out, etc. Does it really matter if your game's framerate slows to a crawl when not active and thus, the person isn't even playing it? If that's really the case, forcing it to pause is an option--a commonly-used option, at that.

So yeah, I guess you could say I'm in the enter frame camp. And the fewer loops your (possibly quite large) collection of game objects has to constantly cycle through, the better.

Edit for another thought: Hard stop "game overs" are fairly antiquated, as the common practice seems to make them more of a "try again" than a "restart from square 1." Thus, game overs aren't really a big deal, meaning players are less likely to try to abuse framerates to boost their survivability. As for those who are prone to cheating, unless it's a multi-player game, I don't really see the big deal. I used to use game genie/game shark all the time to experience games I loved in new and interesting ways. Now that I attempt to make games, I don't really want to stand in the way of people who might want to do the same thing I did back in the nes/snes days.
Flag Post

Topic: Game Programming / Question about arrays

Yeah oops, forgot a period. I’ll edit my post. Anyway vectors are basically arrays, except they’re faster and can only be made up of the specified data type (Number in this case) rather than anything. If you’re more comfortable with arrays, you could certainly use one instead to get the same result, although I find the extra strictness nice because it makes things easier to debug.

Flag Post

Topic: Game Programming / Question about arrays

Simple data types (which includes numbers, ints, uints, etc) are always by value rather than by reference. Consider changing your approach to do away with individual powerFire, PowerIce, and powerElect variables entirely, because with an array (or vector) they’re really not needed at all. I usually approach such things like this:

// this is the closest you can get in AS3 to enumeration
private static const TYPE_FIRE:int = 0;
private static const TYPE_ICE:int = 1;
private static const TYPE_ELEC:int = 2;

private var power:Vector.<Number> = new <Number>[0, 0, 0];

// ...then, to access/change/etc:

power[TYPE_ICE] = 3; // setting ice's power to 3
Flag Post

Topic: Game Programming / [Solved] Rotation with bitmapData.draw blows

Thank you so much. All I've ever been able to do with matrices is get them to rotate based on upper-left registration, which is useless (but not as useless as clipRect!). I had no idea you could do what is basically moving them to the center, rotating, and then moving them back like that.

With the following changes, it works perfectly. :D

				iTempWidth = ssSpriteSheet.aSpriteRect[iAppearanceID].width;
				iTempHeight = ssSpriteSheet.aSpriteRect[iAppearanceID].height;
				bmpNew = new BitmapData(iTempWidth, iTempHeight, true, 0);
				bmpNew.copyPixels(ssSpriteSheet.bmpSpriteSheet, ssSpriteSheet.aSpriteRect[iAppearanceID], ZERO_POINT, null, null, true);
				oMatrix = new Matrix();
				oMatrix.translate(iTempWidth * -0.5, iTempHeight * -0.5);
				oMatrix.rotate((iNewDirection + 90) * PIForRadians);
				oMatrix.translate(iTempWidth * 0.5, iTempHeight * 0.5);
				bmpRotationCache = new BitmapData(iTempWidth, iTempHeight, true, 0);
				bmpRotationCache.draw(bmpNew, oMatrix);