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

Pages: [1]
1
Make a resource holder class now. Global SFML resources will more often than not lead to crashes due to undefined destruction order.

Thor has an excellent resource holder class and the SFML Game Development book has some code for one as well.

what would a function in main that uses the Game Development example look like. Would it look something like this?

ResourceHolder exampleTexture;

sf::Texture cake;

exampleTexutre.load(cake, directory)


2
Graphics / How can i slow down the rate my projectiles fire.
« on: April 23, 2017, 11:20:52 pm »
I have a function that draws and moves a projectile automatically based on if a certian monsters are in range or not. The problem I am having is that when the monsters in range it draws it so many times its almost like a line. I have been at this for so many hours im about to throw in the towel. I have tried using the clock but its just not working out.

This function checks if the monster is in range and pushes back a vector of bullets.

 for (int i = 0; i < mymonsters.size(); i++)
        {
                for (int k = 0; k < myicetower.size(); k++)
                {
                        if (mymonsters[i].checkCollision(myicetower[k].getRadius(), myicetower[k].getPositionX(), myicetower[k].getPositionY()))
                        {

                                //      BulletClass bulletshot;
                                bulletshot.setPosition(myicetower[k].getPositionX(), myicetower[k].getPositionY());
                                bullet.push_back(bulletshot);
                        }
                }
        }

 

This function draws it to the window. But it draw it so many times its ridiculous

sf::Vector2f fire(1.f, 1.f);
        for (int i = 0; i < bullet.size(); i++)
        {
                //if(function.checkCollision(myicetower, mymonsters))
                {
                        bullet[i].fire(fire);
                        bullet[i].draw(window);
                }
        }
       
        window.display();
}

Any help would be great.

3
Can i create two shapes with sfml and draw them together all in the same class?


void TowerA::draw(sf::RenderWindow & window)
{
   window.draw(sprite)
   window.draw(circle)
   window.draw(circle2)
}
   

4
Graphics / Trying to create a tilemap in a class.
« on: April 16, 2017, 08:11:38 pm »
In my constructor I have my TileMap object definition. But other functions of the class cant use the map. I tried defining map in the header but it really dosent work like that. I have a render function that does all my rendering like window.clear and window.draw(map). I also have a processEvents that processes all the events. I cant pass it to the function as a parameter either.

        window.create(sf::VideoMode(528, 256), "Tilemap");
                // define the level with an array of tile indices
        const int level[] =
        {
                        4, 4, 4,  4,  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
                        4, 4, 4,  4,  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
                        4, 4, 4,  4,  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
                        12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
                        4, 4, 4,  4,  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
                        4, 4, 4,  4,  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
                        4, 4, 4,  4,  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
                        4, 4, 4,  4,  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
                };

                //create the tilemap from the level definition
        TileMap map;
        if (!map.load("tileset.png", sf::Vector2u(33, 33), level, 16, 8))
                        std::cout << "Cant upload map" << std::endl;
}

5
Window / Re: resizing a window by dragging it and using sf::view
« on: April 16, 2017, 05:25:15 am »
Well I wanted to resize the window and view because i have an event that moves sprites. Once the window is stretched i lose my pixels. I figured view had a function for this, however I figure I might be able to divide by the window size.x.y making the aspect ratio always similar. I did something like this in glut and ill probably try it here.

6
Window / resizing a window by dragging it and using sf::view
« on: April 16, 2017, 01:46:17 am »
I am trying to have my map stretch when i either full screen it using the box or slowly drag the borders using sf view. I have tried various methods doing that however they all failed. The window resizes but the map stays the same size.  Here we have

 
case sf::Event::Resized:
        if (event.type == sf::Event::Resized)
        {
                sf::FloatRect visibleArea(0, 0, event.size.width, event.size.height);
                window.setView(sf::View(visibleArea));
                window.draw(map);
                /*sf::View view(sf::FloatRect(0, 0, 1000, 600));                               
                window.create(sf::VideoMode(event.size.width, event.size.height, 32),"Tilemap");
                view.setSize(event.size.width, event.size.height);
                window.setView(view);
                window.draw(map);*/

                std::cout << "Resized" << std::endl;
        }
        break;

7
General / Fallens tmxlite question.
« on: April 06, 2017, 03:14:09 am »
I am trying to use tmxlite to parse a tmx file from tiled. Has anyone used his parser before. He has a visual studio project included in his github but compiling to test it i get the error /user/....../x64/bin/ReleaseStatic/libtmxlite-slib. Cannot find path. I didn't see such a lib included in his zip file. Do i need to make this myself....

Pages: [1]