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

Pages: [1]
1
General / Re: collision detection
« on: October 16, 2015, 05:32:29 pm »
Fixed it, forgot to put the player updating function under the active event poll, too much coffee isn't good for my health

2
General / Re: collision detection
« on: October 16, 2015, 03:02:21 pm »
oh thanks for the notice, i fixed it but the problem seems to persist, any other clues?
I do get the idea behind collision detection but trying to do it with an array is difficult for me

3
General / collision detection
« on: October 16, 2015, 02:21:45 pm »
Hi, when i run my program, the controllable rectangle is always blue although i want it to be red when it collides with tiles with the value 1.

 player.Update();
    for(int i = 0; i < colMap.size(); i++)
{
        for(int j = 0; j < colMap[i].size(); j++)
        {
            if(colMap[i][j] == 1)
            {
            int bottom, top, left, right;
            bottom = i * 40 + 40;
            top = i * 40;
            right = j * 40 + 40;
            left = j * 40;

                if(player.right < left || player.left > right || player.top > bottom || player.bottom < top)
                {
                    player.rect.setFillColor(sf::Color::Blue);
                }
                else
                {
                    player.rect.setFillColor(sf::Color::Red);
                    break;
                }
            }

        }
}

Stuff that might help you further:
(click to show/hide)

(click to show/hide)

(click to show/hide)

(click to show/hide)

thanks

Pages: [1]