var arr:Array = new Array(); var p:Function = arr.push; p("hello"); p("whats up?"); for each(var s:String in arr){trace(s);}
Saturday, September 14, 2013
With is not the only way to shorthand in AS3
Monday, July 29, 2013
Intellesense Recognizes imports but FlashDevelop compiler does not
Thursday, July 18, 2013
Hide Flixel Mouse and Show System Cursor
Saturday, May 25, 2013
InfinityBomber76
Tuesday, May 14, 2013
Static Initializers In Haxe
public static var NUMBERS = { var a = new List(); for (i in 0...10) a.add(i); a; // result of last block expression is saved in NUMBERS }
Monday, May 13, 2013
Function Types In Haxe
// fType : T -> Void // argument means that it takes a function "fType" // that takes one argument of type "T" and returns Void. public function applyFuncToAll( fType : T -> Void ):Void { cur = first; while (true) { //Call bound function on current object in list. fType( cur.obj ); if (cur.hasNext) { cur = cur.next; } else { break; } } }
Sunday, May 5, 2013
CS5 crashes on startup or new file creation
Saturday, May 4, 2013
Packages and Imports in Haxe
Unlike in Actionscript, it looks like you must conform to the "Constant-Class" rule when naming packages. --Notes------------------ The class path: import com.JMIM.TestClass; Gave me an error "Unexpected com" or something like that. I thought it might be namespace collision since the NME library also has a com folder so I tried: import dotCom.JMIM.TestClass; And changed the folder structure accordingly only to end up with the same error. During this whole time I did make sure to add my personal library by putting another source path tag into the .nmml file. Then I started getting errors something along the lines: "Unexpected class JMIM" or something. I changed it to: import dotCom.jmim.TestClass; Getting closer to a compile. :) Also, it looks like restarting my computer after messing extensively with the package structure MIGHT be the way to go once you've done everything you can think of. --------------------------
Thursday, May 2, 2013
AppTopia
Wednesday, May 1, 2013
How to add library in Haxe / NME / NMML
<!-- Paths to libraries. Must be declared here. Not in the project properties. -->
<source path="Source" />
<source path="C:\Users\JMIM\Desktop\HAXELIB" />
Sunday, April 28, 2013
Haxe Flixel Links
Wednesday, March 20, 2013
added to my list of people to stalk
Trig rounding errors in AS3
Thursday, March 14, 2013
Iterate through quadrants
var xo:int; //x offset. var yo:int; //y offset. var i2:int; var z0:int; var z1:int; var zeroMaybe:int; for (var i:int = 0; i < 4; i++) { zeroMaybe = (i < 2) ? 0 : 1; i2 = i + 1; z0 = (i & 1); z1 = (i2 & 1); xo = (z0 + (-1 * z1)) * zeroMaybe; yo = (z1 + ( -1 * z0)) * (1-zeroMaybe); trace("debug"); }Guess I should just put the pairs into a vector. Trying to iterate over checking 4 positions relative to a tile: UP,DOWN,LEFT,RIGHT. By outputting the correct offset values each iteration: [0,1] [0,-1], [1,0], [-1,0] in no specific order. Actually... This isn't bad for building a lookup table that is a linked-list. Same thing said another way:
for (var i:uint = 0; i < 4; i++) { var and3:uint = i & 3; //OUTPUT: 0,1,2,3 0,1,2,3 //OUTPUT in BINARY: 00, 01, 10, 11 //If we SUBTRACT the bits, we can get 0,-1,1,0. Just what we need. var a3 :uint = (i + 2) & 3; //same as and3, but input is shifted over two. //When and3 and a3 are converted to -1,1,or zero, we will have the following outputs in this order: // [0,1] , [-1,0], [1,0], [0,-1] ALL THE KITTY KORNERS. var npX:int = ((and3 & 2)>>1) - (and3 & 1); //convert number 0-3 to: 0,1,-1 var npY:int = ((a3 & 2)>>1) - (a3 & 1); //convert number 0-3 to: 0,1,-1 //Building linked-list table of offset quadrant values: cur.x = npX; cur.y = npY; if (i != 3) { cur.hasNext = true; cur.next = new LinkedXYPair(); cur = cur.next; } trace("debug: [" + npX + " : " + npY + "]"); }
Sunday, March 10, 2013
Shiny Little Plasma Flares
Wednesday, March 6, 2013
When is SetPixel32 Faster than CopyPixels?
package { //Common knowledge is SetPixel32 is slower that CopyPixels. //What I want to know however is... What is the equivalency ratio? //Meaning: //Does using setPixel32 100 times take the same amount of time as CopyPixels for a (100x100) (10,000 pixel area)? Or something like that? //If you are going to use particles that use the "setPixel32" command... We need to know. //Compare setting pixel32 to usingCopyPixels on ONE pixel and see the speed difference. import flash.display.BitmapData; import flash.display.Sprite; import flash.events.Event; import flash.geom.Point; import flash.geom.Rectangle; import flash.utils.Timer; import flash.utils.getTimer; /** * ... * @author JMIM */ public class Main extends Sprite { public function Main():void { if (stage) init(); else addEventListener(Event.ADDED_TO_STAGE, init); } private function init(e:Event = null):void { removeEventListener(Event.ADDED_TO_STAGE, init); // entry point for (var i:int = 1; i < 100; i++) { pixelTest(i); } } public function pixelTest(inRecSize:int):void { trace("rec size == " + inRecSize + "--------::"); var t1:Number; var t2:Number; var tt:Number; var counter:int; var counterMax:int = 98765; var theBm:BitmapData = new BitmapData(500, 500, true, 0x00); var copyFromBm:BitmapData = new BitmapData(500, 500, true, 0x00); var ZZ:Point = new Point(0, 0); var rec1x1:Rectangle = new Rectangle(0, 0, inRecSize, inRecSize); var setPixelCount:int = 0; var setPixelTimes:int = (inRecSize * inRecSize); t1 = getTimer(); counter = 0; do { counter++; if (counter > counterMax) { break; } setPixelCount = 0; do { setPixelCount++; if (setPixelCount > setPixelTimes) { break;} theBm.setPixel32(10, 10, 0x88FF); }while (true); }while (true); t2 = getTimer(); tt = t2 - t1; trace("setPixel32 time:: tt==" + tt); t1 = getTimer(); counter = 0; do { counter++; if (counter > counterMax) { break;} theBm.copyPixels(copyFromBm, rec1x1, ZZ, null, null, true); }while (true); t2 = getTimer(); tt = t2 - t1; trace("copyPixels time:: tt==" + tt); } }//class }//package
//OUTPUT: rec size == 1--------:: setPixel32 time:: tt==50 copyPixels time:: tt==160 rec size == 2--------:: setPixel32 time:: tt==130 copyPixels time:: tt==160 rec size == 3--------:: setPixel32 time:: tt==270 copyPixels time:: tt==170 rec size == 4--------:: setPixel32 time:: tt==470 copyPixels time:: tt==170 rec size == 5--------:: setPixel32 time:: tt==680 copyPixels time:: tt==170 rec size == 6--------:: setPixel32 time:: tt==980 copyPixels time:: tt==180 rec size == 7--------:: setPixel32 time:: tt==1320 copyPixels time:: tt==170 rec size == 8--------:: setPixel32 time:: tt==1730 copyPixels time:: tt==180 rec size == 9--------:: setPixel32 time:: tt==2150 copyPixels time:: tt==190 rec size == 10--------:: setPixel32 time:: tt==2690 copyPixels time:: tt==190 rec size == 11--------:: setPixel32 time:: tt==3220 copyPixels time:: tt==190 rec size == 12--------:: .... //Personally interested in this one, because my tilemap uses 16x16 tiles: rec size == 16--------:: setPixel32 time:: tt==6830 copyPixels time:: tt==210
Particle Bit Packing Math Experiment
//Packs position, velocity, acceleration, and color into a SIGNED(+-) integer. public function putPVAC(p2047:int, v127:int, a7:int, c3A:int, c3R:int, c3G:int, c3B:int):int { //SIZES: HEX BITS UINT INT BIN //pos: FFF 12 4095 +-2047 1111 1111 1111 //vel: FF 8 255 +-127 1111 1111 //acc: F 4 15 +-7 1111 //clr: FF 8 255 N/A 1111 1111 // aa: 3 2 3 3 11 // rr: 3 2 3 3 11 // gg: 3 2 3 3 11 // bb: 3 2 3 3 11 //pack in position: var packed:int = p2047; packed = packed << 8; //shifting to make room for VELOCITY. //pack in velocity. if (v127 < 0) { v127 = 127 + (0 - v127);} //handle negative numbers. packed = (packed | (v127 & 0xFF)) << 4; //shifting to make room for ACCELERATION. //pack in acceleration: if (a7 < 0) { a7 = 7 + (0 - a7); } //handle negative numbers. packed = (packed | (a7 & 0xF)) << 2; //shift to make room for first color component. // 42 127 212 //0 ----- 85 ----- 170 ----- 255 //pack in ARGB: if (c3A > 212) { packed = (packed | (0x3)); } else if (c3A > 127) { packed = (packed | (0x2)); } else if (c3A > 42 ) { packed = (packed | (0x1)); }; //other wise it is zero and nothing needs to be set. packed = (packed << 2); //shift to make room for SECOND color component. // 42 127 212 //0 ----- 85 ----- 170 ----- 255 //pack in ARGB: if (c3R > 212) { packed = (packed | (0x3)); } else if (c3R > 127) { packed = (packed | (0x2)); } else if (c3R > 42 ) { packed = (packed | (0x1)); }; //other wise it is zero and nothing needs to be set. packed = (packed << 2); //shift to make room for THIRD color component. (G) // 42 127 212 //0 ----- 85 ----- 170 ----- 255 //pack in ARGB: if (c3G > 212) { packed = (packed | (0x3)); } else if (c3G > 127) { packed = (packed | (0x2)); } else if (c3G > 42 ) { packed = (packed | (0x1)); }; //other wise it is zero and nothing needs to be set. packed = (packed << 2); //shift to make room for FOURTH color component. (B) // 42 127 212 //0 ----- 85 ----- 170 ----- 255 //pack in ARGB: if (c3B > 212) { packed = (packed | (0x3)); } else if (c3B > 127) { packed = (packed | (0x2)); } else if (c3B > 42 ) { packed = (packed | (0x1)); }; //other wise it is zero and nothing needs to be set. return packed; } public function getPVAC(com:int):void { var acc:int; var vel:int; var pos:int; var clr:int; var color:uint; // AA RR GG BB // 11 11 11 11 //extract color: // 0xC0 | 0x30 | 0xC | 0x3 clr = com & 0xFF; //ARGB color channels. color = ( ((clr & 0xC0)>>6) * 85) << 24 | ( ((clr & 0x30)>>4) * 85) << 16 | ( ((clr & 0xC )>>2) * 85) << 8 | ( ((clr & 0x3 )>>0) * 85) << 0; //extract acceleration. com = com >> 8; acc = com & 0xF; if (acc > 7) { acc = 7 - acc; } //extract velocity. com = com >> 4; // ==com >> 12 when looking at cumulatively. vel = com & 0xFF; if (vel > 127) { vel = 127 - vel; } //extract position: //This is only ONE line because the signed bit on the com integer affects this. pos = com >> 8; // ==com >> 20 when looking at cumulatively. trace("color==" + color); trace("pos ==" + pos); trace("vel ==" + vel); trace("acc ==" + acc); //make sure color is what you think it is: var rgb:RGB = RGB.make(color); trace("a ==" + rgb.Alpha); trace("r ==" + rgb.Red); trace("g ==" + rgb.Green); trace("b ==" + rgb.Blue); }//getPVAC
Tuesday, March 5, 2013
int(2147483648)
t1 = getTimer(); counter = 0; do { counter++; if (counter > counterMax) { break;} someValue = int(2147483648); }while (true); t2 = getTimer(); tt = t2 - t1; trace("tt==" + tt); t1 = getTimer(); counter = 0; do { counter++; if (counter > counterMax) { break;} someValue = int.MIN_VALUE; }while (true); t2 = getTimer(); tt = t2 - t1; trace("tt==" + tt);
Friday, March 1, 2013
Thursday, February 21, 2013
Generating Classes at Runtime
Tuesday, February 19, 2013
ThreeBlockTypes
Sunday, February 17, 2013
Bomb Type Design
1. Invincible walls.
2. Explosions stop at invincible walls.
3. Icons for different bombs translate to how they explode.
4. Bomb modifier that can kill any type of block.
5. When holding keys while going through exit door, the next level loads right away.
Need to prevent this and give the user more time between level transitions.
Change between: pressed to justPressed
6. Bunnies set off the bombs and are a general pain in ass.
Bunnies can fall in ooze and turn into monsters.
Friday, February 15, 2013
B0X Att@ck
Wednesday, February 13, 2013
Note Sketches
Sunday, February 10, 2013
POD Cloner iterates through non-dynamic properties just fine
package JM_LIB.utils { import mx.utils.ObjectUtil; /** * Clones any POD (plain old data) class: * @author JMIM */ public class PODClonerUtil { public function PODClonerUtil() { }; public static function clone(inObj:Object):* { //Step1: Get class of inObj, and instantiate a new object of that type. var c:Class = inObj.constructor; var newObj:Object = new c(); //POD clases take zero parameters. //Use Flex's ObjectUtil to extract properties of object. var classInfo:Object = ObjectUtil.getClassInfo( c ); var propArr:Array = classInfo.properties as Array; var prop:String; //must use this type of loop. Because the other will NOT work. for each (prop in propArr) { if (prop == "prototype") { continue;} newObj[ prop ] = inObj[ prop ]; } /* * //Does same thing as for each loop above. for (var i:int = 0; i < propArr.length; i++) { prop = propArr[i].localName; if (prop == "prototype") { continue;} newObj[ prop ] = inObj[ prop ]; } */ return newObj; } } }
Wednesday, February 6, 2013
Reference static class via variable
Friday, February 1, 2013
Make sure object property exists
Wednesday, January 30, 2013
Saturday, January 26, 2013
GlitchMode
Tuesday, January 22, 2013
Ray lighting blocked out
Wednesday, January 16, 2013
Buffered Lighting System In
Light todo simple: A dark yellow tile will direct us to stamp a certain type of light at that coordinate. Light todo ADVANCED: Make it auto-project based on where it was set on the tile-map: 1. If tile directly below EXISTS: Project LIGHT THROUGH ALL TILES BELOW TILL YOU REACH FIRST EMPTY TILE 2. If tile NO TILE directly below: Project LIGHT till you hit a tile. Make light COVER that last tile that was hit. 3. If you have a HORIZONTAL row of CONNECTED light tiles, make all lights the SAME length. 4. If you have VERTICLE column of connected lights, DO step #3, but also make the lights project LEFT or RIGHT rather than DOWN. Deciding which way to project: Whichever side has the most empty space. Deciding how LONG the light is: Steps 1-3 still apply here. But on x-axis instead of y-axis.
Thursday, January 3, 2013
Binding Getters To Function Types
package { import flash.display.Sprite; import flash.events.Event; /** * ... * @author JMIM */ public class Main extends Sprite { public function Main():void { if (stage) init(); else addEventListener(Event.ADDED_TO_STAGE, init); } private function init(e:Event = null):void { removeEventListener(Event.ADDED_TO_STAGE, init); // entry point var hg:HasGetter = new HasGetter(); var func:Function = hg.getStuff; func(); } } } internal class HasGetter { public function get getStuff():Boolean { trace("hay!"); return true; } public function HasGetter() { }; }
Wednesday, January 2, 2013
Making Calculations
//TAKEN FROM STACK OVERFLOW:--------------------------------------------
Your problem is caused by the fact that Flash uses pre-multiplied alpha. Usually this is not a big issue, but it becomes very apparent if you have pixel values with very low alpha values which unfortunately are very common when you use a blurred soft-feathered brush. The pre-multiplication causes an information loss in the pixels - and when you have low alpha values the color values are effectively getting rounded down which when you are drawing slowly in your app and the same pixels are getting drawn over each other again and again will cause the area to get darker and darker. For some more details on the pre-multiplication issue check an old post of mine: http://www.quasimondo.com/archives/000665.php There is nothing you can do about this except if you handle the alpha channel and the rgb channel separately. But then you will also have to do all the compositing yourself which is not a trivial task and might slow down your app too much.
-------------------------------------------------------------------------Hmm... Even if it was fixable, saving out PNG files with the correct alpha channel would still have problems. Don't use alpha channel.
1234 5678 --Set bits describe which channel pixel exists on. [1111 1111]R [1111 1111]G [1111 1111]B Thus, each pixel becomes defined by 3 bits. There are 8 possible combinations for bits: BINARY RGB-EQUIVALENT:
000 [000,000,000] BLACK 001 [000,000,255] BLUE 010 [000,255,000] GREEN 011 [000,255,255] CYAN 100 [255,000,000] RED 101 [255,000,255] MAGENTA 110 [255,255,000] YELLOW 111 [255,255,255] WHITE
Basically: Compressing 3bit color tilemap into a 24bit PNG. 24/3 = 8. Making file size 1/8th of what it would be otherwise. Of course, this limits your selection of tiles. But with clever auto-tiling, we've got something good here. Special items like entrance/exits will be defined in a text file. Shouldn't use a whole channel for something that is only ever going to use up, say TWO pixels on the entire level PNG.I have 9 Levels
Game now has 9 levels loaded from PNG files. Also has win/lose conditions. It's somewhat of a game now. TODO: 1. Gun that deters but does not kill enemies. Gun can also set off mines INSTANTLY, from a distance. 2. Enemies that are bound by gravity, but cling to the walls, making them more mobile than you. 3. Make it so you can die if you get caught in the blast. 4. Score will simply be stats on how long it takes to complete each level. 5. Ladder Tiles that allow you to climb. They will be immune to explosions. 6. Think about vines too. Maybe Cables in your game. Like this game android: http://www.newgrounds.com/portal/view/428733