Tag Info

Hot answers tagged

20

It sounds like what you need is the concept of rooms as opposed to screens. Screens 1-3 would be one room, e.g. Your rooms could then be of any size and shape, or even restricted to the size of multiples of a screen. Your camera would follow the player through a given room, up until the player gets too close to the border (half a screen width). When the ...


19

When a player collides with a wall while jumping (or, if you like, falling), turn on a flag for the next 100 milliseconds or so that causes an attempt to jump to successfully initiate a jump (ignoring any surface contact checks) with a fair amount of speed on the X axis in the direction away from the wall. Remember to turn the flag off early if a jump is in ...


19

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


16

My solution would be to treat every physical entity in the game map as a tree node, and the map itself as the root node. Nodes can contain other nodes. Every node is contained (directly or indirectly) inside the map node. For example, let's say your character is standing on a platform. The platform's node contains the character's node. So, whenever the ...


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 ...


16

Let's separate your problem into its distinct issues... A word on code quality Your code currently has your platforms directly controlling your player's velocity and even the world's gravity constant. It's hacky, and it's procedural when it should be object-oriented. Once you start expanding this game things are going to get ugly fast. You need to ...


15

I have a personal logic issue on a regular basis that you seem to be expressing here. It's that sometimes you're looking at the logic and programming from the wrong direction entirely. In this case, you seem to not be realizing that from the beginning you know which is happening, because of the logic code. You should already know, programmatically speaking, ...


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 ...


13

In using the word connectedness, you've come within a hair's breadth of the tool best suited to determining a solution: graph theory. Connectedness is a property of graphs. Graphs can be either connected or disconnected (as you're experiencing, AKA a multigraph). Any game level, in any number of dimensions, can be represented as a graph, and logically, this ...


12

There are three general approaches to dealing with stairs in video games: The "Mario" approach is that you must jump to get up stairs. The "Castlevania" approach is that moving up/down stairs is a different sort of movement; you must press 'up' on the controller, and a special "stair-climbing" animation is played to traverse the stairs. A variant of this ...


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 ...


11

If you're able to rotate the boundingboxes, I would've put a 45 degree rotated box at the player's feet and combine it with one non-rotated box to represent the rest of the body. That could make the player automatically slide over anything small enough. Though, that would probably cause some clipping with the player model and the stairs. Another idea is to ...


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 ...


9

This is almost paradoxical, because if you focus too much on "planning" for alternative routes you ultimately tend towards constricting the number of available routes to exactly those you've planned for, achieving a pale semblance of your goal instead. There is some level of specific design work you may need to do to facilitate this (for example, rooms in ...


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

You can do this in C#, but you'll likely need to P/Invoke a lot of the functionality you'd need. C or C++ is probably more well-suited to the task -- you'll have fewer hoops to jump through. There are a few open source "cheat engine" projects out there you can look at for a better idea of what you're going to have to do. How do I find the correct memory ...


8

I would suggest treating this as a pseudo-physics problem and solve it by using ground friction. You're already using gravity to hold the character on the ground, this handles the situations where platforms move up and down. To handle the left and right movement, the ground should exert a great deal of friction on the character. Typically this friction ...


8

Here's the method I found. It might be flawed, but I haven't found any problems with it yet in my cursory analysis. It also works for arbitrary polygons with a few minor modifications. In the illustrations below, the blue object is moving and the red object is stationary. Step 1: For each polygon, find the two farthest points along the projection of that ...


8

What I always do in this case is store a frameTime variable and store the last update time variable inside my animation class. Then I only update the frame if the currentTime - lastUpdateTime > frameTime, in which case I also set last update time to currentTime. Huzzah for animation =]


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

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 ...


8

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 ...


8

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 ...


7

The point of a quadtree is to efficiently cull large chunks of the data so that you only spend time on the data in the immediate vicinity. However a 2D array already gives you location-specific random access, so for a 2D game that may make a quadtree redundant. In a 3D game you can't use an array to locate everything and that's where quadtrees (or better yet ...


7

Isn't it as simple as having a collection of tile locations and frame counters that get updated? So where you have that code now (in rough pseudocode), if( thisTile == breakable && !breakingTiles.Contains( thisTile ) ) { breakingTiles.Add( thisTile ); } And somewhere else you do something like foreach( tile in breakingTiles ) { ...


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 ...



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