How to make a Platform Game – source-code options

Following some feedback on reddit regarding the price of the source code, I’ve decided to offer people who’d like to get access to the source code accompanying this series of articles a few choices.

Totally free version


Click to give focus, then cursor keys control the green player character.

This versions contains the bare essentials of the game, one player character, one map, one tile type, no level progression, no enemies, no fancy graphics, or dependence on the Flash IDE. Basically, everything you see in the demo above, including the nice robust camera system.

This version is recommended for anyone who wants to get a pretty decent code framework in which to build their vision of the game or for anyone who is interested in sampling the quality of my code before making a purchase of the other, more advanced versions.

Download it here for free

Update: this version is now available on IOS, courtesy of Gabriel Sanchez who wrote an article about the port. You can read it (and download his version) here: http://gabrieldsblog.wordpress.com/2013/12/29/2d-platform-game-ios-port-part-1/


USD 9.99 version

This version contains all the assets of the full game, but only one enemy type, no level progression, no parallax layers and no ladders.

I’d recommend this version for those who are interested primarily in having a very solid framework with a good set of features, have a strong desire to put their own mark on the game and a willingness to experiment and learn.

USD 9.99


USD 19.99 version – SALE: reduced from $49.99!

This is the complete version, with everything included.

I’d recommend this version for anyone who wants a nearly complete game they can make their own. Just by re-doing the gfx, and adding more levels you will have a completely unique and fun game.

USD 19.99


USD 49.99 version

This is the complete version, with graphics redone by Khan Studios.

I’d recommend this version for anyone who wants a neat tile-set and animated character set to go with the project, and to use in whatever else they see fit.

USD 49.99

85 Responses to How to make a Platform Game – source-code options

  1. Pingback: How to make a 2d platform game – part 2 collision detection | Paul's blog@Wildbunny

  2. Pingback: How to make a 2d Platform Game – part 1 | Paul's blog@Wildbunny

  3. Luke says:

    Hey Paul,

    Just tried to download the free version of this to investigate the AABB code a little further, but the download link (http://www.wildbunny.co.uk/downloads/platformerSimple.zip) returns a 404. Have you removed it in favour of the paid downloads or has it accidentally gone awol?

    Cheers!

  4. Luke says:

    Brilliant, thanks for sorting it out :)

    Oh, and huge thanks for your articles, s’all great stuff.

  5. Will says:

    Hi Paul i want to know if i buy the code when i will receive it and if is AS3 code

    • Paul Firth says:

      Hi Wil,

      You should be redirected after paypal to a download link on the wildbunny blog, so it should be instant :)

      Yes, its all AS3 code.

      Cheers, Paul.

      • Will says:

        Thx Paul i already bought and its helping too much but if possible can u awnser me a question about a code im doing
        I know this isnt ur job and u dont need awnser anything but i will be grateful if u help me

        I make a array and push the array to make number 2 become the walls but i dont know how to do to push number 1 to be a Ladder.

        ( [0,0,0,0,0],
        [0,0,1,0,0],
        [0,0,1,0,0],
        [2,2,2,2,2] );

        for (var i:int = 0; i<4; i++)
        {
        for (var j:int = 0; j1){
        aCollision.push(tileset);

        for(var i:int=2; i<aCollision.length; i++)
        "code to the wall"

  6. Dan Rostron says:

    Hi Paul

    I’m interested in using the framework you have created. One question though, I have a need to have angled platforms, ie. they will be sloped. Looking at your source code of the free version, I can see that you create the walls/platforms using a Matrix. Is this the same in the full version? So, I wouldn’t be able to create sloped platforms?

    Thanks in advance.
    Dan

    • Paul Firth says:

      Hi Dan,

      Right now all versions of the source only support platforms which are square. To add sloped platforms the collision detection would need changing, as its currently only performing AABB vs AABB.

      Hope that helps!

      Cheers, Paul.

  7. Bardikus says:

    Hello Paul, I downloaded the basic kit (too poor for others :( ) , but I don’t know how to run it.It has no exe or flash exported file in which i can run/play the game. All there is in my archive are a bunch of folders with some .as files and some other files which flash doesnt recognise and I don’t know/understand how to put it all togheter to get my game platform. you didn’t include any tutorial either ,so could you help me out a little? Thanks!
    p.s. : yes, I know the basics of flash and actionscript, I’ve managed to get some lynda tutorials to learn those

  8. karvinjarvis says:

    Yes, I downloaded 9.99 version of this game but I don’t know how to run it. So what should I do for playing game. Any one please suggest me how to play version of 9.99 game.

  9. Coop says:

    Hi Paul,
    I just began programming and the free version has really helped me learn. I decided to make a new map using mappy, but the tile.png file isn’t working in mappy. can you either tell me what I did wrong, or if I have the wrong file?

  10. Henning says:

    Hey Paul,

    i bought your 19.99$ Version. Now i want to change the graphics as a first step. so i open up the fl.fla in the dict assets with CS6… everything ok so far and i can change graphics….but i dont know how to create this swc file?! i mean if i select publish as swc i cant find such a file…hu? but if i select a single movieclip like “brainbrain” i can of course export a swc….however i guess i need the whole thing as a swc to change the graphics…

    sorry for my english i am from germany in europe ;)

    maybe u can help me :) thanks in advance.

    greets henning

  11. Henning says:

    Hey Paul,

    thanks for your fast answers :)

    so rough translated these are the 7 shown compile errors:
    1)
    Position:
    Symbol ‘DiamondPickup’
    Description:
    1152: In the definition inherited Code.Pickups:Diamond.m_flaCollision in namespace public is a conflict.

    2-7 is same conflict but different classes:
    Postion:
    1 Line
    Description:
    5000: The class ‘Code.Characters.LadySpikes’ must be, as it is associated with a symbol library of this type is a subclass of ‘flash.display.MovieClip’.

    ….

    im pretty confused at the moment i didnt changed anything of the original script code but maybe i am just not smart enough at this point and the solution may be very simple…

    greets henning

    • Paul Firth says:

      Hi Henning,

      Sounds like your class-path isn’t configured correctly?

      By default its set to point to a location on my machine, but you’ll need to update it to point to the location you extracted the project.

      Cheers, Paul.

      • Henning says:

        Heya Paul,

        i dont want to hurt your nerves but i am not quite shure what to do…guess i need to change the flash.display.MovieClip path but where to? and which file? hu?


        package {

        import flash.display.MovieClip;

        public class BrainFla extends MovieClip {

        public function BrainFla() {
        // constructor code
        }
        }

        }

        dont worry this will be my last question :)

        thanks in advance for your help
        greets henning

  12. Parker says:

    Hello Paul,

    I’am a Junior in High School and I am taking a digital design class. For my ‘final’ project of the year I wanted to do the art for a platforming game. Of course I am very interested in being a game developer, but I am still at the basics (if not below) on coding and that sort of things. However I can do the art side of things (and maybe the lvl design) and I would like to buy one of your ‘templates’ to change basically all the art + animations. The only problem is, is that I own a Mac and I use a Mac at school. I’ve tried to find an alternative to Flash Develop since it does not work on Mac, but I wasn’t sure if it would even work with the games you have created.

    So, Can I still do this on a mac? And I’ve looked into ‘bridging’ the program over, and/or using bootcamp but that would cost a good amount of money and time.

    Thank you,
    Parker

    • Paul Firth says:

      Hi Parker,

      If you have access to FlashBuilder, then that does have the capability to build the project but you’d have to set the project up yourself as I don’t have FlashBuilder. For Mac thats really the only option you have, unless you can dual boot.

      Cheers, Paul.

  13. Corey Bunnell says:

    Hey Paul,

    Thanks so much for making your source code available for us to dissect. It is nice to see some legit stuff.

    I have noticed a slight glitch however with the free version. Zooming with the camera causes cracks to appear between the tiles. In the camera class you have two lines of code to fix this:

    // this is essential to stop cracks appearing between tiles as we scroll around – because cacheToBitmap means
    // sprites can only be positioned on whole pixel boundaries, sub-pixel camera movements cause gaps to appear.
    m_worldToScreen.tx = Math.floor( m_worldToScreen.tx+0.5 );
    m_worldToScreen.ty = Math.floor( m_worldToScreen.ty+0.5 );

    However them seem to appear nonetheless.

    Any thoughts?

    • Paul Firth says:

      Hi Corey,

      I guess the only real answer I can give is that although the code does have functions to support zooming, the game itself was never designed with that in mind… Not a very good answer but I don’t have another solution to offer at this time.

      Cheers, Paul.

  14. Tomas says:

    here’s some questions I’ve come up with:
    do I need stencyl? There seems to be a problem with the program when I download it I get a message it’s damaged (I’m not using mac so their hotfix that they admit to isn’t working)
    how do I access your swc symbols and classes? I’m assuming that’s what holds all the animation content, I have a bunch of characters and animations I want to load directly into your game but I’m having a hard time navigating the complete package. You mentioned using amethyst with virtual studio, is this necessary? which copy of virtual studio are you using? I’m downloading the express 2012 windows desktop. I’m not sure if that is necessary, I really just want to swap out that pink character with the character I have and see him move :/

    • Paul Firth says:

      Hi Tomas,

      You don’t need styncl, just Flash CS4+ and FlashDevelop/Amethyst in order to build the project. I recommend using FD as Amethyst is a PITA to set up. All the assets are held in the .fla file which you load into CS4 and export as .swc.

      Hope that helps!

      Cheers, Paul.

      • Tomas says:

        what’s the name of the .fla? is that assets and assets_hk? I open up the assets.swc in flash and get an unrecognized file format error. If I open up assets or assets_hk there are 2 grids of animations, but if I swap out anything on the grids it doesn’t update in the game when I test it in flash develop.

        • Paul Firth says:

          Assets.fla is my programmer art, and assets_hk.fla is a different version by an artist. You’ll need to make sure flash is exporting the .swc correctly, i.e. with no errors messages. Check that your class-paths are set correctly to match the location of the project on your machine? And make sure the .swc is getting exported in the right location.

          Cheers, Paul.

          • Tomas says:

            hmmm I think I was just saving the fla and not exporting as an swc to use with the as3proj. ok, so I use the content in assets_hk.fla in flash export that as a swc, load that swc with that as3proj file in flash develop hit “test”, and I should be able to update the graphics from the assets_hk file right? I’m just looking for a streamlined process to updates that pink character and all his enemies.

          • Paul Firth says:

            Yes you can update the contents of whichever .fla file you choose, export over the top of the existing .swc file, rebuild the project in FD and bob’s your uncle.

            That’s about as streamlined as is possible :)

            Cheers, Paul.

          • Tomas says:

            ok, say hi to bob for me ;) I’m going to go play around with those files.

          • Tomas says:

            ok, I’ve successfully copied my character over the pink guy, now I’m ready to load up the work I’ve done from flash into flash develop. There are a lot of movies in that fla, if I right click the player it gives me the option to export that swc. how do I export the swc for the whole set of .fla? that should be my last question and the rest I can figure out on my own.

          • Paul Firth says:

            Not from the right click, but from the main menu, should be file->export movie, but make sure export .swc is checked in the settings :)

      • Tomas says:

        Do you know the exact method to produce the swc? I tried publish with swc check on publish settings, but it didn’t make anything. I tried export movie but it just exported a flash movie.

        • Tomas says:

          nevermind i figured that out and exported the swc. turns out i wasn’t saving the file after i set the path destination. ok, so that’s done but now I take it into flash develop and boom :

          [Fault] exception, information=Error: Assertion failed: Missing collision shape called “m_flaCollision”. throw new Error( “Assertion failed: ” + message ); wut.

          • Paul Firth says:

            Every character must have a symbol instance named called m_flaCollision – just copy paste the one from one of my characters and then place it in your own and make sure to name the instance :)

      • Tomas says:

        Ok, that went right over my head. where can I grab a m_flaCollision, what does it look like, and where does it go? also, I don’t really know about naming instances. When I try to publish the movie now I get a “ReferenceError: Error #1065:” on all the variables like: Variable MidgroundTileFla is not defined. I didn’t even touch that I just went to the player folder and swapped out the pictures :(

        • Paul Firth says:

          From the original symbol which you’ve replaced. It looks like a white circle IIRC. It sounds like it might be insightful to follow a few Flash IDE tutorials before going any further?

          Cheers, Paul.

          • Tomas says:

            oh that little white thing? nah, I’m just trying to swap out the graphics. I’ll worry about the programming some other time. I have a whole library of 3d models and images I made that I can just import into any game engine(so like, i can pose my characters, take pictures, and then just put them in your game on the fly)… trying yours out right now, might move on to another if I can’t get it to work. I hope I can, I got all the keyframes swapped out I just need the game to recognize it. ok, so somehow I deleted the fla collision when I deleted the pink guy, and now i just go back and copy it into place. Hmm… do you think that caused the 1065 error as well? ugh, so close yet so far away!

          • Tomas says:

            NICE! I GOT IT WORKING FINALLY! I must have deleted it that white box from the collision. ahh, he’s too small! but it looks good! awesome, now to tear apart those levels and build up a new game! Thanks for all your support. You went above and beyond what was expected for a piece of code. I felt like I got to talk to the writer of a book! Thanks for your support, well worth the 60 dollars. Watch out for the sword of the black double eagles.

          • Paul Firth says:

            Excellent, glad to hear that and happy to help! :)

  15. Tomas says:

    hey Paul, I’ve been playing with the files and have come across some new questions :) first off, how would I add sound effects to your game? second off, what’s the easiest way to redo the levels and place the enemies and goal? I finally got stencyl to work but it doesn’t seem necessary, or is it? For example how would I move that platform above the player on the first level and the skeleton resting on it. is there an easy way to do that?

    • Paul Firth says:

      Hi Thomas,

      You add sound effects to this game the same way you would do any other flash game :) Look into the flsah.media.Sound class – but you’ll need to do some research on how to use it.

      The enemies and map are edited and placed using the editor called Mappy. Please see the description in my original article:

      http://www.wildbunny.co.uk/blog/2011/12/11/how-to-make-a-2d-platform-game-part-1/

      Cheers, Paul.

      • Tomas says:

        ohh it was mappy, not stencyl. thank you for redirecting me. I knew I needed more stuff to get this working. Damn, you make it look so easy hahaha.

      • Tomas says:

        where does the as3proj access the fmp?

        • Paul Firth says:

          It doesn’t.

          The maps in mappy have to exported as an array of integers, as per the article and compiled into the code directly.

          Cheers, Paul.

          • Tomas says:

            that’s what I thought just wanted to make sure I was reading that right. sigh.

          • Tomas says:

            ok so export .mar? and then where do i put that info in? oh man this just went right over my head again, I was able to tweak startmap.fmp but now I’m kinda stuck adding that tweak to the game.

          • Paul Firth says:

            Should be an option called something like ‘export to actionscript’ on one of the menus. Then you can open that file and copy/paste the map into the code in the correct location.

          • Tomas says:

            what’s the correct location to copy the code once I get it? Also I don’t see export to .as with mappy. mind enlightening me on the most streamlined process for this step?

          • Tomas says:

            4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4,
            4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
            ,
            4, 45, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4
            ,
            4, 42, 42, 2, 2, 2, 2, 2, 0, 42, 42, 42, 42, 42, 42, 42,
            42, 42, 42, 42, 42, 42, 42, 0, 0, 0, 0, 0, 0, 0, 0, 4
            ,
            4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4
            ,
            4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4
            ,
            4, 13, 0, 0, 0, 0, 0, 1, 2, 2, 2, 3, 1, 2, 14, 14,
            2, 2, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 4
            ,
            4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
            4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4

            is that it? and then I just paste that into the level?

          • Tomas says:

            nevermind i figured it out, i can export as csv with the commas then export that into each slot for the 3 layers you have. ok, that works whew that’s awesome mappy does all that work.

          • Tomas says:

            ok 2 more questions for you since you’ve been so helpful so far. how do you control which level the goals at the end of the level go to? I can lay them down in mappy and control the placement of the caves but not which level they go to. also, how do I control his speed? that should get me moving in the right direction.

          • Paul Firth says:

            In Platformer.as there is a list of levels m_levels. The order of this list dictates the sequence in game.

            Code/Characters/Player.as has a kWalkSpeed parameter and there is also Constants.kMaxSpeed.

        • Tomas says:

          m_currentLevel = -1;
          m_levels = new ReferenceArray( Map );
          m_levels.Add( new StartMap( this ) );
          m_levels.Add( new Map1( this ) );
          m_levels.Add( new Map2( this ) );
          m_levels.Add( new LastMap( this ) );

          is that the list and then I can just throw in
          m_levels.Add( new Map3( this ) );
          m_levels.Add( new Map4( this ) );
          m_levels.Add( new Map5( this ) );

          • Tomas says:

            hmmm… nope i get a null error. just copied maps, map/1/2 into 3/4/5 and kept the last map. that way I could just copy those 3 and keep adding them into place. you have 5 levels so that make 8. add 3 more 11 etc etc never touching the last level. right now they are just copies but I can go back and tweak them all once i have the order lined up properly. in the game and the levels progressing in a linear fashion.

      • Tomas says:

        the error is:
        a super statement can only be used inside class instance constructors.

  16. Tomas says:

    any idea how to do that? I just want to copy level 2 and then make the end of level 2 go to that copy then the end of that level go to 3.

    • Paul Firth says:

      I get the feeling you’re not familiar with programming in AS3 using OO? I suggest running through a couple of basic tutorials on the subject before going any further. The error you have is probably because the class names haven’t been renamed in your copies of the level.

      • Tomas says:

        oh ya I’ve never used as3 before this. hahaha i’m just learning as I go. I’ll browse the copies I made for the class names. This documentation should help someone if they encounter the same questions.

        • Tomas says:

          public class Map4 extends Map I already setup the class names in the map4.as hmmm is there somewhere else I need to declare this statement?

          • Tomas says:

            well here’s what I have but I really would like to add more levels even if it’s just a copy of level 2 over and over between 2 and 3. I’m still stuck on that issue. Not bad for just over a week worth of work and no prior experience with as3. I’ve been following a as3 platformer tutorial online at this site:
            http://as3gametuts.com/2011/11/11/platformer-1/

            but ya here’s what I have so far, I really want to add a key/more levels/change up the levels a lot more and then add some type of collection system for those coins. maybe start him out in his undies with a stick or a bat and then give him the armor as he progresses.
            https://sites.google.com/site/swordofthedoubleblackeagles/Platformer.swf

        • Tomas says:

          ok ok i’m getting ahead of myself. you said “Just by re-doing the gfx, and adding more levels”. so how do i add more levels :? :*(

          • Paul Firth says:

            You need to understand the language before you can do any of that. Please spend some time learning AS3; tutelage is outside the scope of this blog :)

          • Tomas says:

            but i redid the graphics. pshhh i guess it’s just gonna be stuck with like 4 levels. I don’t understand what I’m missing. I setup the name on the maps. it was just copy paste. it’s all the same logic. I can move around the levels but when i add them i get that error. oh well. thus is life. you should do a more complete one I’d pay again and more for something that’s a little more friendly for graphic artists.

      • Tomas says:

        do one like super ghouls and ghosts I’d pay like 500 for that engine if I could just copy and paste stuff in there.

        • Tomas says:

          do you know any tutorials that would go over that? or where I should start? You kind of did imply it was easy to add levels to your game.

      • Tomas says:

        hey paul check out the link i added 12 levels and changed up a lot of the graphics, still using your cheese though(trying to think of what else would work, maybe rocks?). anyway I kind of am wondering if I could ask you a question regarding the scoring. every tutorial i’ve seen says add dynamic text to the stage, but your game doesn’t have a stage. should I add the text as an asset and then pull that variable in the document class(platformer.swf)? I’m just kinda wondering what your perspective is since you’re the pro.

        • Paul Firth says:

          Every flash movie has a stage, it’s the root of all the visuals.

          Scoring wise, I would look in Code/Gui/Hud.as as that is where everything else is currently done.

          Cheers, Paul.

          • Tomas says:

            ok, that’s what I thought I was playin about with the hud earlier with the lives. see I’m not that far behind I’m just trying to adapt from flash mx to this new as3 protocol XD

  17. Tomas says:

    ohhh it was all easy hahaha. I was missing the update not only on public class but the public function too. see it’s all the same logic psshhh language spanguage it’s all the same in the end.

  18. adytt says:

    Hello, I would like to buy the 49.99 $ version and reskin it for one of my projects.
    I use Adobe Flash CS 6 Pro and I’m used to work with it.
    Please tell me can I edit this game in Adobe Flash and compile it – or do I need other software beside it.

  19. Corey Bunnell says:

    Hey Paul,

    I recently bought the 9.99 version of this source code, and I just want to let you know that this code has really taught me a ton about game programming in general, and that it was worth every penny.

    The collision code is a bit over my head however, and I have been trying to implement moving platforms into this system and I just can’t seem to get it right.

    Right now, I have added a second “DoActionsToPlatformsWithinAABB” kind of function to the collision check for MoveableObjects, and I basically just abstracted out the code you wrote for tiles, but my platforms only collide at their vertex it seems, and even at the vertex the character bounces and up and down and wont stay on top.

    I realize this system was never meant for moving platforms, but I would be really happy if you could point me in the right direction. I am really stumped by this problem.

    Let me know if there is more information I can give you to help you answer easier.

    Thanks!

    Corey

    • Paul Firth says:

      Hi Corey,

      It sounds like you just have a bug in your code. For instance, what happens if you freeze your moving platforms – do you still have the same issue which didn’t exist in my original code?

      Cheers, Paul.

      • Corey Bunnell says:

        You were right, there was a bug.

        The half extents of my platforms were not properly being defined so there hit boxes were the size of one point (their center points).

        Thanks!

  20. Paul Firth says:

    Re – Adam Ryan:

    Adam, your email mailbox is full – “The error that the other server returned was:
    550 Mailbox quota exceeded” is what gmail tells me.

    I expect you want to look into that asap :) Here is the mail I was trying to send you:

    Hi Adam,

    The $20 and $50 have exactly the same features and number of levels (3).
    Support wise, you can add as many levels as you like, although you will
    need to get your hands dirty with the code in order to add new levels, as
    each level is represented by an inline array of integers (as described in
    the first article). So you’ll need to design them in mappy and then ‘export
    to actionscript’, copy and paste.

    Cheers, Paul.

  21. Arun Karthi says:

    Hi Paul,
    Your flash works are extremely good.I am new to Flash gaming,kindly help me with ,video tutorials or source file ,so as i could learn by myself, to be expertised in flash gaming.Reply to my e-mail id .Thanks in advance.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

WP-SpamFree by Pole Position Marketing