Tag Info

New answers tagged

1

This is a quite known issue in box2d, the problem is that you are rendering a rectangle per Tile and in the joint of those there is a ghost vertex, you can read extensive explanation here: http://www.iforce2d.net/b2dtut/ghost-vertices As for a solution to that i solved it by creating an object layer in my tiled map and created a Polyline object that defines ...


1

You should draw everything, and swap the buffer (display), at most once per frame (usually 1/60th second). You should definitely not call window.display() more than once per frame. If nothing at all has moved, you might choose to skip drawing and displaying entirely for that frame, especially on a mobile device to conserve power. On a desktop, typically, ...


0

Your best bet is probably Thought 1: A simple tile map and sprites. Unless you're going full-blown OpenGL then doing things like texturing quads is a bit overkill since you're already using a graphics library. Also, you don't need to make a polygon for your hitboxes; a simple rectangle will do in most cases.


1

So @tkausl's answer worked, the player now moves smoothly along the predefined path, here is the updated code: Edit: Bonus WebM of it working if (pathFound) { // A path has been found const float unitsPerTick = 8; // Speed in Units per tick auto waypoint = waypoint_queue.front(); // The waypoint in use Vector2i movementVector = ...


2

Your problem is, you're applying all waypoints in the same frame, which makes the character appear at the last waypoint directly, without moving at all. What you have to do is take on waypoint per frame and move only this one step. Or, better yet, move a bit in direction of the first waypoint, then, if you're near enough, discard the first waypoint. ...


1

You can see the value of your member variables in your debugger, and it will show you the correct values. Your problem lies in that the matrix transformation commands of legacy OpenGL are accumulating on top of each other. If you want to start from a known state, you need to look into the functions that let you load an identity matrix, push and pop on the ...


0

The Separating Axis Theorem might be what you're looking for. Writing collision detection using SAT is easier than it seems and allows you to calculate handy things like where exactly they collided as well as the minimum translation vector. Highly recommended for shape collision detection.


1

This is a classic collision detection problem. Thinking about it in pixels isn't the right way of going about it though. What you need to do is have a geometric representation of your player and the boundaries of your tile map. This might be as simple as just having a bounding box on your player and on each tile. When the player's bounding box intersects ...



Top 50 recent answers are included