Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - OualidH38

Pages: [1]
1
Graphics / Animated Tile with Tiled Editor and SFML
« on: March 17, 2016, 07:44:47 pm »
Hi everyone,

I have a little question about animated tiles in Tiled Editor and SFML. I'm using this parser : https://github.com/fallahn/sfml-tmxloader

I was wondering if there is a way to handle animated tiles as follow:
https://youtu.be/ZwaomOYGuYo?t=15m19s

Because when I add an animation, it is not shown as animated, so I guess it is not handle by the parser.

Any idea?

Thank you in advance  ;D

2
Hi everyone!  ;D

I'm currently programming a little zelda like for fun with the SFML Game Dev book, and I have a little problem with z-ordering. I'm using the scenenode book architecture.
Actually, I'm able to sort children between them like this:
//Inside the update function
std::sort(mChildren.begin(), mChildren.end(), [] (Ptr& lchild, Ptr& rchild) {
                return lchild->getWorldPosition().y < rchild->getWorldPosition().y;
        });
 

But the draw function always draws the Parent before his children:
void SceneNode::draw(sf::RenderTarget& target, sf::RenderStates states) const {

        states.transform *= getTransform();

        drawCurrent(target, states);
        drawChildren(target, states);
}
 

The problem is that I need sometimes to draw the entity after his children.
Imagine that I want to implement some weapons entity.
I use the attachChild function to attach the weapon with the player.
I want to draw the weapon after the player when he uses the weapon at his left, right or bottom. But I want to draw the weapon before the player when he throws a hit at his top.


How could I sort (in the same way I sort children between them) the Parent with his children according to the book architecture?
I was looking for an answer on google, and I found nothing relevant.

I feel like the book architecture doesn't fit with what I look for.

I don't think this is a good solution:

Compare the the position between the parent and all his children individually

if(parent.position().y < child.position().y)
{
   -> draw child
   -> then draw parent
}
else
{
   -> draw parent
   -> draw child
}
 


Any idea will help.
Thank you in advance!  :D

3
Hello there  :D

I'm currently programming a 2D RPG using the SFML Game Development book.
I used quite the same architecture for my game such like scene nodes etc.
The tilemap is also a scene node, I managed to store the integer map into a std::vector, then the tilemap is displayed with a VertexArray.

I'm actually in Chapter 7 Implementing gameplay.

My question is:
How do I react to a collision between the player entity and a tile?

I managed to "detect" the collision by using a function that use the actual position of the player entity and the actual TileMap integer array. But to react to that collision I need to know the futur position of the entity and most of all how to allow or not the player entity movement?


So to summarise, I'm able to know on which tile the player is actually on, but I don't know the tile where the player will be before the movement and how should I "block" the movement.


According to the book, what is the best way to handle that kind of collision?
Using the SceneNode::checkNodeCollision(...) & World::handleCollisions() functions or an other kind of function?

Or perhaps the tilemap should have been an entity?

I really don't know, I will appreciate some help on that matter  ;D

Pages: [1]