A Flash Developer Resource Site

Results 1 to 20 of 20

Thread: [CS3] What's in your classpath

  1. #1
    formerly hooligan2001 :) .hooligan's Avatar
    Join Date
    Mar 2008
    Posts
    405

    [CS3] What's in your classpath

    Hey all,

    Recently got stuck back into flash after a long 1 and a half years working on another project in another language. So just started mucking around with flash again. Was mucking around with this terrain generator from a game idea I have,

    flash terrain generator

    I started thinking I haven't got many classes that I would use from project to project. Only 3 classes really,

    fps - displays the average fps of the movie
    debugger - a nicer way to output and debug my movies - also outputs arrays like print_r method in PHP
    keystroke - Only just added this one thanks to the post from lesli_felix

    So was wondering, what are the classes you always use in your projects?

  2. #2
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,926
    For as2 I've got

    gamingyourway.common
    - ColourHandler
    - EventBroadcaster
    - FontPlotter
    - Rumble ( Now that one doesn't get used every game )
    - SoundHandler
    - XMLmakeObj ( Converts xml files to objects )

    gamingyourway.debug
    - Profiler ( Alternative trace / code profiler )

    as3 is a lot more barren:

    com.gamingyourway.fps
    - Debug_fps

    com.gamingyourway.Math
    - MathX ( Quicker alternatives plus other bits and bobs )

    com.gamingyourway.Utils
    - Key
    - Web ( getURL replacement )

    com.gamingyourway
    - FontPlotter

    And that's it for the general use stuff. Things like scroll engines and polygon classes are also in my common package but I'm not using them every game.

    Squize.

  3. #3
    Senior Member PRadvan's Avatar
    Join Date
    Dec 2004
    Location
    NYC
    Posts
    261
    That terrain generator is really cool

  4. #4
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,378
    Mine are all pretty self explanetory:

    as2.com.hsg:
    BoatControls
    Databases
    FpSCounter
    MazeBuilder
    MenuSystems
    Preloaders
    TerrainEngine (generator I wrote from scratch)
    WindowSystems
    WoodGrain
    XMLtoObject
    The 'Boose':
    ASUS Sabertooth P67 TUF
    Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
    8GB G.Skill Ripjaws 1600 DDR3
    ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
    New addition: OCZ Vertex 240GB SATA III SSD
    WEI Score: 7.6

  5. #5
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    some not to specific ones:

    KeyBind
    bind functions to keys

    MathOptimized
    very quick math functions

    Poly
    polygon data

    UV
    UV map transformations

    ImageLoader
    load multiple images as bitmapDatas

    BitmapFrames
    sprite sheets as animations or rotate able frames, split, join and arrange frames (animation or billboard/sprite wise)

    I use KeyBind for testing alot it allows me to bind functions with parameters with 1 line of code to any key bei either integer ID or string label. The one thing that sucks in AS3 is to bind code to buttons so this is my personal answer to that issue.
    Most of my code however gets rewritten over and over because I think I can improve it each time and by that better learn AS3.
    Last edited by renderhjs; 09-25-2008 at 03:43 PM.

  6. #6
    FK founder & general loiterer Flashkit's Avatar
    Join Date
    Feb 2000
    Location
    Sydney
    Posts
    1,149
    hey squize whats in MathX......
    Regards Mark Fennell - Flash Kit Founder, general loiterer
    -------------------------------
    I Hate Zombies - iPhone Game | markfennell.com

  7. #7
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,926
    I'm too lazy to open Flex right now ( I'm as2 boy atm ), but this is in there:

    http://blog.gamingyourway.com/PermaL...2742edbb1.aspx

    I think there were "faster" sqrt's in there that I need to remove ( After running these tests:
    http://blog.gamingyourway.com/PermaL...631745ba5.aspx
    ), if there's anything else worth sharing I'll post it back here.

    Squize.

  8. #8
    formerly hooligan2001 :) .hooligan's Avatar
    Join Date
    Mar 2008
    Posts
    405
    Squzie: With your Debug_fps class, do you include the mem-usage data that I see with most fps counters these days?

    PRadvan: Thanks, the version up is an older version. I'll hopefully be able to show the new textured version sometime soon.

    ImprisonedPride: Do you have any examples of your TerrainEngine class at work? Would be interesting to see the output.

    renderhjs: I figured you would have a Poly and UV class. The KeyBind class sounds like a smart one.

    With you Math class are you optimising existing flash Math functions or ones that are not covered by the Math class?

    I know how you feel about improving constantly, that's how I am with everything too. Always thinking something can be made better.

    Do any of you guys include any of the physics API's such as Box2D from project to project?

    Thanks for the tips guys, now I know what my default package is missing.

  9. #9
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,926
    I have Box2D ( Which annoyingly seems to change a great deal between even minor versions ) and Papervision in my classpath, but obviously don't use them every game.

    My Debug_fps is just that, my old as2 fps counter converted to as3. I really have no interest in memory usage and to be honest I just find all the fps counters with a little memory graph scrolling beneath them as over the top. Just 'cause you can read the memory doesn't mean to say you have to ( imho ).

    Yeah render, going to share some of your Maths routines ? They're always nice to see.

    Squize.

  10. #10
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    With you Math class are you optimising existing flash Math functions or ones that are not covered by the Math class?
    I am developing a 3d engine atm. and I was searching on the net how to speed up flash AS3 code (because speed is all I care in AS3)- I got tons of sites with alternative ways calculating most trigonometry and basic stuff like Math.max/min/abs,sqrt... but like 10,20,100 times faster. Alot is done using bit operations and other smart stuff. - so I added those smart tips in similar methods like the math class has.
    For example I also cached some values like Math.PI but with less digits so that it runs faster in certain calculations in cost of beeing less accurate - I have very good expierences with that in the past.
    I haven't used it as much as I thought i would so far however for my current engine.

    about the keyBind it basicly is used like this:
    PHP Code:
    var keys:KeyBind = new KeyBind(stage);
    keys.add("h",trace,"you pressed the H key :)");
    keys.add(32,trace,"now you pressed the spacebar key"); 
    (damn I am tempted to use obj tags instead of php ones in order to see the code in the new greasemonkey scripts by WeIsGood)

    I know how you feel about improving constantly, that's how I am with everything too. Always thinking something can be made better.
    personally I think my code gets faster and so much more improved each time I restart writing the code over and over - as my brain tries to find a smart shortcut each time finding a more effecient way.
    Its the path I've taken so far and its what brought me so far - the way I see it. Cancerinform wrote about it once as well saying he would basicly also rewrite most of the code just to learn things better and improve it each time - and he certainly knows his AS.


    about the math class:
    PHP Code:
    package {
        
    /**
        * renderhjs.net
        speeds up varius math operations mainly for the 3d engine loop
        */
        
    public class MathOptimized {
            
            public var 
    pi_180:Number;
            
            public function 
    MathOptimized():void {
                
    pi_180 0.0175;//quicker?, Math.PI/180;//Math.PI/180
            
    }
            public function 
    modulo(a:Numberb:Number):Number {
                
    //x = a%b;    ~ 600% faster
                
    return & (1);
            }
            public function 
    flip(a:Number):Number {
                
    //a = -a;    300% faster
                
    return (^ -1) + 1;
            }
            public function 
    abs(a:Number):Number {
                
    //Math.abs(a);    2600% faster
                
    return (^ (>> 31)) - (>> 31);
            }
            
            public function 
    ceil(a:Number):int {
                
    //a = Math.ceil(a);    1000% faster
                
    return int(a)+1;
            }
            public function 
    floor(a:Number):int {
                
    //a = Math.floor(a);    1000% faster
                
    return int(a);
            }
        }

    the x % faster is what I got from the optimization sites,- I have not tested them all yet myself. Also a few things have yet to be added - but I haven't got the time yet to do so.
    Also regarding speed even though this is off topic here- smart placed local variables can boost alot of performance as you can reduce in some cases alot of lookups of arrays, objects and alike data types.
    Last edited by renderhjs; 09-25-2008 at 08:59 PM.

  11. #11
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    update:
    wooot I used the modulo operation from my math class an its boosted suprisingly +5 fps in my engine - will try to use them all in my render loop and see what it does in the end

    update2:
    I think it messes around makes my engine leave out faces. Hmm gonna have to research that. Might be that the modulo function is kind of buggy

    update3:
    so here was my source:
    http://lab.polygonal.de/2007/05/10/b...-integer-math/
    If the divisor is a power of 2, the modulo (%) operation can be done with:
    modulus = numerator & (divisor - 1);
    This is about 600% faster.
    he he now that makes sence, guee I'll have to modify that function a little bit
    Last edited by renderhjs; 09-25-2008 at 09:11 PM.

  12. #12
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,926
    Nice posts mate.

    I'll have to dig out some of my Maths speed-ups that I don't have in the class ( The method look-up normally wipes out the speed up advantage, so you're left with a method which isn't as accurate and about the same speed as the built in one ).

    Squize.

  13. #13
    Heli Attack! iopred's Avatar
    Join Date
    Jun 2003
    Location
    Sydney, Australia
    Posts
    923
    Render, your ceil function is incorrect, if the number is already an integer it will add 1 to it.
    Christopher Rhodes
    squarecircleco.

  14. #14
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    ah thx for letting me know,- like I said before its a fairly new class and I haven't used it alot yet.

  15. #15
    Senior Member hatu's Avatar
    Join Date
    Jan 2007
    Posts
    480
    I have just one at the moment, all others I usually tend to modify a bit for each project.
    The one I have is BitmapRead, it reads a bitmap into an array
    http://hatu.biz
    Portfolio & games

  16. #16
    The Cheeze to Your Macaroni ColbyCheeze's Avatar
    Join Date
    Dec 2007
    Location
    Texas
    Posts
    244
    Ive got a bunch....
    there is my math library
    my Input managers
    My screen switching system / core
    my rendering system
    I have a few Util classes such as XML loaders etc
    I've got a powerful custom particle system I built
    an AI library with FSM capability and boid behaviors
    ummmm..... I think thats it?

    You can get some of my code from my websites google code page that I've made public to anyone else to use for thier projects for free.

    http://code.google.com/p/cheezeworld/

  17. #17
    Senior Member
    Join Date
    Mar 2008
    Posts
    301
    I talk a lot about reusing code, but if I'm completely honest, I don't reuse that much. Like render I always end up reprogramming everything in order to learn how to do things better. Wastes a lot of time, but meh.

  18. #18
    Senior Member Sietjp's Avatar
    Join Date
    Jan 2005
    Location
    Paris, France
    Posts
    711
    @render : int(a) is not floor when a<0 (I think) thus ceil and floor will e wrong for negative numbers. Nice class by the way.



    Nothing in the classpath for me, I always copy the classes in my project. Because my nightmare is to compile a 5 years old game and it doesn't work because the classes in the libraries have changed.

    The libraries I used so far :
    - data stuctures for games by polygonal labs
    - png/gif/jpg libraries (by adobe I think)
    - TweenLite
    - base64/hash/md5/crypto by hurlant.com
    - Box2D

  19. #19
    ....he's amazing!!! lesli_felix's Avatar
    Join Date
    Nov 2000
    Location
    London UK
    Posts
    1,506
    I don't have any either, for similar reasons.

    I re-use stuff all the time, but the benefits of fixing a bug in a package are way smaller than the risks of breaking a project by amending a package, or having a third party update it themselves.

    Also, most of my commercial work includes giving up the source files, so again, I never exercise any cross-project dependency.
    Last edited by lesli_felix; 09-26-2008 at 01:04 PM.

  20. #20
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,378
    .hooligan: Yeah but not online... if I get some time in the near future I might post an example. It runs a vertical or horizontal "cave" (with one or both walls), comparing each "slope" as a vector for collisions. Sadly that part is a little buggy and I never got around to fixing it. Also I should have technically called it a scrolling terrain engine...
    The 'Boose':
    ASUS Sabertooth P67 TUF
    Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
    8GB G.Skill Ripjaws 1600 DDR3
    ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
    New addition: OCZ Vertex 240GB SATA III SSD
    WEI Score: 7.6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center