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.


Messages - Loopback

Pages: [1]
1
General / Re: Collisions?
« on: April 26, 2014, 07:11:32 pm »
Well, I think I can know its size by using the getAABB() function and position using getPosition();
I will give it a shot to see what can I get done

2
General / Collisions?
« on: April 26, 2014, 01:27:03 pm »
Hi there! I'm having a bit of trouble trying to detect collisions (sprite with tmx::objects or other sprites). I know how to detect if its colliding but what I'd like to know is if f.e my character's sprite is colliding with an object at his right, left, bottom or down. How can I get it done? is there any way of doing it?

thank you very much for your help and hope I've explained my self properly

3
General / Re: Resize bounding boxes?
« on: April 25, 2014, 12:59:13 pm »
I think he meant the "detection bounding box".
Just use a radius and check if an enemy is near the player, no need of resizing anything.
Unless you want a rectangular detection area, then you can use what was said above.

A radius?? what you mean?

The Wiki subforum is not for help questions.

Bounding box of what exactly?

The bounds you get from a sprite represent the visual aspect. A good code design separates the visual part from the logical part. So in essence just use your own sf::Rect<T> object and set its size as large as you want. ;)


I'm really sorry T_T I will delete the topic as soon as possible!

4
General / Resize bounding boxes?
« on: April 25, 2014, 11:32:39 am »
Hi there! I'd like to know if there's a way to resize bounding boxes. I'm coding a game in which I want my pj's enemies to detect him in a wide area and I'd like to know how can do that.

Thanks in advance!

5
SFML projects / Re: 'Tiled' Tile-map Loader
« on: April 21, 2014, 11:29:04 am »
and How can I make those references to layers instead of making copies?

6
SFML projects / Re: 'Tiled' Tile-map Loader
« on: April 20, 2014, 07:28:12 pm »
Still having problems to add, remove objects from layers. Tried the easiest way I could. I succesfully add the object to layer but seems to be having problems when drawing (seems it does not 'update' or refresh the layer objects at the time of drawing)

7
SFML projects / Re: 'Tiled' Tile-map Loader
« on: April 18, 2014, 09:27:04 pm »
Sounds a great idea! but there's something I'm missing. If I do it that way, when it comes to the point in which I have to draw the map (in the main iteration), yeah, I do erase the object from the vector but, not from the map?

8
SFML projects / Re: 'Tiled' Tile-map Loader
« on: April 18, 2014, 06:59:39 pm »
Rather than make the map objects themselves game entities, you could use them as spawn points. For example:

for(const auto& o : layer.objects)
    m_items.push_back(std::make_unique<Collectable>(o.GetPosition()));
 

then for collision testing and destruction you don't even need to query the map:

for(auto& i : m_items)
{
    if(i.contains(player.bounds))
        i.setCollected(true);
}

m_items.erase(std::remove_if(m_items.begin(),
            m_items.end(),
            [](const Item::Ptr& p)->bool
            {
                return (p->Collected());
            }), m_items.end());
 

how would I declare "m_items"? tmx::MapObject array?  std::Vector<tmx::MapObject>?

thx in advance :)

9
SFML projects / Re: 'Tiled' Tile-map Loader
« on: April 17, 2014, 04:57:43 pm »
So... trying to do this will be usless, wont it?

if(layer->name == "Capa de Patrones 1"){ //tile layer
       
       
        for(auto tile = layer->tiles.begin(); tile != layer->tiles.end(); ++tile)
        {
           
            //collision = object.sprite->getGlobalBounds()->Intersects();
       
            if(collision){
               
                //something
           
                }   
          } 
    }
}



/* */

And what about if I wanted to do destroy an object when collision is detected?:

                for(auto layer = ml2.GetLayers().begin(); layer != ml2.GetLayers().end(); ++layer)
{
    if(layer->name == "Destructible")
       
       
    {
        for(auto object = layer->objects.begin(); object != layer->objects.end(); ++object)
        {
            collision = object->GetAABB().intersects(pj->getSprite().getGlobalBounds());
           
           
           
            if(collision){
               

                //wanna destroy object here, how could I do it?

                }
               
          }
    }

}

10
SFML projects / Re: 'Tiled' Tile-map Loader
« on: April 15, 2014, 05:58:59 pm »
Hi Everyone! I'm new here and I'm trying to code a mini game. I'm having a bit of a problem I haven't been able to resolve. Could anyone help me please?

My main problem is that I can not acces (Get information about) my tiles. I can have everything about my objects but not about my tiles. How is that? How can I fix it? What am I doing wrong? Could you guys help me please?

P.S: Attach image with code and prints.


Pages: [1]