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

Pages: [1]
1
General / Is it an inefficient way of making collisions?
« on: September 07, 2014, 06:18:49 pm »
Let's say we have 2 rectangle shapes: shape1 and shape2, i want to test the collision between them and do different things when each side of shape1 touch the other side of shape2.

i was thinking in an easy way of doing it, and ended with something like this:

    sf::RectangleShape shape;
        sf::RectangleShape shape2;
        shape1.setSize(Vector2f(50,100));
        shape2.setSize(Vector2f(500,50));
        (. . .)

        in the game loop:

        //shapes bottom
                s1b = shape1.getPosition().y + 100;
                s2b = shape2.getPosition().y + 50;
                //shapes top
                s1t = shape1.getPosition().y;
                s2t = shape2.getPosition().y;
                //shapes right
                s1r = shape1.getPosition().x + 50;
                s2r = shape2.getPosition().x + 500;
                //shapes left
                s1l = shape1.getPosition().x;
                s2l = shape2.getPosition().x;

                //shapes are coliding?
                if(s1l <= s2r && s1r >= s2l && s1t <= s2b && s1b >= s2t){isColiding = true;}else{isColiding = false;}

                if(isColiding)
                {
                        if(s1b <= s2t + 10)//is shape1 on top of shape2?
                        {
                                spd.y = 0;
                                shape1.setPosition(shape1.getPosition().x, shape2.getPosition().y - 100);
                                std::cout<<"is on top" << std::endl;
                        }
                        else if(s1t >= s2b - 10)//is shape1 top hitting shape2 bot?
                        {
                                spd.y = speed;
                                shape1.setPosition(shape1.getPosition().x, shape2.getPosition().y + 50);
                                std::cout<<"is touching bottom" << std::endl;
                        }
                        else if(s1l >= s2r - 10)//does shape1 left collide with shape2 right?
                        {
                                spd.x = 0;
                                shape1.setPosition(shape2.getPosition().x + shape2.getSize().x, shape.getPosition().y);
                                std::cout<<"is touching right" << std::endl;
                        }
                        else if(s1r <= s2l + 10)//does shape1 right collide with shape2 left?
                        {
                                spd.x = 0;
                                shape1.setPosition(shape2.getPosition().x - shape1.getSize().x, shape1.getPosition().y);
                                std::cout<<"is touching left" << std::endl;
                        }

                }

It works, but i think that maybe this is really inefficient, because if shape1 move in a really fast speed for some reason (fps drops,etc), it will most probably miss the collisions. since it depends in a tiny 10 pixels collision check system, won't it?

2
General / Help on Game Peformance
« on: September 02, 2014, 09:54:25 pm »
Hello!

I'm relatively new in c++ and SFML, last week i've studied a lot and managed to make this simple megaman-like platformer engine, but my friends are having a little issue with the FPS and the game doesn't have almost nothing, just animations, gravity and collisions. The game is set to run at 60fps, but my friend is getting 25~30 fps at his pc, i get 63 fps in mine, but the game is so simple that i can't understand why would someone get 30fps...

the game have only 2 threads at this stage, one for animations, and other for the rest. is this too few for a game?

I've uploaded the source code (with VS2012 build), there's an .exe at the release folder too, so you can test it. would you guys be kind to take a look and give me some advices?

commands are, for now: arrows to move, space to jump, "A" to shoot, "F1" to see the coordinates grid and player hitbox.

https://dl.dropboxusercontent.com/u/9264421/SFML.zip

3
General / Use SFML_STATIC with /MT runtime lib linking
« on: August 27, 2014, 08:33:47 pm »
Hello!
I'm making a megaman-like platformer game. It's all doing fine, i have sprites animations, collisions and projectiles and coordinates.
I'm really enjoying SFML!

I'm using visual studio 2012 and everything looks fine...but...

Well, problem is, that when i send the game for my friends to test, they usually miss the MSVCP110.dll because they don't have the C++ redistributable package.

I would like to know if there is any way that i can include the dll to my ".EXE" with "Multi-Thread DLL (/MT)", and still use the static dll's from SFML. i have conflicts when i try to build with the static dll, but it runs fine without it.

4
General / VS2010 Crash with SFML2.1
« on: August 19, 2014, 01:59:30 pm »
Hi,
I'm using SFML2.1 32bit for VS2010 version (redownloaded it 2 times to make sure).
I've tried both Static and Dinamic versions of the libs.
I've correctly configured it on VS2010 and have no clue of what is happening.
I've recorded an video of the crash to show it.

The program only crashes when i'm writing codes.
I'm also having an "Out of date" warning even on my first build of the project.
Anyone?

Pages: [1]