Skip to main content

News

Topic: Super Metroid 2d physics/gravity (Read 4405 times) previous topic - next topic

Super Metroid 2d physics/gravity
Hey guys,

Firstly, I am so glad we have the forums back (Although unfortunately this site is blocked on my work PC... spheredev.org wasn't :( ) !

Now I move onto my question.

I decided I wanted to learn how 2d sidescrollers work. Specifically Super Metroid for the SNES.

Now I tried figuring it for myself and movement just seemed odd? So I spent a few hours researching on the net although I found some help it was hard to find anything fit-for-purpose.

Again I got close but odd movement, and it didn't seem adaptable at all.

I really wanna keep the floaty-ness of super Metroid, but also for collision I need a way to be more precise with collision (In Metroid your current sprite frames height is taken into consideration, im guessing at least when you consider the morphball)

Can anyone get me started?

Re: Super Metroid 2d physics/gravity
Reply #1
To make it more 'floaty', you can reduce the gravity constant.

Ignoring obstructions:

Code: (javascript) [Select]

delta_time =  GetTime() - last_time;
unit.ytraj-=(gravity_constant*delta_time)
last_time = GetTime();


And then when you update the position of the units

Code: (javascript) [Select]

unit.y-=unit.ytraj;


That's how I did it in Organ Grinder (which had poor obstructions, but I felt decent gravity mechanics).

As far as height, I don't know about Super Metroid but Metroid and Metroid II had you two tiles tall by one tile wide, and in morphball form you were just one by one, I think?
  • Last Edit: March 31, 2013, 10:24:06 pm by Flying Jester

Re: Super Metroid 2d physics/gravity
Reply #2
Yeah that's right

I got this so far :
Code: (javascript) [Select]

const gravity = 1000;
const dt = 1 / 60;
function gravityEngine()
{
  for (var i = 0; i < entities.length;  i++)
  {
    // we still need to check collision
    entities[i].vSpeed = entities[i].vSpeed + (gravity - entities[i].drag) * dt;
    if (drag < gravity) entities[i].drag *= 2;
    entities[i].y = entities[i].y + entities[i].vSpeed * dt;
  }
}


Somethings not right though. I been watching a sprite bouncing up and down trying to get it right for hours now lol

Re: Super Metroid 2d physics/gravity
Reply #3
One thing I did to make jumps seem better was to space out the increase (or it looks like decrease for how you're doing it) to the vertical trajectory over about a quarter second. That might make it feel better. I mainly did it because it didn't look right to me with an instantaneous boost.

To make it more like Metroid, you might want to make the terminal velocity lower, but the gravity constant higher? Or to make the total height gained between touching the ground limited? I know that fudges the physics a bit, but if that makes it feel more like what you want it to, there's absolutely nothing stopping it from working that way.

Simulating drag, too? I never bothered with that, but power to you if it works.

Re: Super Metroid 2d physics/gravity
Reply #4
I sorta got it now.

For now I am not using drag, my internet search told me that was the best way to decide a max speed but upon further thinking maybe just capping the speed would be easier?

Using my current method I am finding it pretty hard to define how high you can jump, but ill get it soon. Having the a factor for speed that's affected by another factor of gravity means its not a simple as jump(number_pixels)

thought id through in a pic (I have mapped this area but had some layers invisible)


Re: Super Metroid 2d physics/gravity
Reply #5
Eeeeek, how cool!!!! This screen makes me want to play metroid!

Re: Super Metroid 2d physics/gravity
Reply #6
I just had to, in order to get all the gear so I could reverse engineer it. Fab game, but short :)

I thought id work on the animation mechanics now but man theres so many animations and causes for them! wow...
  • Last Edit: April 03, 2013, 11:10:48 am by Harry Bo21