Tag Info

Hot answers tagged

19

In various Super Mario games, it's called a pit, abyss or bottomless pit. Bottomless Pit is also a TV trope.


16

Create a custom map format for your game. It's easier than you might think. Just use the BinaryWriter class. First write the header in a few ints or uints. Information to include in the header: The magic string / magic number of you file format. The start/end/size of the chunks described in this file and also (and here comes the performance critical part ...


16

one byte for the whole number and another for the fractional part Basically you just have to subtract 64 from low in order to subtract 0.25, because an 8 bit value can have 256 values, so 256 * 0.25 = 64 When there is an underflow in low also subtract 1 from high. Disclaimer: This code is intentionally wrong when it comes to negative numbers, it is ...


15

Do it like Super Meat Boy. I assume your game has levels of some sort since its a puzzle plat-former, so as you mentioned Super Meat Boy I believed it's a great example for your question. In super meat boy, the way you control meat boy stays the same throughout the game, it's only the mechanics of the levels/environments that change. Therefore every ...


11

I ran into a similar problem and decided to create my own structure to handle the data. It's based loosely on a quadtree, but has infinite (at least as big as an Int) expandability in all directions. It was designed to handle grid-based data which expanded from a central point, much like Minecraft does now. It is space efficient in memory, and very fast. ...


11

You are absolutely right. I've had my share of problems with the collision routines on the XNA platformer sample. But I've managed to start from the code as provided in the sample, and modified it a bit until I achieved consistent results in every test scenario I could throw at it. In particular, the sort of problem I was having was when trying to slide ...


10

I think I stumbled upon this link here on gamedev and I really found it enlighting. http://higherorderfun.com/blog/2012/05/20/the-guide-to-implementing-2d-platformers/ It explains some basic methods of implementing tile based levels, but there are also some important parts about how certain mechanics work in 2d platformers. I think you should look into ...


8

It's mostly a subjective question, and it depends a lot on your intended game aesthetic and mechanics. The important ratio is feature size to screen size, not feature size to tile size. Some numbers are given here : http://kotiro.petermichaud.com/visual/resolution/. As you might notice, the original Mario Bro featured a really small mario, not only in terms ...


8

From what I understand reading your question, you want to calculate the correct Y position, given a X position of the player. This is rather trivial. Have a look at this image: Assuming your slope-tile is at a given position x,y (origin is bottom left as in the image). You have the player position x1 and the width and the height of the sloped tile (u, v). ...


8

The simplest solution for you will be to check both collision directions against every object in the world before resolving any collisions, and just resolve the smaller of the two resulting "compound collisions". This means that you resolve by the smallest amount possible, instead of always resolving x first, or always resolving y first. Your code would ...


8

One possible solution is as follow: Fix the rotation angle for the box Box2D doesn't have angle joints, but setting the body definition with the property fixedRotation = true allows it to maintain a constant angle of rotation like the angle joint. High maximum torque for the motor's joint The maximum torque for the motor in the revolute joint needs to ...


7

The simplest, more fail-proof approach is to simply not check for collisions on hidden edges. If you have two wall tiles, one directly above the other, then the bottom edge of the upper tile and the top edge of the lower tile should not be checked for collision against the player. You can determine which edges are valid during a simple pass over the tile ...


7

I believe you're on the right track. Take a look at my amazing artistic skills here ;) Let's say that the player is the red block with the solid being their current position and the open square being their previous position. Now say that the blue tile is the platform you expect to land on and the green one is some other "impassable" tile beneath it. The ...


7

I think your main problem lies here: While the jump button is pressed, gravity is turned off and the avatar's Y coordenate is decremented by the constant value of the gravity. For example, if things fall at Z units per tick, it will rise Z units per tick. Gravity doesn't work like that. Google "uniformly accelerated motion" for the details, but ...


7

In such cases, you may be better off letting the client be slightly authoritative. For such precise controls you're extremely unlikely to get good behavior even with really advanced correction and prediction. The client needs to extend from just sending "I jumped" messages to sending "I jumped from X,Y at time T" messages. The server then checks that the ...


7

No, you don't have to use any specific toolset and you don't have to use any specific (physics) library either. It's just a question of convenience, since things like Box2D will provide you other benefits as well, e.g. being able to do collision, physics simulation etc. If you're not using tiles, you'll most likely want to write your own custom editor. As ...


6

I think there's a few reasons behind 3d platformers declining in popularity, and thus, declining in sales (and since sales is the defining metric for what types of games are made, you can draw your conclusions from that). First, Jeff's comment about people simply not comprehending 3d too well on a 2d screen. Now, you could argue that FPS games are 3d on 2d ...


6

OK, I figured out why the XNA AppHub platformer demo doesn't have the "jumping" bug: the demo tests the collision tiles from top to bottom. When up against a "wall" the player may be overlapping multiple tiles. The resolution order is important because resolving one collision may also resolve other collisions (but in a different direction). The onGround ...


6

Although this is already answered, allow me to offer another equation: y = mx + b, where y is the coordinate calculated, m is the slope (-1 for down at 45 degrees, 1 for up at 45 degrees), and b is the y-intercept -- the y-coordinate where x=0. This allows you slightly more flexibility; you can change m to calculate a different slope other than 45-degrees. ...


6

I'm going to share a link with you that someone else had shared with me: http://higherorderfun.com/blog/2012/05/20/the-guide-to-implementing-2d-platformers/ This page covers several approaches as to how one might implement 2d platformers with both basic and some more advanced mechanics. It doesn't give you straight up code but it does a fantastic job at ...


6

How about making any "stick" surface a character touches apply a force along the inverse normal of the surface? The force remains as long as they're in contact with the surface and overrides gravity as long as it's active. So jumping off the ceiling will have the expected effect of dropping down to the floor. You would probably want to implement some ...


6

You don't say anything about what your game is, so it's hard to know whether you should or shouldn't have such collectibles. Some platformers do have additional tokens to collect, and some don't. There's no tradition that requires they be included in a game. What matters is if they fit in how your game should be played. I imagine you're more likely to be ...


5

Here the order I would do things.... 1) Save current X,Y of character 2) Move the X direction 3) Check all corner of character by getting the tile data and check if it is solid by doing the following: (X and Y is the character position) for top left: floor(X / tileWidth), floor(Y / tileHeight); for top right: floor((X + characterWidth) / tileWidth), ...


5

The easiest approach is to check for collisions more often. This approach separates into two methods: [most optimal, harder to implement] Check for collisions at least once per frame and after each N pixels (usually half of a tile) of movement. [least optimal, easier to implement] Split the movement vector into N parts (depends on level design, could even ...


5

You could use movement subdivision. If you have an object with a bounding box with a height of 50 and it moves 300 pixels in height that frame then you can move it 6 times 50 pixels and check each time if there is a collision. A small optimization to this technique is to draw a second bounding box from the start position to the end position of the ...


5

Here is my complete learning experience, resulting in a pretty much functional version of the movement I wanted, all using Nape's internal methods. All of this code is within my Spider class, pulling some properties from its parent, a Level class. Most of the other classes and methods are part of the Nape package. Here's the pertinent part of my import ...


5

Add an intermediate layer. You have some kind of PlatformInput that manages all the different input methods and generates low-level events like KeyUp, KeyDown, etc. Another layer then processes these messages into logic events, like MoveUp, Jump, etc. It can do this by receiving the inputs, mapping keys to logic events, and doing only the most basic ...


5

Most games don't have a separate class for each level. The usual way is to store the layout of each level in a file. These map files contain the environment and the positions and properties of all objects in it. When a level starts, the map file is loaded and a Level object is initialized with the data from that file. When the player finishes the level, ...


5

Make sure that there is a visual cue that the player is currently not in control. When it is a non-interactive cutscene, you could remove the GUI during the cutscene and bring it back as soon as the player is in control again. When the users control is impaired (but not completely disabled) during normal gameplay, for example because their character is ...



Only top voted, non community-wiki answers of a minimum length are eligible