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

Pages: [1]
1
General / Re: Graphic is bugging because of sf::Clock
« on: October 19, 2013, 02:30:43 pm »
Well that's hardly complete and minimal code (not to mention extremely redundant code), but my guess would be that your character moves enough pixels per frame that there simply is no frame during which he intersects the rectangle yet is still above it.

You need to design some collision logic that doesn't rely on frames taking specific lengths of time.  The simplest approach I know of is looking at where the player is and "should" move to (given player input, gravity, momentum, delta time, etc), and see if there are any obstacles between the two points.
Ok, thanks for the answer. But i have no idea how to realize this, can you give me any tips or something?

2
General / Re: Graphic is bugging because of sf::Clock
« on: October 19, 2013, 11:39:37 am »
If you're asking why your player falls through the floor sometimes (just guessing), that probably has more to do with how you test for collisions than anything else, so you should probably show us that code.

Hi but with the max. framerate my sprite dont fall through the floor, but here is the code:

                if(playerrect.intersects(rect)){
                if(playerrect.top - playerrect.height < rsprite.getPosition().y && playerrect.left + playerrect.width > rect.left + 1 && playerrect.left < rect.left + rect.width - 1 && playerrect.top + playerrect.height < rect.top + rect.height + 1)
                        collisiontop = true;
                    currentcollision = true;
        }else
                collisiontop = false;

        if(playerrect.intersects(rect)){
                if(psprite.getPosition().y > rsprite.getPosition().y)
                        collisionbottom = true;
        }else
                collisionbottom = false;       
       
        if(playerrect.intersects(rect)){
                if(psprite.getPosition().x < rsprite.getPosition().x)
                        collisionleft = true;
        }else
                collisionleft = false;

        if(playerrect.intersects(rect)){
                if(psprite.getPosition().x > rsprite.getPosition().x)
                        collisionright = true;
        }else
                collisionright = false;



        if(collisiontop == true){
                Game::jumpable = true;
                Game::collisiontop = true;
        }

        if(collisionleft == true && collisiontop == false){
                Game::collisionleft = true;    
        }

        if(collisionright == true && collisiontop == false){
                Game::collisionright = true;
        }

        if(collisionbottom == true){
        Game::collisionbottom = true;          
        }

        if(Game::collisiontop == true && collisiontop == false){
                currentcollision = false;
        }

        if(posY < rect.top - 250 && currentcollision == true){
                Game::up = false;
                currentcollision = false;
        }

3
General / Graphic is bugging because of sf::Clock
« on: October 14, 2013, 10:28:49 pm »
Hello Community,

First apology if this isnt the right position for this question. Now to my problem at the beginning i've moved a sprite only by move and a x.xx number. Now i try to move it with sf::Clock to not be bound at the framerate. But then sometimes the sprite moves through the texture. My OS is Windows 7 home premium. Here is a little snippet of the code:

               
window.setFramerateLimit(60);
sf::Clock clock;       
while (window.isOpen())
        {              

                sf::Time elapsedTime = clock.restart();
                speed = elapsedTime.asSeconds() * Game::speed;
                sprite.move(speed, gravity);
                //checking for collisions etc.
                }

For more code just ask.

P.S: Sorry for the bad english.

Pages: [1]
anything