# Recent posts by DPbrad on Kongregate

 I might have to miss this one. Who knew studying for a degree full-time and working part-time means that you have little free time? Unless you plan on your physics engine being very basic (Squares & Circles only), your going to have to understand and learn a lot of physics to get a decent engine going. I know as I started one of my own a while back, and it quickly gets complicated. Originally posted by vesperbot:hmm, N=5, one of the possible answers seems to be 1-2-4-5-6-30-120, is this optimal? I think 6-step is optimal for N=5, so yep. I remember the same question being asked ages ago somewhere (relating to SLP’s) and I remember the answer of finding the optimal k as being “There is no known way of 100% finding the lowest k value”. So this should be….fun? Right now, I am just bruteforcing from k=1 until I hit k=50 (at which point I tell my program to give up…) EDIT: OK, this is a little trickier than I first thought. I need to do some background reading into the area first to get a better idea of how to tackle this, as even with really low values of N, my current algorithm takes far too long once it hits around N=11. (It takes around 30 minutes of execution time to get N=11, and the way it works means I cannot get the ‘winning’ sequence right now.) For N=1→11 I got; N = 1, N! = 1, k = 0 N = 2, N! = 2, k = 1 N = 3, N! = 6, k = 3 N = 4, N! = 24, k = 4 N = 5, N! = 120, k = 7 (Definitely not the optimal answer…) N = 6, N! = 720, k = 7 (?) N = 7, N! = 5,040, k = 7 (?) N = 8, N! = 40,320, k = 7 (?) N = 9, N! = 362,880, k = 8 (?) N = 10, N! = 3,628,800, k = 9 (?) N = 11, N! = 39,916,800, k = 11 (?) Just from thinking this through, I would think almost every sequence should have a k value of around 8 or lower. Originally posted by player_03:Originally posted by ErlendHL:Couldn’t find type in circleBodyDef Are you using box2Dflash? I checked, and `type` is defined on line 67 of b2BodyDef. Additionally, `SetType()` is defined on line 897 of b2Body. For some reason, neither one appears in the online documentation, but they’re definitely there. It is in Box2D 2.1, but Erlend is using the old version and I don’t think that “type” property of a “b2BodyDef” was implemented in the old version. Regarding the shakiness Erlend, I would recommend just using the newer Box2D (2.1a). It contains a lot of fixes over the old version and you dont require as many lines of code for the same functionality you desire. Originally posted by lan14n:I copy pasted it from a tutorial Uh-oh… Your problem is here ```loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit); loader.addEventListener(IOErrorEvent.IO_ERROR, onURLError); ``` Your first event listener you add to the contentLoaderInfo (as you should with a Loader object), but you then add the other event listener directly to the loader object, which I don’t think will ever get dispatched. ```loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onURLError); ``` That’s what it should be. You may need to call SetMassFromShapes on your circle b2Body then if your using 2.0.2… EDIT: After line 56 in your pastebin code. ```circleBodyDef.type = b2Body.b2_dynamicBody ``` If you own Flash CSx, you can export a .swc with the components you want inside (and link them I believe) and you can then use them from inside FD as you wouild any imported .swc file. I did this once when I had access to a Flash CSx copy, and it worked fine. Originally posted by RandyZ:Okay, so i want to make my first game Great! Originally posted by RandyZ: and i want it to be a browser based mmofps Oh dear. Originally posted by alecz127:@DPbrad I’d love the source if you wouldn’t mind. I think its making more sense. Sure, here you go: http://dpbrad.com/storage/Metaballs.zip http://www.fastswf.com/Nmx6mcc Click on the left side of the window to get the original blurred bitmap, and then the meta-ball effect on the right. I whipped this up quite quick so it looks a bit ugly but the basic principle works. Code: Meta-bitmap blur ```_meta.bitmapData.fillRect(_meta.bitmapData.rect, 0); _meta.bitmapData.threshold(_bitmap.bitmapData, _bitmap.bitmapData.rect, new Point(0, 0), ">", 0x88888822, 0xffffffff); _meta.bitmapData.applyFilter(_meta.bitmapData, _meta.bitmapData.rect, new Point(0, 0), new GlowFilter(0xFFFFFF)); ``` _bitmap is just the original bitmap on the left, which gets gradient filled shapes drawn to its bitmapData. EDIT: Another meta-ball test I found. http://www.fastswf.com/X_xnhtI I have the source if you want it, just ask and ill upload it. I would prefer a GiTD every month, should help get me motivated and organised for 1GAM throughout the year! Although I cannot help you with your issue as I cannot remember AS2 (I think my brain threw all knowledge of it away when I learnt AS3), I would recommend stop using AS2 and move to AS3. I will link you to this topic by Senekis who wrote a comprehensive list of reasons to do so, and also, you will have much more success with finding help if you have a problem in AS3, rather than AS2. Especially as you most likely only just started learning AS2, you can quit and get out before you get “stuck” in it! LINK This will work without antiAliasing. ```var bd1:BitmapData = //whatever var bd2:BitmapData = new BitmapData(bd1.width * 2, bd1.height * 2); var matrix:Matrix = new Matrix(); matrix.scale(2, 2); bd2.draw(bd1, matrix); var bitmap2:Bitmap = new Bitmap(bd2); ``` EDIT: Minor correction. For your issue, there are a few things I can point out: 1: You don’t need an Event.ENTER_FRAME event listener, as you aren’t even using it. 2: You seem to be trying to add an event listener (KeyboardEvent.KEY_DOWN) to the stage, at a point where the stage may not actually be accessible. 3: You are not type-casting your “MyKey” variable. It is good practice to do so (var MyKey:int = k.keyCode). 4: Although it is personal preference, naming all your functions and variables like “myKey” and “mainKeyboard” instead of “MyKey” and “MainKeyboard” usually looks cleaner and more readable (But is up to you). 5: Ensure you specify the type of object (or value) a function returns, try not to leave it blank. If your function does not return anything, use `:void`. However your biggest problem is you have what I like to call a “if if if” problem. Lets run through your MainKeyboard function as if StageQuality is equal to StageQuality.HIGH (What it defaults to). `if(stage.quality==StageQuality.HIGH)` Well, this will be true, so we will now set stage.quality to LOW `if(stage.qualityStageQuality.LOW)` Well, this is going to be true now as well, so set the stage.quality to MEDIUM `if(stage.qualityStageQuality.MEDIUM)` Woah, this will be true too! So we now set the quality to HIGH. But, we are now back to where we started! Oops. To solve this problem, we can just add some simple “else if” statements. View the full fix (Including my above suggestions) below: *Note, I changed some things. Notably I dont use the StageQuality class, as it doesn’t seem to work for me. ```public class Main extends MovieClip { public function Main() { if (stage) init(); else addEventListener(Event.ADDED_TO_STAGE, init, false, 0, true); } private function init(e:Event=null):void { removeEventListener(Event.ADDED_TO_STAGE, init); stage.addEventListener(KeyboardEvent.KEY_DOWN,keyDown,false,0,true); } public function keyDown(k:KeyboardEvent):void { var myKey:int = k.keyCode;//MyKey = the pressed key if (myKey == Keyboard.Q) {//81 is the number for Q, I think if (stage.quality == "LOW") { stage.quality = "MEDIUM"; } else if (stage.quality == "MEDIUM") { stage.quality = "HIGH" } else if (stage.quality == "HIGH") { stage.quality = "LOW"; } trace("New quality: " + stage.quality); } } } ``` If you have any questions, feel free to PM me or post here again. Originally posted by NineFiveThree:stage is also possibly null (depending on where your code is located), it’s not recommended to add childs to it anyway I already confirmed that stage was not null, and I was only adding to that as I knew that was the only DisplayObjectContainer that wasn’t null. Anyway, I will be going through voting on submissions too. I will choose my #1 & #2 when I have played all games. MossyStump – Portal or Die It took a few deaths until I figured out what to do, but once I did I quite liked it! I did experience a few bugs but all in all a nice game, that with polish and some other features/ideas, could be a cool puzzle game. Originally posted by UnknownGuardian:Sorry. I’ve got an issue where my FlashDevelop’s debugger can’t connect to flash player ( I assume I have a wrong version of Java that prevents this). Also, just because it is cool, the mine system is entirely event based. If a mine has full resources it makes a request for a cart. All the carts listen and then the one that is on same floor as the mine is notified and adds the full mine to it’s queue of mines to go to. When a minecart has a full basket it heads back to the central shaft and makes a request for an elevator. Same thing with the elevator. It adds the cart to it’s queue and picks it up when it gets to it. Then it takes a fully loaded basket to the surface to drop resources off and brings it back down to the cart where it notifies the cart that the basket has been reattached so it can go pick up more resources. Cool stuff. Nice, I love setting up automated event systems similar to this, when they work right they are awesome. Finally figured it out. Needed to send my URL requests through a slightly different URL to avoid crossDomain issues. Everything loads alright now. phew! I have tried .allowDomain() and .loadPolicyFile() to no effect. Ok, I seem to have found the source of the issue, namely rogue URLLoaders() returning garbage data, due to good old security issues I assume. Using Vizzy, I found these issues. How do I resolve these errors (Never seen them before). ```Error: Request for resource at HIDDEN_URL.json by requestor from SOURCE_URL is denied due to lack of policy file permissions. *** Security Sandbox Violation *** ``` ```try { home = new Home(); stage.addChild(home); } catch (e:Error) { var t:TextField = new TextField(); t.width = 640; text.height = 480; t.textColor = 0xFFFFFF; t.text = e.message; stage.addChild(text); text.appendText("\n" + home); } ``` When testing locally, this works fine and everything goes as expected. When I test on my private server, my public server and even testing an uploaded version to Kongregate, it fails at that point and states that home==null, error 1009. What is going on? For added confusion, this is the Home class. The Page class is simply a class which extends a Sprite with a custom Event system (Which I have removed and it still doesn’t work). ```package screens { import dpbrad.Page; import dpbrad.PageEvent; /** * ... * @author DPbrad */ public class Home extends Page { public function Home() { } } }``` Originally posted by ErlendHL:Did it and it worked, thanks! Also found out by trial and error that it’s the gdefault element that is no text! Edit: What element is the panel between the linenumbers and the actual code, with the [-]’s for shortening code? Marker Back and Marker Fore I cannot see anything wrong with the code, as long as your Main.w and Main.h values are what I expect they are (stage dimensions) and circle.radius is the radius of the circle (duh). Are you adding/removing any circles in the “circles” Vector/Array?