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

Pages: [1]
1
Graphics / particle system inheritance
« on: May 03, 2020, 12:44:49 pm »
Hi, i'm creating particle system and i want to have possibility to choose what kind of object will be showing on the screen (like just points from primitive types or circle shapes). I have one class in which all parameters are stored (ParticleSettings), but without those entities like points, or circle shapes. I thought that i may create pure virtual class (ParticlesInterface) as a base class, and its derived classes like ParticlesVertex, or ParticlesCircles for storing those drawable objects. It is something like that:

class ParticlesInterface
{
protected:
        std::vector<ParticleSettings>   m_particleAttributes;  

public:
        ParticlesInterface(long int amount = 100, sf::Vector2f position = { 0.0,0.0 });
        const std::vector<ParticleSettings>& getParticleAttributes() { return m_particleAttributes; }
...
}
 

and :
class ParticlesVertex : public ParticlesInterface
{
private:                                                       
        std::vector<sf::Vertex>                 m_particleVertex;
public:
        ParticlesVertex(long int amount = 100, sf::Vector2f position = { 0.0,0.0 });
        std::vector<sf::Vertex>& getParticleVertex() { return m_particleVertex; }
...
}
 

So... I know that i do not have access to getParticleVertex() method by using polimorphism. And I really want to have that access. I want to ask if there is any better solution for that. I have really bad times with decide how to connect all that together. I mean i was thinking also about using template classes, and different types of relations. I thought that this idea will be okay, but i'm really need to have access to that method in that option. Can you please help me how it should be done? I want to know what is the best approach here, and also if there is any good answer to that problem i have if i decide to make that this way that i show you above.

2
General / particle system sorting data
« on: April 18, 2020, 05:38:13 pm »
Hello,
I'm creating particle system with possibility to create force waves which can push partcles away when colliding.  Particles are moving away from the point of my mouse click, and force waves are expanding as long as they are visible on the screen (after that they are just erased). I want to improve performance of my code so i am thinking about sorting particles in some way. Problem is that i don;t know how to sort them. For now i am checking every single particle if it is colliding with force wave (there may be more than one of it) and i really don't want to do that. Also i want to add that checking is executed in every main loop. So it would be awasome if it could be stopped after reach some point. Also i'm wondering if there is some great container for particles. Currently i am using vector of unique pointers of particle objects. If anyone can recommended something better i would really appreciate it.

3
Graphics / ParticlesSystem efficient
« on: April 12, 2020, 12:11:57 pm »
Hello!
I'm working on particle system that have some predefined features like creating a force wave to push particles floating on the screen. It causes change of direction, speed, etc. The problem is that with every force wave i have to iterate through every particle on the screen if it is in range of force wave. Because of that i have some huge fps drops.  Do you have some optimization idea? I really want to have a lot particles on the screen ;d.

4
SFML projects / Re: SAT collision algorithm
« on: March 12, 2020, 10:59:30 am »
Well, that's not exactly my idea. I saw video with something similar to that while searching for information about SAT. It was stunning for me how simply and cool was that. So i take it as inspiration and code it by myself. Sorry for not to mention that from begining. Anyway thanks for respond. And beside that what i was looking for was some opinions about structure of the code. Not sure though if it's complex enough to review this code in that way.

5
SFML projects / SAT collision algorithm
« on: March 10, 2020, 12:30:50 pm »
Hi there,
i made program with collision based on seperate axis theorem. I will be very gratefull for any feedback about that little project:
https://github.com/TMalicki/Seperate-algorithm-theorem-with-MTV-

Looking for some advice how things could be done.

6
General / Re: STL List object with sprite
« on: December 21, 2019, 02:24:02 pm »
Thanks for all your help. Now i think everything is clear :)

7
General / Re: STL List object with sprite
« on: December 18, 2019, 04:13:34 pm »
Not sure if understand, i mean... i have condition that i<chestAmount, so it's not like i go outside of list. And for choosing list, i had white box problem, because after one of boxes where open erase method was called which causes memory relocation. From what i read in moments like that it's better to use list or vector with inteligent pointer, or am i wrong in your opinion?

8
General / Re: STL List object with sprite
« on: December 17, 2019, 09:18:57 am »
Yeah.. i'm okay with that. I'm not saying that i don't know your version of facing that problem, but i'm rather wondering what's the difference? From what i see only thing that your version is different from mine is that yours miss advance method, of course beside optimalisation things. So how that should that solve my problem? And yeah, clearly i don;t know list very well, as i said before it used to be vector, but problem rose up before me and i find that people suggest to use list.

9
General / STL List object with sprite
« on: December 16, 2019, 09:30:57 pm »
Hello, when i run game which i'm making i get error : "Cannot dereference end list iterator". I search for something that could help me but without any breakthroughs. So maybe you can help me. So... i have class - Chests, which objects stores sprite. objects of that class are stored in STL List container. Error which i refered to before appears after that line of code:

for (int i = 0; i < chestAmount; i++)
        {
                advance(chestIterator, i);     
                chestIterator->DrawChests();
        }
 

chestIterator is type -> list<Chests>iterator

Inside DrawChests() method i have just:

void Chests::DrawChests()
   {
           TChests.loadFromFile("images/chest.png");
           SChests.setTexture(TChests);
   }

 


And yeah... i think thats it. Propably something stupid (i wish) since thats my first time using list container (before that was vector but i;ve had problem with reallocating memory. Thanks for any ideas.

10
General / Re: Vectors of texture and sprite
« on: December 12, 2019, 12:03:47 pm »
Thanks for respond. Good to know.

11
General / Vectors of texture and sprite
« on: December 10, 2019, 08:40:50 pm »
Hello, i have a function which send by reference, textures and sprites to vectors.  First time i made this function i had a problem. Generally speaking by tapping "i", sprites that are inside my vector of sprites should be displayed. What i get is first sprite (usually) displayed correctly and rest of them (again... usually) are white squares. After that by tapping "i" again sprites are cleared, and than again displayed by pressing the same button. But after that second time, they are displaying correctly. Below is fragment of my code:

        vector<Items*> YourItems = hero->openBackpack();

                sf::Texture tempTItems;
                sf::Sprite tempSItems;

         for (int i = 0; i < YourItems.size(); i++)
                {
                        if (!(THeroItems.size() == YourItems.size()))
                        {
                                THeroItems.push_back(tempTItems);
                                SHeroItems.push_back(tempSItems);
                        }
                        YourItems[i]->getLook(THeroItems[i], SHeroItems[i]);

                }
 

Then i remake this function. I've come up (a little randomly) with something like that:

                if (!(THeroItems.size() == YourItems.size()))
                {
                        int tempSize = THeroItems.size();
                        for (int i = 0; i < YourItems.size() - tempSize; i++)
                        {
                                THeroItems.push_back(tempTItems);
                                SHeroItems.push_back(tempSItems);
                        }
                }
               
                for (int i = 0; i < YourItems.size(); i++)
                {
                        YourItems[i]->getLook(THeroItems[i], SHeroItems[i]);
                }
 

And... that works... After some debugging i found out that pushing back vector is changing elements of sprite vector. Because of that sprites are pointing some rubbish things. And i don't have any clue why. I will be very gratefull for help. I'm not sure if amount of code provided is enaugh. If not, than i will paste more. Please help! ;)

Pages: [1]
anything