Game Mechanic Explorer – examples for game mechanics, algorithms, and effects
gamemechanicexplorer.com
gamemechanicexplorer.com
When I came up to variable jump height I tried a solution very similar to the one presented here, but I just could not get my jumps to feel at all "right". Jump height that's modulated by initial or continued velocity feels weird and floaty and a bit hard to precisely control.
I finally broke down and found a detailed analysis of the physics maths used on the original Super Mario Bros. I discovered to my surprise that variable height was achieved SMB1 by temporarily reducing gravity during the time the button was held down, capped by a time limit. Using this rule, jumps feel very solid precise and look more realistic than the image of a character with a continuously firing rocket under its feet.
So strong jumps, and weak jumps both always look like the first "push" happened at the very start.
As I said before, the velocity approach looks a bit more like the character has a jetpack, and is rocketing into the air. That is, the accelleration is slow. then fast, then slow again (as gravity takes over). Instead of just fast then slow.
re:perception, derivatives, and discontinuities. I think you are right. In bezier curves, discontinuities are numbered according to which derivative the discontinuity occurs in. So if you draw a straight line with a corner in it, in adobe illustrator, that's a c0 discontinuity. A curved line, where the control points for the curve after the vector are the same angle, but different lengths are a c1 discontinuity (but c0 continuous), and so on.
It's useful to number these, but c0 continuous "looks" smooth, always.
edit: sorry, I've misnumbered these. I should say that g1 continuous always looks smooth.
http://www.clemson.edu/ces/credo/AID/ACIS_HELP/HTM/DATA/ACIS...
Tuning these has let me reproduce pretty much any controllable jump arc - for example, the jump in Metroid has a lot of "float" to it at release time. This is doable by making acceleration at release equal to inverse of gravity.
To start a jump, the user presses the jump button while the character is standing. There is a "grace period" where you can still jump if the character isn't on the ground now, but was a few frames ago. This is important to be able to jump right as the character reaches the edge of a platform. Without this, you have to jump earlier than you feel you should.
Once a jump has started, we track how long the jump button has been held down. Every frame, the character's Y velocity is modified by the "jump acceleration". This acceleration starts at some high value, and ramps down linearly the longer the jump button is held down.
For example, the first frame of jumping may add -10 to velocity, then -8, -6, -4, -2, until finally zero. I found this acceleration ramp was the key to getting the jump to feel snappy yet responsive. The first frame gives the biggest velocity boost, so the character immediately leaps into the air. Then later frames give a diminishing effect so that you can more precisely dial in how much oomph you want the jump to have.
Gravity is then applied on top of this. In code, it looks like:
// Start jump.
if ((Actor.LastOnGround <= JumpAllowedFrames) && UserInput.JumpHeld) {
jumpFrames = 1;
}
// Accelerate upwards while holding jump button.
if (jumpFrames > 0) {
velocity.Y -= JumpSpeed * (MaxJumpFrames - jumpFrames) / MaxJumpFrames;
if (!UserInput.JumpHeld) {
// Stop accelerating if player releases button.
jumpFrames = 0;
} else if (jumpFrames >= MaxJumpFrames) {
// Can only accelerate for so long.
jumpFrames = 0;
} else {
// Keep jumping.
jumpFrames++;
}
}
// Apply gravity.
velocity.Y += Physics.Gravity;
I was really happy with how this turned out. Actually, now that I dig into this several-year-old code, it kind of makes me want to resurrect the project. :)https://en.wikipedia.org/wiki/Shigeru_Miyamoto
In an earlier talk, he explained that he designed his games starting with how you physically interact with the controls you're holding in your hand, and then inwards into the computer, instead of the other way around like so many other people tend to do.
In a later talk, about the Wii, he explained that now he designs his games starting with the facial expressions of the people playing them, then to the physical experience that could evoke such an expression, then on into the computer that could conduct such an experience.
As an example, he showed a picture of a grandfather with his granddaughter sitting in his lap, playing a game, looking totally entranced and delighted at the game, and her grandfather looking at her, with just as entranced and delighted an expression as on his granddaughter's face, even if he didn't necessarily understand what the game itself was about. He got so much enjoyment out of just watching his granddaughter enjoying the game, that it was fun for him, too.
The Wii was so successful as a social party game, because the players themselves were more fun to watch than the game on the screen, because they make spectacles of themselves, which is much more entertaining to watch than the computer graphics. And you don't get bored waiting for your turn to play, because it's fun watching other people play.
I'll add that many games don't understand "the reveal." They simply rely on "the experience." iow, Sure, it's great to be an astronaut zapping meteors, but it's not great to instantly and always be that astronaut. It's best to earn the ability in several large strides.
Mario is an 8bit game. There's no "real physics" in it. They aren't "applying a force to a mass". They're just adding an acceleration (gravity) to a velocity and that to a position.
I'm not sure that's the feel I would shoot for. SMB 1 feels very odd, I'd try to mimic Super Mario 3 or Super Mario World.
http://en.wikipedia.org/wiki/Game_mechanics#Game_mechanics_v...
(Cross posted from another reply I made:)
Asteroids-like spaceship movement is not a game mechanic. Shooting bullets is not a game mechanic.
A game mechanic would be the system that is the feedback loop of moving to chase/avoid asteroids while shooting them and creating more and faster obstacles and targets.
The gameplay is what the player can actually do at any given point in the course of the game: move a piece, make Mario jump, shoot a gun.
Rules define both the valid inputs and the reaction of the game to player input: you can't walk through walls, monsters drop loot, XP lets you level up.
Mechanics are the higher-level constructs resulting from the feedback loops created by the game's rules, in reaction to choices that the player makes.
The example of Asteroids:
The gameplay is moving a spaceship and shooting asteroids.
The game rules state that you progress to the next level by clearing all of the asteroids from the screen. When you shoot a larger asteroid, it breaks into several smaller pieces. When you shoot the smallest asteroids, they disappear. Colliding with an asteroid means you lose a ship, and losing all of your ships means you lose the game.
The mechanics that result from this are evading the asteroids on the screen, judging the risk of shooting each particular asteroid, choosing the right place to be and the right time to shoot, allowing you to stay alive to eliminate them all.
It is interesting that the author of the page calls them "examples for game mechanics" not examples of game mechanics, so he may be in agreement with you.
Can't write more now, need to go play with the other examples!
See also the source here:
https://github.com/photonstorm/phaser/blob/master/src/physic...
and the doc comment for computeVelocity a couple lines down.
But then I saw the linked page, and it gave a pretty decent definition of Game Mechanics: http://www.lostgarden.com/2006/10/what-are-game-mechanics.ht...
Asteroids-like spaceship movement is not a game mechanic. Shooting bullets is not a game mechanic.
The system that is the feedback loop of moving to chase/avoid asteroids while shooting them and creating more and faster obstacles and targets is a game mechanic.
I would love to see this teach-by-example format used to show some collision detection (polygons, squares, circles, pixel), scrolling (top-down, side), expanded gravity with objects that have gravity, particles, and controls.
Then there are all the "boring" mechanics like saving scores and other data, main menu systems, options screens with volume control, toggles, linking to websites, tweeting scores, etc, etc, etc.
http://www.wildbunny.co.uk/blog/2011/04/06/physics-engines-f...
http://www.wildbunny.co.uk/blog/2011/04/20/collision-detecti...
That said, the term 'Mechanic' in game design has multiple meanings. My favorite is in context of Dynamics and Aesthetics, as explained here - (pdf) http://www.cs.northwestern.edu/~hunicke/MDA.pdf
I for one hate the drag component in platform games. It makes them always feel very sluggish and imprecise. Most of the Mario games are unplayable for me because of this behavior.
An issue I noticed: After loading a lot of examples, the page seems to slow down a lot, like everything else is still in the background somewhere.