Recent posts by Aesica on Kongregate

Flag Post

Topic: Game Programming / GiTD #43 *Theme Selection*

Noun: Dragon
Verb: Replicate
Adjective: Procedural
Game Mechanic: Collection (I was going to say turn-based too, but it’s already covered!)

 
Flag Post

Topic: Game Programming / As3, how do i write this?

@darkjonas8: You forgot to specify the type, both in the declaration and the instantiation.

var aBunchOfGrassBlocks:Vector = new [SFoliage1, SFoliage2, SFoliage3];

Should be…

var aBunchOfGrassBlocks:Vector<Class> = new <Class>[SFoliage1, SFoliage2, SFoliage3];

Originally posted by Shake_N_Baker:

The extra pair of brackets made it an array of arrays while it was expecting an array of classes.


“Yo dawg, I heard you like arrays so I put an array of classes into an array so you passed in an array of arrays of classes when it expected an array of classes.”

Sorry, I couldn’t help myself. :D

 
Flag Post

Topic: Game Programming / As3, how do i write this?

Oh neat, I wasn’t aware of the global function. Plus, my mind (for whatever reason) automatically inserted a “new” as I read over that part, so I was like “why are you passing in an array where the constructor expects a uint?”

 
Flag Post

Topic: Game Programming / As3, how do i write this?

Is this what you’re trying to do?

var aBunchOfGrassBlocks:Vector<Class> = new <Class>[GrassBlockA, GrassBlockB, GrassBlockC];
var i:int = Math.floor(Math.random() * aBunchOfGrassBlocks.length);
var myGrassBlock = new aBunchOfGrassBlocks[i]();
addchild(myGrassBlock);

Edit: player_03 beat me to it, but yeah. Roughly that, although I’m not sure that version of filling the class vector will work.

 
Flag Post

Topic: Game Programming / Squeezing as much audio into a game

Originally posted by truefire:

Nope. Just nope. Java has a lot of problems and they’re not going anywhere. Ever loaded a Java app and had your browser crash with no explanation? Yeah, I thought so.

Not to mention the updates never seem to install properly.

 
Flag Post

Topic: Game Programming / Squeezing as much audio into a game

Originally posted by EndlessSporadic:

Dont use MP3. You need to license those. If possible, switch to ogg format.

What? You really can’t use MP3 files in flash games? Or am I just misinterpreting something?

 
Flag Post

Topic: Game Programming / Squeezing as much audio into a game

Change the bitrate, which is usually listed as something like “128 kbps.” The lower you take it, the smaller the file but also, the worse the sound quality. Also, try to use “mono” or “joint stereo” (if you need stereo) instead of “stereo.” You’ll have to play around to find which bitrate you feel is a good compression-vs-quality tradeoff.

 
Flag Post

Topic: Game Programming / My passion for game development is wearing out

Electricity creates heat and internet. I consider those two things pretty much on par with food, water, and shelter.

 
Flag Post

Topic: Game Programming / My passion for game development is wearing out

Originally posted by truefire:

Ever since I started working…

Stop working, obvious solution.

Unfortunately, doing so often causes the food, water, electricity, and shelter to start going away. Those are kind of important.

 
Flag Post

Topic: Game Programming / My passion for game development is wearing out

Ugh, yeah totally. I get like that when working on the really boring parts of game projects, too. I have no worthwhile advice to offer though because I haven’t found an answer myself. :(

 
Flag Post

Topic: Game Programming / GiTD #42 - *Pirates*

I thought the “lengthy feedback” aspect was entirely optional.

Edit: Also, the population/activity level of this forum has declined over the last year or so anyway. I think low gitd turnouts are merely a symptom of that rather than the result of flaws in the contest itself.

 
Flag Post

Topic: Game Programming / In-game banner ads?

Yeah don’t put ads in the game during the actual levels/gameplay. Not only are they distracting, but also, players will generally ignore them because the level demands their attention. Ads between levels, on pause or summary windows, on menus, etc, and of course the preloader are just fine though as long as you don’t overdo it. It’s the kind of question that can really only be answered by approaching the question from a player’s perspective rather than a developer’s. Ask yourself “would this annoy the crap out of me, or otherwise distract me from the actual game?” If the answer is yes, then don’t do it.

 
Flag Post

Topic: Game Programming / GiTD #42 - *Pirates*

Everything I come up with is too complex for a 10-day contest. Also, the warlords of draenor beta is taking up my free time.

 
Flag Post

Topic: Game Programming / Using format for Textfield jumbles characters, no clue why

Yeah you only ever set embedfonts to true if you’re using an embedded font. If you have to ask what that is, you’re probably not using one. (But you should learn about them and eventually start using them, because they look a lot better)

 
Flag Post

Topic: Game Programming / Using format for Textfield jumbles characters, no clue why

1) autosize is applied to a textfield, not a textformat.

2) Have you set a particular font for this textformat anywhere? I see the embedfonts property set to true, but no specific font being specified.

3) If you can’t find the problem, try commenting out each line until you find what’s causing it. Personally, I’ve never played with letterspacing either, so make sure that’s not causing any problems.

 
Flag Post

Topic: Game Programming / as3 tutorial

^ I second this. Seriously, AS2 is a complete waste of time.

 
Flag Post

Topic: Game Programming / GTArcade’s star cosplayer Liz Katz!

Is this a game, or softcore porn?

 
Flag Post

Topic: Game Programming / GiTD #42 - *Pirates*

I see no reason not to allow the use of assets that aren’t code-related for future contests as well. After all, there’s little difference between “reusing your own assets” and “using premade assets from the internet.” Plus, it helps put everyone on more equal footing in terms of higher quality entries, since not everyone is an artist or musician capable of quickly cranking out assets.

 
Flag Post

Topic: Game Programming / [Solved I think] How to _copy_ semi-transparent pixels?

@player_03: I mainly need draw for things like colortransforms (enemy flashing on-damage), rotation (use once, cache, then copyPixels), and the occasional, sparingly-used blendmode. As someone who’s become something of a performance nut, I’d never use it to replace copyPixels.

Anyway, I think I solved my issue, too (Sorry ErlendHL for accidentally hijacking your thread!) so I’ll post my solution:

SWF

The important stuff is in the FrameHandler function.

package
{
	import aesica.display.SpriteSheet;
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.BlendMode;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.filters.GlowFilter;
	import flash.geom.Matrix;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	import flash.text.TextField;
	import flash.text.TextFormat;
	
	/**
	 * ...
	 * @author
	 */
	public class BlitBlendTest extends Sprite
	{
		[Embed(source="../lib/gradient-orbs.png")]
		private static const ColorOrbs:Class;
		
		private static const ORB_COUNT:int = 200;
		private static const ORB_TOP_SPEED:Number = 1;
		
		private static const MODE_COPYPIXELS:int = 0;
		private static const MODE_DRAW_NORMAL:int = 1;
		private static const MODE_DRAW_BLEND_MULTIPLY:int = 2;
		private static const MODE_DRAW_BLEND_DARKEN:int = 3;
		private static const MODE_DRAW_BLEND_LIGHTEN:int = 4;
		private static const MODE_DRAW_BLEND_OVERLAY:int = 5;
		private static const MODE_DRAW_BLEND_SCREEN:int = 6;
		private static const MODE_DRAW_BLEND_DIFFERENCE:int = 7;
		private static const MODES:Vector.<String> = new <String>["CopyPixels/Control Group", "Draw:Normal", "Draw:BlendModeMultiply", "Draw:BlendModeDarken", "Draw:BlendModeLighten", "Draw:BlendModeOverlay", "Draw:BlendModeScreen", "Draw:BlendModeDifference"];
		
		private var ssOrbs:SpriteSheet;
		private var bmpCanvas:BitmapData;
		private var aOrbBitmapDataIDs:Vector.<int>;
		private var aOrbPoints:Vector.<Point>;
		private var aOrbVelocities:Vector.<Point>;
		private var aDrawRects:Vector.<Rectangle>;
		private var bmpBackground:BitmapData;
		private var lZeroPoint:Point;
		private var iMode:int = 1;
		private var lblMode:TextField;
		private var mModeSwitch:Sprite;
		private var mBackgroundSwitch:Sprite;
		
		public function BlitBlendTest()
		{
			ssOrbs = new SpriteSheet(new ColorOrbs() as Bitmap);
			bmpCanvas = new BitmapData(800, 600, true, 0xffffffff);
			bmpBackground = new BitmapData(800, 600, true, 0xffffffff);
			RandomizeBackground();
			lZeroPoint = new Point();
			
			var i:int;
			var iSpriteSheetSize:int = ssOrbs.aSpriteRect.length;
			aOrbBitmapDataIDs = new Vector.<int>(ORB_COUNT);
			aOrbPoints = new Vector.<Point>(ORB_COUNT);
			aOrbVelocities = new Vector.<Point>(ORB_COUNT);
			aDrawRects = new Vector.<Rectangle>(ORB_COUNT);
			for (i = 0; i < ORB_COUNT; i++)
			{
				aOrbBitmapDataIDs[i] = Math.floor(Math.random() * iSpriteSheetSize);
				aOrbPoints[i] = new Point();
				aOrbVelocities[i] = new Point(Math.random() * ORB_TOP_SPEED, Math.random() * ORB_TOP_SPEED);
				aDrawRects[i] = new Rectangle(0, 0, ssOrbs.aSpriteRect[aOrbBitmapDataIDs[i]].width, ssOrbs.aSpriteRect[aOrbBitmapDataIDs[i]].height);
			}
			
			var mCanvas:Bitmap = new Bitmap(bmpCanvas);
			addChild(mCanvas);
			
			mModeSwitch = new Sprite();
			lblMode = QuickTextField("[Change Mode (Currently " + MODES[iMode] + ")]");
			mModeSwitch.addChild(lblMode);
			
			mBackgroundSwitch = new Sprite();
			mBackgroundSwitch.addChild(QuickTextField("[Randomize Background]"));
			
			mBackgroundSwitch.buttonMode = mBackgroundSwitch.useHandCursor = mModeSwitch.buttonMode = mModeSwitch.useHandCursor = true;
			mBackgroundSwitch.x = 800 - mBackgroundSwitch.width;
			
			addChild(mModeSwitch);
			addChild(mBackgroundSwitch);
			
			addEventListener(Event.ADDED_TO_STAGE, Init, false, 0, true);
		}
		
		private function QuickTextField(sMessage:String):TextField
		{
			var lblReturn:TextField = new TextField();
			lblReturn.selectable = lblReturn.mouseEnabled = false;
			lblReturn.autoSize = "left";
			lblReturn.defaultTextFormat = new TextFormat("Arial", 16, 0xffffff);
			lblReturn.filters = [new GlowFilter(0, 1, 2, 2, 10)];
			lblReturn.text = sMessage;
			
			return lblReturn;
		}
		
		private function RandomizeBackground(e:MouseEvent = null):void
		{
			bmpBackground.perlinNoise(Math.random() * 250 + 1, Math.random() * 250 + 1, Math.floor(Math.random() * 10) + 1, Math.floor(Math.random() * 9000), ((Math.floor(Math.random()) < 0.5) ? true : false), ((Math.floor(Math.random()) < 0.5) ? true : false), Math.floor(Math.random() * 15));
		}
		
		private function Init(e:Event):void
		{
			removeEventListener(Event.ADDED_TO_STAGE, Init);
			addEventListener(Event.REMOVED_FROM_STAGE, Dispose, false, 0, true);
			addEventListener(Event.ENTER_FRAME, FrameHandler, false, 0, true);
			mModeSwitch.addEventListener(MouseEvent.CLICK, Clicked, false, 0, true);
			mBackgroundSwitch.addEventListener(MouseEvent.CLICK, RandomizeBackground, false, 0, true);
		}
		
		private function Dispose(e:Event):void
		{
			removeEventListener(Event.ADDED_TO_STAGE, Init);
			removeEventListener(Event.REMOVED_FROM_STAGE, Dispose);
			removeEventListener(Event.ENTER_FRAME, FrameHandler);
			mModeSwitch.removeEventListener(MouseEvent.CLICK, Clicked);
			mBackgroundSwitch.removeEventListener(MouseEvent.CLICK, RandomizeBackground);
		}
		
		private function FrameHandler(e:Event):void
		{
			bmpCanvas.lock();
			var i:int;
			var oMatrix:Matrix;
			bmpCanvas.fillRect(bmpCanvas.rect, 0xff000000);
			bmpCanvas.copyPixels(bmpBackground, bmpBackground.rect, lZeroPoint, null, null, true);
			for (i = 0; i < ORB_COUNT; i++)
			{
				if (aOrbPoints[i].x < 0 || aOrbPoints[i].x > bmpCanvas.width - ssOrbs.aSpriteRect[aOrbBitmapDataIDs[i]].width)
				{
					aOrbVelocities[i].x *= -1;
				}
				if (aOrbPoints[i].y < 0 || aOrbPoints[i].y > bmpCanvas.height - ssOrbs.aSpriteRect[aOrbBitmapDataIDs[i]].height)
				{
					aOrbVelocities[i].y *= -1;
				}
				
				aOrbPoints[i].x += aOrbVelocities[i].x;
				aOrbPoints[i].y += aOrbVelocities[i].y;
				
				if (iMode == MODE_COPYPIXELS)
				{
					bmpCanvas.copyPixels(ssOrbs.bmpSpriteSheet, ssOrbs.aSpriteRect[aOrbBitmapDataIDs[i]], aOrbPoints[i], null, null, true);
				}
				else
				{
					oMatrix = new Matrix();
					oMatrix.translate(aOrbPoints[i].x - ssOrbs.aSpriteRect[aOrbBitmapDataIDs[i]].x, aOrbPoints[i].y - ssOrbs.aSpriteRect[aOrbBitmapDataIDs[i]].y);
					aDrawRects[i].x = aOrbPoints[i].x;
					aDrawRects[i].y = aOrbPoints[i].y;
					
					if (iMode == MODE_DRAW_NORMAL)
					{
						bmpCanvas.draw(ssOrbs.bmpSpriteSheet, oMatrix, null, null, aDrawRects[i]);
					}
					else if (iMode == MODE_DRAW_BLEND_MULTIPLY)
					{
						bmpCanvas.draw(ssOrbs.bmpSpriteSheet, oMatrix, null, BlendMode.MULTIPLY, aDrawRects[i]);
					}
					else if (iMode == MODE_DRAW_BLEND_DARKEN)
					{
						bmpCanvas.draw(ssOrbs.bmpSpriteSheet, oMatrix, null, BlendMode.DARKEN, aDrawRects[i]);
					}
					else if (iMode == MODE_DRAW_BLEND_LIGHTEN)
					{
						bmpCanvas.draw(ssOrbs.bmpSpriteSheet, oMatrix, null, BlendMode.LIGHTEN , aDrawRects[i]);
					}
					else if (iMode == MODE_DRAW_BLEND_SCREEN)
					{
						bmpCanvas.draw(ssOrbs.bmpSpriteSheet, oMatrix, null, BlendMode.SCREEN, aDrawRects[i]);
					}
					else if (iMode == MODE_DRAW_BLEND_OVERLAY)
					{
						bmpCanvas.draw(ssOrbs.bmpSpriteSheet, oMatrix, null, BlendMode.OVERLAY, aDrawRects[i]);
					}
					else if (iMode == MODE_DRAW_BLEND_DIFFERENCE)
					{
						bmpCanvas.draw(ssOrbs.bmpSpriteSheet, oMatrix, null, BlendMode.DIFFERENCE, aDrawRects[i]);
					}
				}
				
			}
			bmpCanvas.unlock();
		}
		
		private function Clicked(e:MouseEvent):void
		{
			iMode++;
			if (iMode >= MODES.length)
			{
				iMode = 0;
			}
			
			lblMode.text = "[Change Mode (Currently " + MODES[iMode] + ")]";
		}
	
	}

}

PS: Sorry for the ridiculous lack of comments, and hopefully my variable prefixes aren’t too annoying to look at.

 
Flag Post

Topic: Game Programming / [Solved I think] How to _copy_ semi-transparent pixels?

There is no sourceRect for draw — the closest thing is clipRect but that does something entirely different. I’m starting to think that the only way to draw a single sprite from a sprite sheet via draw involves making a temporary bitmapdata, copypixeling the sprite in question to it, and then in turn using draw to place that temporary bitmapdata onto the canvas. Eww.

 
Flag Post

Topic: Game Programming / [Solved I think] How to _copy_ semi-transparent pixels?

The main limitations (which I really need to find a way around) are no rotation, scaling, blendmodes, color transforms, etc. And in my case, I can’t figure out how to use draw to place a single sprite instead of the entire sheet. Probably involves something with matrices which hurt my head enough as it is. :)

 
Flag Post

Topic: Game Programming / [Solved I think] How to _copy_ semi-transparent pixels?

Originally posted by Draco18s:

It will copy, but it won’t blend. It’ll overwrite the destination color value rather than multiplying.

They don’t entirely overwrite, unless you’re specifically referring to the multiple blendmode or something else entirely.

Click the stage to cycle render modes, and excuse the weirdness that happens with draw because I have no idea how to select a single sprite from a spritesheet with draw because I never really use it. (It’s drawing the whole sprite sheet instead of just one of the colored bubbles) Oh, and excuse the loading time. Because of laziness, I made this on top of an existing project instead of just making a new one. Trying out things like this in such a way is one of my shamefully bad habits. :(

 
Flag Post

Topic: Game Programming / GiTD #42 - *Pirates*

Originally posted by Draco18s:

God, you have no idea how much I want someone to remix those lyrics with the theme from Pirates of the Caribbean.

The best part is that it’s a cover of this song.

Originally posted by Shalmezad:

If I get a song stuck in my head because of this theme, I’m picking llamas next time so I can return the favor.

Not if I beat you to it: http://youtu.be/ZeCm793CFZo

 
Flag Post

Topic: Game Programming / [Solved I think] How to _copy_ semi-transparent pixels?

Originally posted by Draco18s:

Copy Pixels can’t do transparency. You have to use Draw()

I hope I’m just misinterpreting something here, because copyPixels most certainly will copy partially-transparent BMDs. I suspect what’s going on is what Amibtious said, and the only workaround I can think of involves either drawing the circle with more opacity or using lines thicker than 1 pixel.

 
Flag Post

Topic: Game Programming / GiTD #42 - *Pirates*

Originally posted by Shalmezad:

(of course, some of you may want to consider that piracy means something completely different now that what it used to)

NO! All games MUST be about looting, plundering and sailing the seven seas, matey! I just hope I can come up with something worthy of the theme. In the meantime, this should help set the mood a bit: http://youtu.be/xDVdo2-JGtg