Local Moderators said:
2D Super Mario Galaxy Gravity
- Title: 2D Super Mario Galaxy Gravity
- Description: 360° platformer gravity. Including support for non-circular planets.
- GM Version: GM6
- Registered: Yes.
- File Type: .gm6 (mirror: .zip)
- File Size: 36 kB (mirror: 15kB)
- File Link: Super_Mario_Galaxy_Gravity (mirror)
Additional Info
Credit appreciated.
In-Depth Description:
This example revolves around getting the character to move 360° around any shaped 'planet'. The method it uses to accomplish this goes like this:
Finding the nearest ground is probably the trickiest part to grasp but basically, the character just checks for collision in a circle constantly increasing in radius (using the collision_circle function). If a collision is found it then checks each point on the circle (360 default) to find the exact location of collision (using the lengthdir_? functions in combination with the position_meeting function). The gravity_direction is then adjusted to the direction of the point
Another tricky part is to find what angle the terrain slope is at. This example accomplishes this by sending two "rays" downwards (one on either side of the character) in the direction of gravity (found by the previous step) until both hit the ground. A right-angled triangle is then formed between the two co-ordinates where the rays hit and the angle is worked out from that by using simple trigonometry.
The movement is relatively simple in comparison to the rest of the code. The character simply moves in a direction perpendicular (90°) to the gravity direction. Jumping is accomplished in much the same way by sending the character in a direction 180° from the gravity_direction.
The rest of the example is relatively simple code that does not need to be explained in detail.
And just to clear things up, this is not the engine the Frozzd uses. I made it myself. 2DCube made his own engine.
Enjoy,
$pecter
This post has been edited by $pecter: 16 November 2008 - 11:16 PM

Help

MultiQuote








