Tag Info

New answers tagged

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


1

Why would you consider the wave disappearing unexpected? The shader averages/spreads differences in the heightmap. All it does is basically damping. Each iteration it will flatten out the waves, making them a little less high and a little wider. To have a more realistic wave-propagation you might want to try to use 2 textures. Use one for heights, and one ...


0

I think what you're looking for is an object pool. You can create such a pool with constant time (O(1) complexity) creation and deletion, which is perfect for your case, I believe. Let's say you have an Entity class: class Entity { public: Entity* getNext(void) const { return m_state.next; } void setNext(Entity* next) { m_state.next = next; } ...


1

This usually depends. Are the sprites static? If they are, you could use a Vertex Array for storing all of your static geometry and such. I believe there is an example of this in the SFML tutorials, under Vertex Arrays. This is a great way to store maps, but it isn't always suitable for moving sprites, like the player sprite. ...


1

As far as I know, this is possible using the sf::Image class: sf::Image spritesheet; spritesheet.loadFromFile("spritesheet.png"); int currentSprite = 2; sf::Texture texture; texture.loadFromImage (spritesheet, currentSprite*spriteWidth, spriteHeight); sf::Sprite sprite; sprite.setTexture(texture); If you do this in a for-loop, you could create a fluent ...


1

The games that have nothing but an .exe have compiled their executable with the assets inside. This is generally poor practice. By embedding your assets into the executable, they will stay loaded into memory while the program is running, even when not in use. For your scale and with modern machines this might not be much of an issue, but as the executable ...


0

Put all your frames into 1 image, then load that image into an sf::Texture. In your spritesheet class, have that texture (or a ref to it) as a member along with an array (vector) of sf::IntRect objects, which each represent the parts of the texture that the frames are from. When you want to draw a frame from your spritesheet, create a temporary sf::Sprite ...



Top 50 recent answers are included