Tag Info

Hot answers tagged

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


14

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


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


9

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

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

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


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


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

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


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

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


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

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


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


4

Edit I have improved it It seems the key thing I changed is classifying the intersections. Intersections are either: Ceiling bumps Ground hits (push out of the floor) Mid-air wall collisions Grounded wall collisions and I resolve them in that order Define a ground collision as player being at least 1/4 way on the tile So this is a ground collision ...


4

I don't think that half of your code base will turn into network code if you decide to implement a feature such as this. In my opinion, the most simple way to do this, is to setup a "central" server (even if that means that one player "hosts" the game and then connects to his own server) that accepts all user input as fast as possible, and sends it back out ...


4

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


4

What you want to do is travel over that line and project the player's position onto the y-axis of the slope. That sounds complicated, but it's alright. Suppose we define a line as being between two points: p0 and p1. We can define the slope of the line as p1 - p0. What we need to do is take the x of the player's position and plug it into our line equation ...


4

Generally, you should not “cull” physics updates in your game with respect to the screen, except perhaps to a very limited extent — things not moving when they are off-screen is now seen as archaic. What you need to do instead is make the updates more efficient. You state that you have tile-based liquids. I assume they are flowing around by checking their ...


4

Definitely maybe. Good platformers that have collectibles (and how they're used): Nintendo's Super Mario (coins, Shine Sprites, mushrooms...) Very frequent coin pick-ups, with some games featuring collectibles that are harder to find. Team Meat's Super Meat Boy (bandages). Always very difficult to get, but optional to winning. They're still visibly ...


3

You may find a lot of value in this site: http://info.sonicretro.org/Sonic_Physics_Guide Specifically for what you are looking for check out the Solid Tiles: Slopes and Curves section. It basically shows you how it is believed this was accomplished in the early Sonic games.


3

Handle all slope tiles as a rise/run ratio. Each slope tile will have a ratio, and assuming 45 degrees means going up as you go right, 315 degrees will have a ratio of -1. Think back to basic coordinate algebra. Using the player's X position local to the tile, which is the run, solve for pos.Y by multiplying the X position by -1. However since y = 0 is ...


3

You could use a database instead -- PostgreSQL has some special indexing capabilities optimized for this type of data which is located by X and Y coordinates. You can also specify that the data returned is within a certain radius rather than in a square or oblong shaped area.   PostgreSQL (free and open source)   http://www.postgresql.org/ There ...


3

The simplest way to get you approximately correct beahviour would be to have your CheckCollisions() function consider the relative velocities of the two objects, in addition to their current positions. Basically, you do this: Vector3 RelativeVelocity = secondVelocity - firstVelocity; And then only treat it as a "didJumpOnEntity" event if the resulting ...



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