I tried my hand at a side scrolling platformer in phaser myself some time back.
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.
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.
Do you have link? As someone who's written 8bit platformers and effectively "copied" Mario's feel I didn't have to lower gravity to achieve a similar feel. I just set velocity while the button is held. There's no reason to lower gravity.
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.
So altering the acceleration rather than the velocoty gives more natural results? I wonder if our brains are good at first derivatives, but nothing beyond, so a discontinuity or warp in acceleration is less noticeable. SMB1 does have fantastic variable jump height.
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.
Will you are probably technically correct, it would be helpful if you could explain what they are instead. Because they're a bit more than just applied physics - the choice in jumping mechanics has a fundamental influence on gameplay, so there is at least some kind of relation to game mechanics.
Nice stuff. I noticed something slightly weird in the "Spaceship motion / With drag" example. Looking at the code it seems that drag is applied individually on the X and Y axis. If you rotate the ship just a little bit, gather some speed and then let go, the ship will have its horizontal speed zero out rather quickly and the ship will glide sideways until it comes to a halt in the vertical direction.
Can't write more now, need to go play with the other examples!
"drag" seems like a bit of a misnomer for what that parameter is doing - the effect on x and y velocity is calculated separately, so you're always going to get the little "twist" at the end when velocity on one axis drops below the drag value.
Yes, I guess the examples shown are indeed "game mechanics" of a sort, but it seems to be heavily focused on game physics, at least for now. When I saw the title I was thinking of something much broader that would include things like how to use items, how to level up, etc.
Game mechanics are the rule systems that give the game goals or meaning.
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.
This is a great way to present the mechanics with phaser code to back it up!
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.
Wow, awesome. The "Homing Missiles, Flocking" demo is pretty much a game by itself already. "Variable Jump Height" just needs a score meter and some obstacles and that's also a game all by itself (ala Flappy Bird). Great collection!
A suggestion, assuming the author reads HN: One very basic game mechanic that is so far missing is strategies for collision detection. I would be quite interested to see interactive examples (and code examples) that do a good job of covering that topic.
Great little resource for building your first game.
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
PS: Phaser is a very good framework. I've used with Typescript and that's as close as you can get from AS3 and flash, without flash. (Cause you know, flash is the birth of all evil yaddi yadda)
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.
[+] [-] TheZenPsycho|12 years ago|reply
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.
[+] [-] DonHopkins|12 years ago|reply
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.
[+] [-] greggman|12 years ago|reply
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.
[+] [-] nitrogen|12 years ago|reply
[+] [-] cma|12 years ago|reply
[+] [-] jcromartie|12 years ago|reply
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.
[+] [-] vanderZwan|12 years ago|reply
[+] [-] vinkelhake|12 years ago|reply
Can't write more now, need to go play with the other examples!
[+] [-] al2o3cr|12 years ago|reply
See also the source here:
https://github.com/photonstorm/phaser/blob/master/src/physic...
and the doc comment for computeVelocity a couple lines down.
[+] [-] barbs|12 years ago|reply
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...
[+] [-] arghbleargh|12 years ago|reply
[+] [-] jcromartie|12 years ago|reply
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.
[+] [-] NoPiece|12 years ago|reply
[+] [-] dpcan|12 years ago|reply
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.
[+] [-] lobotryas|12 years ago|reply
[+] [-] xvedejas|12 years ago|reply
[+] [-] rmb177|12 years ago|reply
http://www.wildbunny.co.uk/blog/2011/04/06/physics-engines-f...
http://www.wildbunny.co.uk/blog/2011/04/20/collision-detecti...
[+] [-] jcromartie|12 years ago|reply
[+] [-] Vermeulen|12 years ago|reply
[+] [-] apitaru|12 years ago|reply
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
[+] [-] keyle|12 years ago|reply
[+] [-] unterstrom|12 years ago|reply
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.
[+] [-] albeec13|12 years ago|reply
[+] [-] Gracana|12 years ago|reply
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.
[+] [-] thyroxo|12 years ago|reply
[+] [-] nichochar|12 years ago|reply
[+] [-] afhdshufdufdo|12 years ago|reply
[+] [-] _random_|12 years ago|reply
[+] [-] ekmartin|12 years ago|reply