The Daily Click ::. Downloads ::. Engine ::. Super Mario Engine V2 + Source!

Super Mario Engine V2 + Source!
Author: Pixelthief Submitted: 24th January, 2008 Favourites:0
Genre: Engine Downloads: 735
105th Place     (4.25 / 5)

Note: This is NOT an updated version of my old engine; instead this is a made-from-scratch new version that I put together last night, which allows for much neater stuffs, and also comes open sourced!

If you remember my old engine; this is essentially the same thing, except with a revamped movement/platforming engine. It works on 2 rather simple concepts:

1) The gravity:
This is for those who would rather hear how it works, then dig through the code; What it does is on every frame of gameplay, it cycles through each source of gravity ("gravity well", and adds a velocity vector to the player's movement based on the formula:

Velocity = Power / (distance ^ 2)

Hence, the X & Y velocities applied to the player each frame for every single gravity object are:

XVel = Cos(Angle between player & well) * (Well Power) / ((Distance between Player & Well) ^ 2)
YVel = Sin(Angle between player & well) * (Well Power) / ((Distance between Player & Well) ^ 2)

In a simple setup where these velocities are integrated into standard positional movement, this then provides accurate gravitation. In the code, you'll notice alot of these numbers have VERY high values; this is due to TGF not being able to save floats, and thus is neccesary.

2) The platform movement:
This is new to this version- it allows for the player to walk along the edges of essentially any oddly shaped obtuse object with a gravity well on it, even if its not in the center.
First, as soon as you touch down onto ground (it detects the player hitting ground via a posteriori detection; it checks your next movement due to your current velocity, and if this would overlap a backdrop, it keeps you in the same position as the last frame, but counts you as "touching ground" it will keep track of the greatest source of gravity nearby; each run through the gravity well cycles, it records which one gave the highest 'weighted power'. This one is then treated as the center of gravity for the object you are on.

Nextly, when moving "left or right" around an object, it follows a simple algorithm;

1) Check the position equal to the next positional movement at a 90 degree angle to the gravity well; the tangent with the surface.
2) If this position is overlapping a backdrop, move the angle upwards by 1 degree, and repeat until it is not overlapping a backdrop, then skip to 4)
3) If this position is NOT overlapping a backdrop, move the angle downwards by 1 degree, until it is overlapping a backdrop, then move it upwards by 1 degree and go to 4
4) Use this angle as the position for the next movement; move the player

Hence, at every frame of movement, the player will be set to to 1 pixel away from the ground along the surface, and will follow it as long as the surface doesn't diverge from the center of gravity by more then 90 degrees.

(This is a feature I Have not made, but intended to)
Linear projection;
I got lazy, and only set the groundworks for this, but couldn't get the math quite right; I wanted to implement a system where given 2 points that form the endpoints of a line (seen as "Left Checker" and "Right Checker" in the editor), it could then place a gravity well projected and restricted into this line from the players position. The point of this, is that then on long surfaces, such as the vertical strip or the Sin wave you see in the editor, the gravity well would follow beneath the player, always counting the center of gravity as immediately on the surface. This is very useful, as it allows the player to effectively gravitate towards the surface with proper effect, and jump with the restrictions of gravity constant at any point on the surface. Simply creating a long horizontal strip with 1 gravity well in the center would result in that jumping from either edge would have dramatically higher jumping then jumping from the middle. If the well was projected onto this line, its always constant.
Likewise, this would allow for more spunky effects, such as platforms set at odd angles, sin waves and other wierd transformation types of platforms and the like. Unfortunately, my brains were too addled to do this on anything more then a simple vertical/horizontal scale, which is retardedly easy.

So be a dear and looky through, see if you can discern from my poorly commented coding how it works.

Review This Download (699 kb )

Posted by alastair john jack 24th January, 2008
Rated :

wow, thats awesome!
Posted by Cecilectomy 24th January, 2008
Rated :

so wait. thats without using the projection stuff? it looks like it can handle odd angles without it. unless you updated it before i could dl it .

only problem is when walking on a horizontal or vertical platform (probably on any surface, its just more noticeable on the hor or vert), the angle seems to be off a little. so when you jump, its not straight.

also i used the stars to blast my way AWAY from any gravity strong enough to pull me back so i just drifted away lol.
Posted by Pixelthief 24th January, 2008

Yeah, all the stars are arranged in a very specific manner; most of them should blast you directly into another star. Like the one on the big brown square will send you flying past all sorts of wierd stuff, but should always land in the right spot (an orange planet)
Posted by Peblo 24th January, 2008
Rated :

Thanks, I was waiting for this.
Posted by Pixelthief 24th January, 2008

eah and as far as the jumping is concerned; I half-assed the jumping system, so its not nearly as tight as the movement, however it should always be projecting the player in a perpendicular to the surface, not the gravity source. This should only *not work* if you're on a surface at a 90 degree or more angle to the center of gravity, since I only set the movement to check for 90 degrees either way (the 90 loops thingy). I haven't tried it, but theoretically you could just tell it to run 180 loops and that might fix it.

The main problem you'll see is that because of the gravitation, if you jump straight up you'll often be pulled to a side by the latent gravity. I guess if you wanted, you could just lower the max distance for a gravity well's effect, which would make movement seem more contrained.
Posted by Jason Orme 25th January, 2008

Any chance of putting the DLL in the zip?, havn't used TGF in years..
Posted by Cecilectomy 25th January, 2008
Rated :

just google cncs32.dll

first one is a download
Posted by Guru Rinpoche 25th January, 2008
Rated :

Knowledge is power!
Posted by [EclektiK] 25th January, 2008
Rated :

Power is knowledge!
Comment edited by Eclektik on 1/26/2008
Posted by Airflow 25th January, 2008
Rated :

Is power knowledge?
Posted by Kazuma 26th January, 2008

If knowledge is power, power is knowledge.
Posted by [EclektiK] 26th January, 2008
Rated :

so...Power is knowledgable?
Posted by Tim 27th January, 2008

No, powerful.

But wisdom is neither!
Posted by Pixelthief 27th January, 2008

Mind that the angular movement thingamajig can be easily adapted into a neat little enemy movement system; by just giving each enemy an angle value you can iterate through each one and apply the movement. I tested it and found it to be operable on about 30-40 enemies before there was a noticable slowdown, and even then it was only to ~37 FPS, at the least.
Posted by DaVince 28th January, 2008
Rated :

Knowledge can be power, and power can be knowledge.

Make a full game out of this already!
Posted by MBK 7th February, 2008
Rated :

Makes me feel good to know that i'm not the only one who still uses TGF. I have some interesting code myself, that i've shared with a few people .. it would make for some good Beat-em-up character movement. I need to get a free host and put my stuff on this site sometime.

This is a SwEEt example btw Pixelthief. Got any other little things like this ? Very nice stuff. I'm stuck trying to make animations for the beat-em-up i wanna make. ... I'm terrible at graphics Image.

Oh yea, and Knowledge is always power, because it allows questions to be answered, which in turn sets events into motion. Even trivial knowledge could win you money, say for instance on a game show.

Power, however, is not always Knowledge, as there are many other forms of Power besides Knowldege. ... Power is at the top of the pyramid, with all its groupings below it.

Yea. Davince was closest. ImageP

And Tim the cat is right, Wisdom is neither. Alot of people confuse Wisdom with Knowledge. I bet there's even dictionarys out there that confuse it.

And me writing all this was probably Unwise, because now I look like a know-it-all, which i'm not ... as a matter of fact, i know very little, but what i do know, i have wisdom about. ... hmm... Wisdom, Power, Knowledge .. no .. that's not it ... What was the third TriForce ? ... heh. There was only 2 on the old cartoon, Power and Wisdom .... What's that one in the game that isn't in the 80's cartoon ?

This is the first i've been on here in a long time, .. I like how the voting system is now .. was that like that before ? .. well, anyways... it's the best one that i've seen on any site so far. .. WTG TDC !!
Comment edited by MBK on 2/7/2008
Posted by Ski 10th February, 2008
Rated :

Cool engine, felt a bit odd though sometimes.
Posted by Sir_robin 9th May, 2008

The dll is IN the zip.. just a typo.. its called cncs232.dll instead of cncs32.dll just change it.

P.S the game crashes after i jump..:s
Posted by OMC 8th July, 2008
Rated :

Awesome Pixelthief, very nice.
Posted by Arekku Dai 22nd August, 2008
Rated :

Had me awestruck at most times. I got worried when Mario started floating out of orbit, but he eventually floated to that eyeball planet.





Worth A Click