Mario Physics Tutorial

Member
Posts: 196
Joined: 2002.04
Post: #1
Where can I find a tutorial on creating physics for a 2-D mario type game.

Thanks
Jonathan
Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #2
What kind of physics would Mario need? Surely it wouldn't be very complex.
Quote this message in a reply
Member
Posts: 277
Joined: 2004.10
Post: #3
All you need is stuff like Gravity, Wind and Movement.

xSpeed = xSpeed + xGravity + xWind + xMove;
ySpeed = ySpeed + yGravity + yWind + yMove;

But if you add stuff like ropes swings etc. etc. etc. your going to need to learn the
physics of those items.

Hope that helps. Smile

Global warming is caused by hobos and mooses
Quote this message in a reply
Member
Posts: 277
Joined: 2004.10
Post: #4
Mario (NES) itself probebly had less physics than that. (what I just posted)

Global warming is caused by hobos and mooses
Quote this message in a reply
Member
Posts: 338
Joined: 2004.07
Post: #5
What you would need is basic newtonian stuff for the character (position, velocity, acceleration) which any game physics tutorial online would teach you. Google it or snoop around Gamedev.net and I'm sure you'll find something.

After that you'll need collision detection/response for the platforms. What exactly you'll need depends on your game and the nature of the platforms. Are they all level like the old NES games (Mario, Metroid, Kid Icarus), or can they be sloped? If the former, you're colliding with rectangles. If the latter, you're colliding with arbitrary polygons. Can the player jump through the bottom of some platforms? If so, then you have to account for that too.

You should also account for special platforms that have certain properties while the player stands on them, such as a moving platform, a conveyor belt, or an electric floor that damages the player.

After that it all depends on the details of your design.

Justin Ficarrotta
http://www.justinfic.com
"It is better to be The Man than to work for The Man." - Alexander Seropian
Quote this message in a reply
Member
Posts: 89
Joined: 2002.04
Post: #6
There are some really good tutorials / source code at gotoAndPlay, look under the Articles tab.

Here is one that will help you get started: http://www.gotoandplay.it/_articles/2003...nd_run.php

One note though is that all these tutorials are for Flash games using Action Scripting. Regardless it should be easy to extract the needed math. One item that may be difficult to extrapolate though may be collision detection...
Quote this message in a reply
Moderator
Posts: 916
Joined: 2002.10
Post: #7
I don't think you so much need acceleration as much as velocity... I mean, if you played any of the NES marios, there was no acceleration, even when you were running with the flying hat, you just had velocity 1, velocity 2, and then LIFT OFF!
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #8
skyhawk Wrote:... I mean, if you played any of the NES marios, there was no acceleration, ...

I beg your pardon? Sounds like you need to go back and play them again. There's very noticeable acceleration in every Mario game I've ever played, with the possible exception of the Super Mario Land series on the Gameboy. Mario has always taken a bit to get up to full speed, even when walking...

- Alex Diener
Quote this message in a reply
Member
Posts: 184
Joined: 2004.07
Post: #9
I think this is my favorite pet peeve about games that are just rip-offs of the 2D Super Mario series, which is they almost always **** up the physics, ruining what worked so elegantly in the original game. A lot of programmers see old retro games and say, 'God, that's so primitive, I could easily program that,' and then miss all the subtleties of the original game. These retro games, despite modern graphics and sound, have gameplay honed to a fine point.
Quote this message in a reply
Member
Posts: 196
Joined: 2002.04
Post: #10
Thanks for the help. I like the tutorials at gotoAndPlay. I was also looking for the collisions with the platforms and blocks. I'm not good with vectors so I was wondering if there was a tutorial on it.
Quote this message in a reply
Member
Posts: 89
Joined: 2002.04
Post: #11
This is your lucky day! LOL

Check out the following tutorial link posted by Alex "ThemsAllTook": http://www.idevgames.com/forum/showthrea...r+tutorial
Quote this message in a reply
⌘-R in Chief
Posts: 1,261
Joined: 2002.05
Post: #12
phydeaux Wrote:These retro games, despite modern graphics and sound, have gameplay honed to a fine point.

I absolutely agree. Many of the old school games are far more fun to play than modern games.
Quote this message in a reply
Member
Posts: 196
Joined: 2002.04
Post: #13
Thanks flipflop. I'm confused though. I finally found a tutorial on gamasutra that makes some sense.
http://www.gamasutra.com/features/19991018/Gomez_4.htm
But I need someone to interpret the Box-Sphere collision code below.
Code:
#include "aabb.h"

//Check to see if the sphere overlaps the AABB
const bool AABBOverlapsSphere ( const AABB& B, const SCALAR r, VECTOR& C )
{

    float s, d = 0;

    //find the square of the distance
    //from the sphere to the box
    for( long i=0 ; i<3 ; i++ )
    {

        if( C[i] < B.min(i) )
        {

            s = C[i] - B.min(i);
            d += s*s;

        }

        else if( C[i] > B.max(i) )
        {

            s = C[i] - B.max(i);
            d += s*s;

        }

    }
    return d <= r*r;

}

What's b.min and b.max? Can someone write this out in simple code?
Quote this message in a reply
Member
Posts: 196
Joined: 2002.04
Post: #14
Ok I figured out what min and max is. Now I feel stupid Blush.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  A mixture of Mario & MegaMan Zero Tek SeriouSamus05 1 2,992 Dec 8, 2011 04:40 PM
Last Post: SeriouSamus05