View Full Version : Super mario
plasmagames
06-01-2008, 04:08 AM
K, since stopping production on the guitar hero game i was think I now have some free time and i just found this awesome Mario game called Mario Forever(freeware). I looked for a flash version of the original SMB(Super Mario Bros. or SMW(Super MArio World/without cape mario) and suprised no one had i good one so i was think maybe i should make a good flash one.
So heres what i need and what i need to no.
need: super mario world sprites(mario, scenery, enemies)
need to know: how to make the game work with platform
example mario jumps on to a block and doesn't go through
GMaker0507
06-01-2008, 08:33 PM
For the sprites, Check out The Spriters Resource (http://www.spriters-resource.com/nintendo/index.php)
For the mario style physics, basic hitTest functions (Search the flash help) could work okay,but for more accurate physics i would use AABB's
AABB's are Axis Aligned ( Non- Rotated ) Bounding Boxes
it may seem difficult, as it did to me, but for development and learning purposes it would be wise to just take a look at it, after a while you start understanding it.
If i were to start making a mario game now, thats what i would use.
For some info and tutorials on them, check out The N Tutorials (http://www.harveycartel.org/metanet/tutorials.html)
The guys on those website have some tutorials on collision detection, they also have put their game "N+" on the XBOX 360 arcade
and Some articles over at GameDev.net (http://www.gamedev.net/reference/list.asp?categoryid=45#199)
Newgrounds, even though is mostly known for gaming, can also be a big help for flash developers. Check this out (http://www.newgrounds.com/collection/flashtutorials.html)
plasmagames
06-04-2008, 02:19 PM
Ok, Sprites are cool but I need to know of some resource for using the hitTest and aabb fuctions. kuz right now i don't knwo where to start.
So post some tutorials on ways to use the function then i should be able to go from there.
Also i just thought of right now, how will i make the tunnel passage ways?
GMaker0507
06-04-2008, 04:01 PM
hittest tutorials are everywhere. Try searching these forums for hittest.
http://www.kirupa.com/developer/mx2004/platform_game.htm
this is a big tutorial: (Click Flash Icon -> Actionscript -> Platform game)
http://www.2flashgames.com/f/f-1290.htm
in as2 the hitTest function has two overloads(versions) one that accepts movieclips, and another that accepts certain points. Their downside is that they only return boolean. Such is why others turn to more advanced forms of collision detection using AABB's, OBB's (Oriented Bounding Boxes), Sweep Testing, and so on..
if(MovieClipInstance.hitTest(OtherMovieClip)){
//Yada Yada Yada
}
The downside with that code is that it only checks the ojects bounding boxes. Meaning, imagine a box that contains the whole mc, or rather, select the mc and look at the box flash displays. So, if your using two squares or rectangles, then it works fine. However if your using complex objects then it might say they are colliding when they are not:
Then theres the second version ( inMyTerms )
if(MovieClipInstance.hitTest(X,Y,useBoundingBox)){
// Yada Yada Yay
}
This version checks if the movie clip is hitting a certain point (X,Y). This one is a little better because it allows you to verify is you want to check using the bounding box or not.
If you have a wierd shaped object on the stage. If 'useBoundingBox' is set to true. If the objects bounding box hits the point and none of the objects pixels do, then it returns true. However if 'useBoundingBox' is set to false, then if the objects bounding box hits the point then it returns true, whether or not any of its pixels actually hits the point.
Get what i said, or not, you need to search more flash forums, and flash sites. Platformer tutorials on how to use the hittest function's are everywhere
Good Luck
plasmagames
06-07-2008, 03:43 AM
K so i got a better idea if the hit test, but i need to know to do the folowing:
When mario get the mushroom or flower it changes the sprite to the right ones for walking jumping etc.
plasmagames
06-07-2008, 05:43 AM
Here's a test swf file of the game with the mario stuff in it. There alot of problem i need help to fix them
Here the problems i see:
- Mario goes through objects that are solid objects
- background music doesn't work
- jumping is slow and too high
If you see any more tell em what they are and how to fix em
GMaker0507
06-07-2008, 02:35 PM
This is going to be a long post, so grab a drink ,a hot pocket, and get ready to read.
- Mario goes through objects that are solid objects
use the 'while' statement to push him back. for example, assuming your mc is aligned horizontal center, and bottom edge (bottom-middle of Feet at the origin ). If you wanted to stop overlap with the ground you could.
if(ySpeed>0) {/* If mario is going downward */
while(_root.Ground.hitTest(this._x,this._y-1,true))
{
this._y-=1 /* Move mario up one pixel */
}}
The problem with this code is, what if the ground doesnt hit (_x,_y-1) but it hits (_x+5,_y-1) or (_x-7,_y-1)? The possibilities are endless, simply testing for one spot can cause errors.
Another way, which is better , but can potentially throw the same errors we can check the bottom middle (_x,_y-1), the bottom right edge (_x+width/2,_y-1), and the bottom left edge (_x-width/2,_y-1). And if a collision is found at any of the three points, then we have hit the ground.
You could do the same for the top, left, and right edges
That should suffice, but if you have big sprites, errors might come up. But in a mario game, you shoud be fine.
- background music doesn't work
drag it from the library to whichever keyframe the game plays on,when the frame changes, the music stops
- jumping is slow and too high
Increase the amount of gravity (speed) and how much force is applied when jumping (height).
Note the stronger the gravity, the more force youll need to jump a certain height.
For example if you use this to move vertically (up and down):
_y+=vSpeed
you should have something like this for gravity:
if(!Grounded){vSpeed+=GravityAmount}else{vSpeed=0}
and for jumping:
if(Key.isDown(Key.SPACE)&&Grounded&&vSpeed==0)
{
vSpeed -= JumpStrength
Grounded=false
}
The 'Grounded' Variable
Note the 'Grounded' variable. I noticed that if we only test when mario's vSpeed is zero then at the exact top of mario's jump, based on the code instead of the design, he will be able to jump again.
You decide that boolean value probably like so
Grounded=(_root.Ground.hitTest(this.x,this._y,true )
But be careful when increasing gravity. Because movement as we see it in flash, and in all game development, is really drawing the object, then, next frame - erase and draw it again but 10 pixels downward. Repeat that over and over again at a fast rate and it seems like normal movement.
This is where a problem comes in. If, FOR EXAMPLE, the top of the block is at y=95 and the bottom of mario is at 90, then 10 pixels downward would be too much. Or course, we both now that we should instead move him downward 5 pixels, but how do we find this out, and code against it.
For beginners we dont, we let mario overlap, then we make up for it using the while statement, moving mario up one pixel during each iteration until he is no longer overlaping the block.
Using some AABB related math, fixing the overlap would be an easy thing that would would more quickly resolve the problem, but it would be more difficult
For those with a little more experience, we could use sweep testing, but only if we were dealing with high velocities
How to jump a certain height.
Note if you want mario to jump a height of 'MaximumHeight' with gravity at 'GravityAmount', you would find the 'JumpStrength' by using a trajectory equation for maximum altitude.
The equation (flash AS2 version)
var MaximumHeight = (JumpStrength*JumpStrength)/2*GravityAmount
so:
(JumpStrength*JumpStrength) = (MaximumHeight)*(2*GravityAmount)
and finally:
var JumpStrength = Math.sqrt((MaximumHeight)*(2*GravityAmount))
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.