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

Author Topic: I need help with colision map  (Read 1142 times)

0 Members and 1 Guest are viewing this topic.

Ladislav

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
I need help with colision map
« on: April 10, 2019, 12:36:08 am »
so I need some help seriously and as quickly as possible (deadline this Friday)

 I have created a collision map that doesn't work right
I need some serious help, I'm confused, and tried like 10 different approaches idk what to do anymore


sf::Vector2f pp = Player.GetPlayerPos();
         PtpY = static_cast<int>(pp.y/40+1);
         PtpX = static_cast<int>(pp.x/40+1);
         float Ptop = pp.y;
         float  Pbot =pp.y+Player.PlayerSprite.getGlobalBounds().height ;
         float  Pleft = pp.x;
         float Pright = pp.x + Player.PlayerSprite.getGlobalBounds().width;

int i, j;
            for ( i =1 ; i <= 20; i++)
            {
               for (j = 1; j <=20; j++)
               {
                  float top = static_cast<float>(PtpX);
                  float bot = static_cast<float>(PtpX*20);
                  float right = static_cast<float>(PtpY*20);;
                  float left = static_cast<float>(PtpY);;
                  int mk =( PtpX * 20) + PtpY;
                 
                     




                     if (Ptop > top)Player.PlayerSprite.setPosition(pp.x,pp.y--);
                     else if (Pbot <bot)Player.PlayerSprite.setPosition(pp.x, pp.y++);
                     else if (Pleft >left)Player.PlayerSprite.setPosition(pp.x--, pp.y);
                     else if (Pright <right)Player.PlayerSprite.setPosition(pp.x++, pp.y);

               }
//////////////////////////////////////////////////////////////////////////
int Overlay_Centermap[] = {
       25,25,25,25,10,10,10,10,10,52,10,10,10,10,10,10,25,25,25,25,
       25,25,25,25,25,25,10,10,10,10,10,10,10,10,10,10,25,25,25,25,
       25,25,25,25,25,25,10,10,10,10,10,10,10,10,10,10,25,25,25,25,
       25,25,25,25,10,10,10,10,10,10,10,10,10,10,10,10,10,25,25,25,
       25,25,25,25,10,25,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
       25,25,25,25,10,25,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
       10,10,10,10,10,25,10,10,10,10,10,10,10,10,10,10,10,10,10,50,
       25,25,25,25,25,25,10,10,10,10,10,10,10,10,25,25,10,25,10,10,
       51,10,10,10,10,10,10,10,10,10,10,10,10,10,25,25,10,25,10,10,
       51,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,25,10,10,
       10,10,10,10,10,10,10,10,10,10,10,10,25,25,25,25,25,25,10,10,
       10,10,10,25,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
       10,10,10,25,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
       10,10,25,25,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
       10,25,25,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
       25,25,10,10,10,10,10,10,10,10,10,25,25,25,25,11,10,10,10,10,
       25,10,10,10,10,15+S,10,10,15+S,10,10,25,25,25,25,10,10,10,10,10,
       25,10,10,10,10,13+S,10,10,13+S,10,10,25,25,25,25,10,10,10,10,10,
       47,47,47,47,47,47,10,10,47,47,47,47,47,47,47,47,47,47,47,47,
       10,10,10,10,10,10,53,53,10,10,10,10,10,10,10,10,10,10,10,10,
    };
« Last Edit: April 10, 2019, 07:51:08 am by Laurent »

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: I need help with colision map
« Reply #1 on: April 10, 2019, 12:24:00 pm »
You don't seem to be using the variables i and j.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*