Tuesday, February 28, 2012

Acid Smoke System As3

I wanted to finish this up a bit more before I posted it..
But I made myself a promise of one awesome thing a day...
And my mental capacity has been drained.

Got gradient rectangle algorithms on my mind.

Monday, February 27, 2012

Looping Wobbly Surface, coded in AS3

Still working on getting it real-time.
Need to make the tree have a "smart-update" option when updating recursively.

Sunday, February 26, 2012

Pre-Rendered Explosion in AS3

If I can make a script to center these bitmaps into a movieClip,
pre-rendered explosion effects may be a good way to go.

Self-Respect has been earned today.
I must now reward myself with caffeinated sugar water.

Saturday, February 25, 2012

Happy Accident

On my way to creating an explosion effect.
Thought this thing I made was kinda cool.
Too "Static" to use as a layer in my explosion thought.
Going to work on a bitmap merger class that will take all of
my effects layers and merge them together.

EDIT: After 2 hours I found I can embed my flash files using deviant art...
2 hours of searching for a way to host a simple .swf file... grrr.

Friday, February 24, 2012

Displacement Map gives explosion ideas

//It was my goal today to learn how to make fire with perlin noise in flash.
//looked up some source and... Well.. I realized I needed to be a little less
//ambitious and do a working test of a displacement map. So, here is my working
//test of a displacement map. This is giving me ideas for how to make some pre-rendered explosion effects for the game.

Thursday, February 23, 2012

Object type can work like dictionary as3

//Did not know this could be done:
var mc:MovieClip = new MovieClip();
mc["x"] = 0; //works like mc.x
mc["y"] = 0; //works like mc.y

//Also, while trying to make a function to put objects in a "global dictionary",
//I realized that... I need an "Object" instance... not a "Dictionary" instance.
var obj:Object = new Object();
obj["kay"] = "123"; //store value
obj["pika"] = mc; //store object

Clear Dictionary AS3

//Use two steps to avoid changing the dictionary while iterating over it.
//Also, the keys are type "Object" not "String. For speed, use a vector and
//store it's length in a variable before iterating over it. Lastly, just to be safe,
//nullify entries in vector as you go along. Since the whole point of clearing out
//a dictionary in the first place is to de-reference the items within it.

function clearD(d:Dictionary):void{
    //Get Keys from dictionary.
    var idVec:Vector.<Object> = new Vector.<Object>(0);
    for(var obj:Object in d){
    }//[next obj]
    //Delete Keys from dictionary and clear from vector at same time.
    var vLen:int = idVec.length;
    for(var vi:int = 0; vi<vLen; vi++){
        delete d[ idVec[vi] ];
        idVec[vi] = null;
    }//[next vi]

Tuesday, February 21, 2012

Problem with OH_CenterOfUniverse

I had more ambitious goals for my next update...
But instead spent a lot of time getting bugs out of existing code
and polishing up the UI functionality a bit. Scrolling background is not
parallaxing correctly because it is wired to a value that is tessellating/wrapping.
That value coming from my "OH_CenterOfUniverse" class... I swear there is no tessellation code in that class... Mind is fried. Just going to post what I have.

Saturday, February 18, 2012

Sometimes my friends make me do math

Could World's population fit within Nevada?

//Could you pack the world's population into nevada:
var nSurf_miles:Number = 110561;
var metersPerMile:Number = 609.344;
var nevadaSurfArea:Number = nSurf_miles * metersPerMile; //surface area of nevada in miles multiplied by meters per mile.
var nonPersonalSpace:Number = 0.3;    //0.3 meters is about 1FT. putting each person in a 1ftx1ft box.
var worldPop:Number = 6.995 * Math.pow(10,9); //(10^9);
trace("worldPop ==" + worldPop);
var linearSpace:Number = worldPop * nonPersonalSpace;
var surfArea:Number = Math.sqrt(linearSpace); //in meters squared.

trace("surfArea == " + surfArea);

if(surfArea <= nevadaSurfArea){
 trace("it could work");
UPDATE: According to one of my facebook programmer friends. My calculations are wrong. Here is his code.
local feet_per_mile = 5280
-- Surface area of Nevada, in square feet
local sqf_nevada = 110561 * feet_per_mile
-- According to the U.S. Census Bureau, the total population of the World,
-- projected to 02/19/12 at 12:00 UTC (EST+5) is
local pop_earth = 6995347552
print("If you tried to fit the entire population of the Earth into Nevada,")
  "each person would have %.3f square inches of personal space!",

HereDoc As3

var myString:String = (<![CDATA[
                        Here is my string
                        that spans multiple
                       ]]> ).toString();

found here:

Friday, February 17, 2012

Unit Test Side-Track

My casual attempt to code up some "quick" unit tests.
Has resulted in using the whole day to make up a unit-test framework.
Hopefully it will pay off with faster productivity...

Originally I had decided that from now on all my classes would have
their own static method called "UNIT_TEST" from which my master unit test
module would call.

Problems with this model:
[1]: Bloating of compiled .swf.
Flash Develop has optional compiler directives you can use.
But I want my code to be pure AS3.
More about that here: CONFIG::debug
[2]: Navigating through class to edit is harder because now
there is more text to dig through. Find and Replace method
will often put you into the unit-test code when you are trying
to correct errors in your class. This is especially true when
your unit test is very thorough.

New Model:
Since all my classes are in a folder with the SAME name,
there will be an accompanying file called "UNIT_TEST.as"
in that folder.

String Swapper App for my personal coding use

I made this app because I was sick of redundantly swapping out X an Y's in code.

A text-editor takes 3 steps and requires a proxy variable.
Step1: X replaced to K.
Step2: Y replaced to X.
Step3: K replaced to Y.

My App Requires ONE(1) step:
Step1: X swapped with Y.


Unfortunately, I thought this code was going to be simple...
And as a result of my hubris, this function is NOT token based.
Which means that if you tried to swap "A" with "APPLE" you might
have a problem since "A" is contained within "APPLE".

Good news though, for complex variable names, you can put in a list of
things you want swapped and do it in one operation!

Thursday, February 16, 2012

Swap without temp variable, AS3

var in_X1:int = -2;
var in_X2:int = 7;

in_X1 = in_X1 + in_X2; //1 & 2
in_X2 = in_X1 - in_X2; //1 & 2 remove 2, now is original 1.
in_X1 = in_X1 - in_X2; //1 & 2 remove 1, now is original 2.

trace("in_X1 == " + in_X1);
trace("in_X2 == " + in_X2);

tessellate signed number into positive range

//Tessellate negative or positive value into range: 0-4.
var xNum = 5; //means that we will modulate between 0 to 4.
var outp:int;
for (var i:int = -10; i<10; i++){
 outp = i % xNum;
 if(outp<0){outp = xNum + outp;}
 trace("["+i+"] --->" + outp );

Friday, February 10, 2012

x>0 faster than x==0

My assumptions where correct.
Checking to see if x>0 only requires checking 2 of the bits in the uint,
while checking to see x==0 requires checking ALL bits.

Bit Shift Populate Speed As3

Note on populating a uint's bits:
The shifting left(<<) method is faster than the shift right(>>>) method.
(>>>) is faster than (<<), but setting the LEAST significant bit is
faster than setting the most significant bit.

theUint = theUint << 1;
theUint = theUint | 1;

theUint = theUint >>> 1; 
theUint = theUint | mostSigBit; //Where mostSigBit = 0x80000000 DO NOT HARDCODE.
                                //Will be super slow if you do.
                                //Don't do this:
                                //theUint = theUint | 0x80000000;

Thursday, February 9, 2012

custom bitArray decision AS3

A custom "bitArray" made with vectors and uInts is FASTER than
using a bitmapData object as a bitArray... 6X faster... now need to
test my assumptions against a byteArray object to see if my method is also
faster than that.

I would post code... But the bit shifting operators ">>>" break the HTML
in my post and the code and pre tags are not working. :(

Parallaxing and Tesselating background code finished!

This didn't get done as soon as I wanted due to some hard drive failure.
Recovery wasn't too tedious since I backup often... But it did make me take
most of the day to restore my files and then re-think my backup strategy
so next time restoration is quicker when something goes wrong.

Tuesday, February 7, 2012

parallaxing background code as3

Need Sleep...

Though it looks like I am shifting MANY tiles positions....
The positions of all the tiles are STATIC. But, I have one master tile
that is sliced, diced, and pieced back together so that it's top-left corner can
end up anywhere inside itself.

In simpler terms: The tiles are not moving.
They are static tiles with animations on them giving the illusion of movement.

Saturday, February 4, 2012

Files For Jaron


The source FLA file so you have the dimensions you are working with.
Here are the sizes I am set on:
[1]: The playing area with the ships and explosions and stuff.
[2]: The rectangular partition next to the playing area.
(set on that size partition, but organization of elements inside of
is whatever you feel like.)
[3]: The amount of area given to each person who's work on the game in the credits.

All other items sizes can be changed to whatever you feel like.
Also, the behavior of how the buttons kind of pulse is not a dead-set thing
either. That's just something I coded because I didn't have time to do art
for buttons and wanted quick interactive and decent buttons with minimal work.

If you want to mess around with the current working prototype: