don't click here

Flash Sonic Engine

Discussion in 'Fangaming Discussion' started by x2i, Apr 26, 2012.

  1. x2i

    x2i

    Member
    11
    0
    0
    Hello all, it's my first post here so I thought I'd introduce myself a little before going into this.

    My name is Dan, also known as x2i - I've grown up with Sonic and albeit being 23 years of age... I literally am obsessed with Sonic.

    In case anyone is interested - about 4-5 years ago I released a small Flash Game by the name of Sonic Smash Brothers (http://www.newgrounds.com/portal/view/427733) - it's basically a copy of Super Smash Brothers but with Sonic only characters in - to this day I still get e-mails saying how buggy it is and whether I'm ever going to finish it fully - however I gave up Flash a while ago in favour of web development and I've only just started getting back into it.

    The reason that game even spawned was because for a while now I have been absolutely fascinated by the physics in classic Sonic games... how can something that precise have come from the 1990's when they still struggle to get it 100% to this day?
    When I realised I didn't have the correct knowledge or skills to replicate it even slightly, I decided to make a fighting game which wouldn't need the complex physics too much.

    However I find myself at this point in my life, what with Sonic 4 and Generations all boasting Classic Sonic type physics, it's about time I dusted my Flash skills off and tried again - researching seems to be fruitless in most cases so trial and error has been my only source - I do have some work I could show off but it's far from close.

    Anyway my two questions on this are:

    1) How hard do you think it would be to get these kind of physics running in Flash - and I'm talking AS2 not cruddy AS3?

    AND/OR

    2) Would anyone be interested in collaborating on some physics test engines if anyone has any programming skills?


    I realise I sound like another fanboy coming out to say 'LOL I WNT 2 MAEK A SAWNIK ENGIN AND MAEK A GAYM CALLD SONIC FLASH ADVANCED FOREVER RUSH' but seriously... it's been bugging me for as long as I can remember. Even if I never do anything with such an engine (which is unlikely if I did) - just the sheer satisfaction to know that I figured out would be enough.

    Feel free to toss this aside if I've wrongly mis-posted it in the wrong area or whatever.

    Thanks
     
  2. Elektro-Omega

    Elektro-Omega

    Mushroom Hill'in Member
    400
    2
    0
    UK
    -
    Happy first post!

    I'm sure it's possible using the physics presented in the different Sonic asm files and using Mercury's physics guide and studying how the different variables translate.

    Forgive me if I am wrong but I think I seen another forum member do this before. It was very accurate but was done completely in Flash (not sure which AS though).

    Go for it though, it would be nice to see a complete, smooth Sonic engine in Flash.
     
  3. x2i

    x2i

    Member
    11
    0
    0
    Thankyou for the welcome.

    Yes I do believe it's called Ultimate Flash Sonic and as far as I can see, albeit the odd glitch, it plays true to Sonic Advance style physics.

    I'd like to know more about these ASM Files and Mercury's physics guide... any chance you could point me in the right direction?
     
  4. Elektro-Omega

    Elektro-Omega

    Mushroom Hill'in Member
    400
    2
    0
    UK
    -
    No problem. The ASM Files can be accessed through the Mercurial link at the top of the forum, that will take you to the dashboard where you can click Megadrive / Genesis and select either the whichever disassembly you like. (S1 = Sonic 1, S2 = Sonic 2, etc.). The .ASM files can be opened in Notepad or an IDE of your choice (I recommend Notepad++). This method *may require some ASM / Programming knowledge for you to be able to understand what each routine does and how it effects the different aspects.

    Regarding the Mercury Physics Guide, I can't seem to find it via a quick search but I'm sure if you drop him a quick PM he won't mind giving you the link.

    *I used the term may because sometimes the labels can provide you with exactly the information you need.
     
  5. x2i

    x2i

    Member
    11
    0
    0
    Awesome, thankyou very much, I shall see how it goes with those.

    In the meantime if anyone is interested in collaborating - feel free to let me know :)
     
  6. Mercury

    Mercury

    His Name Is Sonic Tech Member
    1,740
    21
    18
    Location Location
    AeStHete
  7. Mr Lange

    Mr Lange

    A wise guy eh. I know how to DEAL with wise guys. Member
    1,286
    11
    18
    The Land of Waldos
    Sonic Utopia, Sonic Overture
    There already exists a Sonic flash game with somewhat decent physics, and its years old.
    http://www.newgrounds.com/portal/view/151706

    What appeals to me about the idea of a Flash based Sonic engine is that curves could be extremely complex and precise if it can utilize vector graphics instead of just bitmap based collision.
     
  8. Aerosol

    Aerosol

    Not here. Moderator
    11,200
    601
    93
    Not where I want to be.
    Sonic (?): Coming summer of 2055...?
    They were just talking about that, Mr. Lange.
     
  9. Mr Lange

    Mr Lange

    A wise guy eh. I know how to DEAL with wise guys. Member
    1,286
    11
    18
    The Land of Waldos
    Sonic Utopia, Sonic Overture
    I don't see any mention of that game anywhere in the thread.
     
  10. Aerosol

    Aerosol

    Not here. Moderator
    11,200
    601
    93
    Not where I want to be.
    Sonic (?): Coming summer of 2055...?
     
  11. x2i

    x2i

    Member
    11
    0
    0
    Right okay, I am following some of the guidance from the Mercury Physics guide and so far I have the basic running, jumping, rolling and skidding pretty much working okay... albeit a few glitches. I have been using the variables in the guide for acceleration, gravity etc.

    At the moment, an anomoly exists when decelerating where the speed will get stuck on a number such as 0.015625 - causing Sonic's Run animation to remain even though he should be stationary - he appears to be moving ever so slightly - hardly even noticeable unless left for a long time. This tends to happen when changing direction because the variable is larger because it is designed to slow Sonic faster than normal as he is braking.

    Also when rolling, if you hold the direction you are rolling, you seem to roll at a constant speed forward, probably a mis-match somewhere which I'm sure I can find if I look hard enough.

    Rolling, jumping and running seem to work fine - I have got it so that Sonic's run speed is variable depending on his speed and when he exceeds a top speed he will start running with his round feet.

    The hardest part and possibly the part which always makes me give up is the slopes etc... in the guide it talks about using sensors which I don't think would work too well in a non-tile based engine. I have seen some scripts out there for making the character rotate to the curvature of the ground, perhaps that might help but in terms of gaining speed down hills, resistance uphill and almost certainly loop-de-loops etc I may be on my own unless anyone else has any knowledge or experience.

    However I shall persist and see what happens. If anyone would like to see what I have so far I'd be more than happy to upload an .swf file.
     
  12. Mr Lange

    Mr Lange

    A wise guy eh. I know how to DEAL with wise guys. Member
    1,286
    11
    18
    The Land of Waldos
    Sonic Utopia, Sonic Overture
    Wow that is amazing, you got all that working already? I can't wait to see it. If you release this engine I'd certainly have a lot of fun working with Flash's flexibility in designing levels for possibly a short Sonic game of some kind. Me and a friend once made a powerful parallax engine for Flash so there's a lot of neat things that could be done combining the two.

    @AerosolSP holy shit I must learn2ctrl+f
     
  13. x2i

    x2i

    Member
    11
    0
    0
    Yeah, I have added in a few other things just for test purposes - mainly just Springs and a Super Box just to test how the physics variables can change if one were to go into Super form for example. Also added the ability to duck - working on the Spindash.

    I just know though that slopes are going to be a pain because it's what always gets me stuck... but hopefully with a little advice I might be able to conquer it once and for all.
     
  14. x2i

    x2i

    Member
    11
    0
    0
    Well... just got back off my holiday, hence my window of inactivity. I just wanted to show you guys what progress I have made on the Flash Sonic Engine. It's far from finished and there are bugs. The ground isn't final as I am using art based hitTest's which is the reason why I struggle in the first place - I may have to look into something else. Anyway, if anyone likes what they see let me know, if anyone wants to help, let me know. I'm sure combined we could create a half decent attempt at a flash sonic engine.

    Here's the link to play - you may wish to resize your browser window to around 550x400 pixels if it lags at all: http://xboxresource.com/sonicengine.swf

    Here's a list of known bugs and improvements pending
    Jumping / Gravity
    ---------------------
    Although it doesn't seem to have too much effect on the game so far, Sonic's Y speed will never actually sit at 0 - instead bouncing from 0 to 0.21875 and back repeatedly.

    Sometimes when jumping (and rolling), Sonic's ball animation is stopped - partly due to me trying to create variable spin speeds based on Sonic's X Speed.

    When jumping up through platforms, Sonic will snap onto them rather than waiting til he is falling to land on them... something I just haven't added yet.



    Movement/Running
    ---------------------
    Sometimes when left to decelerate normally, usually after a direction change, Sonic's X speed will never precisely hit 0 - therefore he appears to be walking still even though he doesn't appear to be moving. He is moving but just ever so slightly so you can't really see it all that well.

    Cannot run up/down slopes properly, there is no resistance or acceleration. There is no tilt of Sonic based on the angle of the slope. Also no Loop-de-loops or anything fancy.

    No wall detection meaning IF Sonic were to walk into a wall, he would just appear at the very top. Something that will need changing for definate. Also cannot run up walls or upside down.



    Rolling / Spindash
    ---------------------
    When Rolling and holding down the direction in which you are rolling, you will continue to roll at a constant speed. I'm sure I've just missed something small out for this.

    Doesn't charge yet, Spindash will always result in constant thrust regardless of how long or how many times the button has been pressed.

    Once you let go of the spindash, Sonic's speed surpasses his maximum run speed - does this need to decelerate down to his top speed gradually or can he continue to run faster until he hits something or stops normally?
     
  15. Crasher

    Crasher

    Why hello there! Member
    515
    63
    28
  16. x2i

    x2i

    Member
    11
    0
    0
    I have incorporated some of the techniques used in that video, such as the two reference points below his feet to detect angles - thats working fairly well but not perfect. I can see what is meant by sensors now in the genesis games, it's kind of the same concept. Would this work well in a non-tile based version though?

    Is anyone else efficient enough at Flash and would wish to help. Some of the math is messing with my brain a little :S
     
  17. winterhell

    winterhell

    Member
    1,165
    7
    18
    I would recommend that you have a function that tells you the distance from a point to the closest solid point in a given direction. Or maybe 4 functions Get[Left/Right/Top/Bottom]Distance(int x, int y). That way if you want to see if there is something below Sonic(when in floor mode), you would do
    heightA=GetBottomDistance( playerX-9, playerY);
    heightB=GetBottomDistance( playerX+9, playerY);
    and then do if(heightA<16 || heightB<16) there is a floor.
    This is how I do it in my engine, and using such method you can abstract yourself from the collision data. It can be either tiles like the original, or the whole terrain can be a single bitmask. Or even polygonal/splines based.
    Unfortunately I may not be able to help much with Flash, as I haven't touched Action script 3 in years. Though I have made a Worms clone that had pixel-perfect collision with the terrain and even destructible terrain. Is this what you are looking for ?
     
  18. x2i

    x2i

    Member
    11
    0
    0
    To be fair, I want it to be as close to the original Sega Genesis/Mega Drive Sonic's as I can get. I am using AS2 as AS3 is beyond me, I never got on well with it.

    Problems I seem to be facing is stuff like sticking to the ground when running downhill, momentum physics - gaining and losing speed on slopes, and in the long run - the stuff such as running up walls, loop-de-loops etc.

    Right now though I am just trying to get the math right so that what I do have feels as genuine as it can but I am dreading going too far into the aforementioned knowing so little about it. I've tried for years to find a tutorial or someone willing to help - people who have accomplished it seem to wish to keep the secrets themselves. My plan is that IF I did create something of this calibur, I would be more than happy to release the source code or help others as I know myself how hard it is to find.
     
  19. Namagem

    Namagem

    Member
    388
    0
    16
    USA
    This is really cool, and solid start! I'm not a real expert on this, but it feels to me like deceleration happens a little bit too fast. Regardless, this looks amazing. Best of luck on continuing work on this!
     
  20. Elratauru

    Elratauru

    Little Shiny Emurralds Member
    Well, I did one of those kind of proof-of-concept engines a good while back, you can find an example of it on this same forum here.

    Also, you test it over here:
    http://alforata.deviantart.com/gallery/#/d31j8rl

    It was made a long time ago when I only knew AS2 so It's kinda basic, no slopes or camera, but physics are pretty much exact. I learned AS3 with the past of the years, so I guess I could make something a lot better right now, but my job kills my free time :v:

    Anyways, I hope you can use it or check it if really needed, I know the file has been deleted (the sonic.as) but I guess I can try to find it on my HDD when I come home.