dcsimg
A Flash Developer Resource Site

Results 1 to 14 of 14

Thread: Slow motion on marmotte's fighting engine (like in mr_malee's version)

  1. #1
    Junior Member
    Join Date
    Jul 2007
    Posts
    5

    Slow motion on marmotte's fighting engine (like in mr_malee's version)

    Hi,

    I've implemented some basic AI on marmotte's fighting engine. The AI makes decisions faster when the difficulty level is higher, so, at this point, I'm quite satisfied with my opponent's behavior, but I'm not very satisfied with the actual gameplay...

    I've already implemented a sort of "scrolling" on the background when the characters move... the same for the jumps, but I feel I need something more.

    I think the game really needs a slow motion effect when a character gets hit... But I have no idea of how to implement that since I only have a frame on the timeline and almost every move is done via actionscript... I've saw something like this in mr_malee's version of the fighting game but I have no idea of how that's actually done...

    Can I simulate somehow that slow motion? Any ideas?

    Thank you.
    Last edited by virruss; 04-04-2008 at 11:12 AM.

  2. #2
    Elvis...who tha f**k is Elvis? phreax's Avatar
    Join Date
    Feb 2001
    Posts
    1,836
    Actually Virus, malees example pauses completely while rendering the effect, and then play at a normal pace afterwards, so you just pause the hit animation until you reach the desired point of the hit blast and then continue playing. That said, malee's version looks so awesome!
    Streets Of Poker - Heads-Up Texas Hold'em Poker Game

  3. #3
    Junior Member
    Join Date
    Jul 2007
    Posts
    5
    Yes, but I think he also stops the characters from falling (and, of course, the background), and I wonder how he does this.

  4. #4
    crossconscious
    Join Date
    Sep 2005
    Location
    Belgium
    Posts
    1,188
    By simply not calling the update function or whatever when you need to 'pause' the game?

  5. #5
    DOT-INVADER marmotte's Avatar
    Join Date
    May 2002
    Location
    Dot-Switzerland
    Posts
    2,601
    Hey Virruss, would you like to share your game, maybe?

    Regarding the "Freeze" part, I know exactely what you mean, and I'm afraid that with such an old engine (and the way it was built back then), it's tricky to implement it; I don't remember exactely how it works, but I think that each animation sequence of the player calls a bunch of appropriate function, using a good old onClipEvent(EnterFrame)?. Well, an easy (but dirty/unoptimized/...etc) trick would be to add something like this:

    For the moment the code is looking like this, right? (sorry I don't have that engine anymore in my computer, it should be stored in an old back-up CD

    PHP Code:
    // Consider this is the "stand" animation sequence;
    // at this point the player can move backwards/forwards, crouch or attack, for example
    onClipEvent(EnterFrame){

    Wait_For_A_Directional_Key_To_Be_Pressed();
    Wait_For_An_Attack_Key_To_Be_Pressed();
    ...
    etc


    Now the crappy trick (I don't like to do it that way since it requires an additional statement in an EnterFrame loop), but this might work, if you get the idea:

    PHP Code:
    // Consider this is the "stand" animation sequence;
    // at this point the player can move backwards/forwards, crouch or attack, for example
    onClipEvent(EnterFrame){

    if(
    GameFrozen==true){

    Wait_For_A_Directional_Key_To_Be_Pressed();
    Wait_For_An_Attack_Key_To_Be_Pressed();
    ...
    etc

    }else{

    // This is how long the game needs to freeze
    // Each time a characters hits his opponent, you should add something like to both players:
    // GameFrozen = true
    // FreezeTimeCountdown = 10

    FreezeTimeCountdown--
    if(
    FreezeTimeCountdown==0){
    GameFrozen=false;

    }
    }

    If I was about to create a fighting game engine today, it would be at least 100 times better, honestly, because I would rewrite everything, but I don't think I can be of any *great* help with that very old engine

    Oh, btw, here's another version of the fighting game engine done in january 2006 (that's so old already!!). I don't think I ever posted that at FK (heck, I have probably hundreds of unfinished games around here!), so enjoy that scoop!!



    The game never ends and you cannot play it (the fighters are AI controlled), but it's fun to watch. Surprisingly, that engine offers many subtle things that probably nobody will notice (and this is even more true since you cannot play it), but you'll notice for example the "freeze" feature that totally depends on the strenght of the hit (a killer hit will freeze longer than a simple hit for example), the screen shaking depending on the same value ...etc.

    Anyway, look at it HERE

    (NOTE that there's no loading bar)
    Last edited by marmotte; 04-05-2008 at 02:32 AM.

  6. #6
    Trainee coder Viza's Avatar
    Join Date
    Sep 2006
    Location
    Melbourne, Down under
    Posts
    513
    Marmotte that fighting engine is f***ing nuts! Really inspiring stuff.. I can't wait to do some AI coding now.

    Viza.

  7. #7
    DOT-INVADER marmotte's Avatar
    Join Date
    May 2002
    Location
    Dot-Switzerland
    Posts
    2,601
    Thanks Viza
    That's funny because I didn't take a lot of time for the AI, just tried to have a very playable fighting game (combo moves such as hadokens / double-taps are very natural this time)

    hahaha, totally unoptimized but I love to watch this one > 2 VS 2 !!
    Last edited by marmotte; 04-05-2008 at 03:12 AM.

  8. #8
    Zombie Coder EvilKris's Avatar
    Join Date
    Jun 2006
    Location
    Fukuoka, Japan.
    Posts
    796
    Wow that's a hell of a fighting engine there, the dude here is mighty impressed!

  9. #9
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,140
    the effect could easily be achieved in AS3 using stage.frameRate = 1. or somewhere around.

    in my version, I simply stopped the enterFrame, since the frames were advanced using action script, there was no need to loop through whenever I needed to pause. So movie clips never actually played. Only nextFrame() was used.

    I think from memory I just used setInterval to return control. As for the death slow motion, same thing, except setInterval was used as the enterFrame.
    lather yourself up with soap - soap arcade

  10. #10
    Senior Member hatu's Avatar
    Join Date
    Jan 2007
    Posts
    480
    Quote Originally Posted by marmotte
    Thanks Viza
    That's funny because I didn't take a lot of time for the AI, just tried to have a very playable fighting game (combo moves such as hadokens / double-taps are very natural this time)

    hahaha, totally unoptimized but I love to watch this one > 2 VS 2 !!
    Damn that's cool. I like how good the AI is at dodging the attacks. It's not cheating is it?

  11. #11
    talk to the hand! Never_land:('s Avatar
    Join Date
    Nov 2007
    Location
    your mother's bedroom
    Posts
    490
    I agree with hatu

  12. #12
    Senior Member Alluvian's Avatar
    Join Date
    Jun 2006
    Posts
    967
    If you use a gametime variable to control your moviespeed you can do slow motion by just editing that.

    Modified slightly from a post by Azraelkans:
    PHP Code:
    var initTime:Number=getTimer();
    var 
    gameTime:Number;
    var 
    speedmod:Number=1;
    var 
    speed:Number=10 //speed in pixels per second.

    function tick(){
       var 
    currTime:Number=getTimer();
       
    gameTime=(currTime-initTime)*0.001*speedmod
       initTime
    =currTime;
    }

    onEnterFrame=function(){
     
    tick();
     
    myhorse._x+=speed*gameTime;

    This way the horse is moving at a fixed speed no matter what your frames per second. If your fps drop, the horse just moves further per frame.

    If you use this for all movements, you can modify the speed of your game by changing speedmod. Making it 0.5 will make the game play at half speed for instance.

    You can do extreme slowdown with something like 0.1 or even 0.05

    This can also be used with frame animations. For instance, below I have some code I am using in my current game where I have some prerendered smoke saved in an array of BitmapData objects.
    PHP Code:
    // inside my 'update smoke' function
    thissmoke.frame += 100 gametime;  //save the decimal value to the object
    frame Math.floor(thissmoke.frame);  // floor it for use as your array index to choose which bitmap to copypixels.
    bmp smokebmpdata[frame].bmp;
    rect smokebmpdata[frame].rect
    As the game slows down in terms of fps, gametime becomes larger and frames will be skipped so that the animation always plays at the same speed regardless of the current fps count. If you have hittests going off on just certain frames then you can't do this of course, because some critical frames could be skipped.

    If you make gametime really small by use of speedmod, the above would show the same frame multiple times until the thissmoke.frame gets to the next integer.

    The above will also make thissmoke.frame a non-integer (hence the floor function).

    I am really enjoying this method because the human brain is REALLY susceptable to changes in speeds. Slowdown in a game is painfully evident to a viewer. We do not notice the frame by frame movements well at all though, which is why movies get by with such awful framerates. It takes some pretty extreme changes in how far an object moves per frame for an observer to notice it.

    For it to work, you really have to use gametime for EVERYTHING that moves though. It also lets you visually pause by just setting speedmod to 0.
    Last edited by Alluvian; 04-14-2008 at 04:22 PM.

  13. #13
    Member
    Join Date
    Jul 2002
    Posts
    65
    actually I am making a fighting game based on this engine. I implemented a timer just for this functions and called it stuntime. I had the stuntime function decriment if its >0 and stop if it hits 0. I had another function that stops the current frame its in if the stuntime is over 0. This is usefull if you want your current frame to "hang" if it gets hit or is hitting somebody. basically {if(stuntime>0){this.character.stop() else{ play();
    hope that helps. Works great on mine

  14. #14
    Member
    Join Date
    Jul 2002
    Posts
    65
    Actually Im interested in how you aproach AI for this engine. Can I ask?

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