# Tag Info

0

How I would do it: Step 1: define rectangles for the bounds of each room and hallway. Now imagine these rectangles as safe areas where the player can be. "Out of bounds" would be declared as any position in which the player is not fully contained in any of the rooms or hallways. Here's a picture as a demonstration: Now, before we go further, you must ...

5

General concept Create a server class (to handle connections and messaging) and a client class (to handle connecting to server by IP and port). Then ask the player whether they want to create or join a server. If create, start a server and join it with the client. If join, join the existing server. Minecraft singleplayer can be opened to the LAN, by ...

1

If you have multiple sprites at the same position, are they all supposed to prevent the player from falling? if so, you can either merge them, or disable collision for one. Else, if not all the sprites should collide, maybe you can add a flag to indicate if they are ground colliders. On a side note, you could use a complete AABB instead of using arbitrary ...

0

If you keep track of the position at last frame you can also create a line from last position to current position and do line to rectangle collision detection to see if you went though the terrain.

1

I did something similar, but with edge detection algorithm. I would use the following setup: 2 frame buffers with one texture each. a vertex buffer/mesh with a full screen rectangle (-1,-1 -> 1,1) with the texture cords going from 0,0 to the texture size. one shader computing the game of life The two frame buffers are used alternating, since they can ...

1

Making collision detection frame rate independent is basically impossible. While you can reasonably implement frame rate independent rigid body motion and many other simulations by multiplying by dt (delta time), actual collision detection is "impossible" to do frame rate independent. To illustrate the issue let us assume you have a small cube moving at a ...

1

found the solution. quad[0].position = sf::Vector2f(x, y); quad[0].position = sf::Vector2f(xsize, ysize);* now fps is like 1100

0

Ok so I found the solution, and thanks for you replies. The linem_player->GameObject::setPosition(m_player->GameObject::getPosition() + dir); was only updating the gameobjects position variable, this variable only took effect on the gameobjects update. Which why of course it worked when there was only one wall. But with a second wall, it would ...

0

if (col.left) dir.x += (wall.getPosition().x + wall.getHalfSize().x) - (m_player->getCollider().getPosition().x - m_player->getCollider().getHalfSize().x); else if (col.right) dir.x -= (m_player->getCollider().getPosition().x + m_player->getCollider().getHalfSize().x) - (wall.getPosition().x - wall.getHalfSize().x);

0

A possible explanation for this is unrelated to the corners: to determine whether it's colliding left or right, or if it's colliding up or down, instead of checking how far inside the player's hitbox is within the wall you should check the direction of the player's movement. It would go more along these lines: CollisionData testPlayerCollision(const ...

0

Here's one thing I noticed: //width==256 //create 255 columns, indexes 0-254 ptr = new Block **[width - 1]; //populate columns 0-255 for (int i = 0; i < width; i++) //This part sets up the 2d block array of pointers { ptr[i] = new Block *[height - 1]; } You did this in Load(), as well. You want to: LevelData[x] = new char[height]; //256, ...

0

Why not just use the sf::Window::setFramerateLimit(unsigned int limit) method? That should be a lot more straightforward and it works flawlessly for me. EDIT:Just read you used it before. Gonna tell you something. Basic of rule of programmers. If it works, don't fix it.

0

Sorting Use a quad- or oct-tree. Basically, the single bucket (vector/array) you are using now represents the outer-most tree-node; it contains everything. In addition to containing all game objects, it will contain 4/8 child nodes (sub-buckets) that are exactly 1/4(quad) or 1/8(oct) the size of the orginal and fit entirely inside it with no "empty space" ...

0

One way to do it would be to wait until all your collision detection is done before 'reacting' to it. You could then check if it touches only the water and not the log before 'reacting' to the event. Example game loop: Update from user imput Move your game objects Clear frog-water collision flag and frog-log collision flag Perform collision detection ...

2

You are changing the size of the array inside the loop, but not updating the loop index to match.. Thus you skip one item in the list every time you delete one. for (unsigned j = 0; j < SpriteVector.size(); j++) { if (this->SpriteVector[j].getPosition().x < 0 - 80 ) { //this succesfully removes the object from the vector ...

0

When you set the origin you have to take into account the position of the card and its previous origin. card.setOrigin(event.mouseButton.x - (card.getPosition().x - card.getOrigin().x), event.mouseButton.y - (card.getPosition().y - card.getOrigin().y)); I don't really know how to explain, I will try with a drawing. Your card is the red ...

Top 50 recent answers are included