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

Pages: 1 [2]
16
Ahhh, excellent. I was hoping it would be something simple. Than you kindly.

17
What I want to do is create an sf::Sprite that is a compilation of a number of other given sprites/textures.

e.g. If I had 4 16x16 textures, I want to create a sprite that is 64x64 that contains those 4 smaller textures in a specific pattern. Is there any way I can do this, or something similar?

18
General / Re: Is it possible to have an array/vector of Textures?
« on: March 28, 2020, 07:10:21 am »
My brain worked on this while I was sleeping. The problem seems to lie with assigning an empty texture as a different texture. I changed PlantTextures[0] = carrotTex to PlantTextures[0].loadFromFile("Location");.

I would still appreciate explaining why this didn't work so I can know  better. May avoid future problems of that ilk.

19
General / Re: Is it possible to have an array/vector of Textures?
« on: March 27, 2020, 10:33:54 pm »
You can have a vector of any movable or copiable type. A common issue, is that a std::vector may relocate its elements in memory when growing, which will result in undefined behaviour if you have sf::Sprite instances pointing to these textures.

If you have a specific issue with a vector of sf::Texture then describe it more precisely, otherwise then just experiment and see by yourself ;)

Thanks for the reply. I am having an issue with it. As an array, trying to assign a specific, or any, slot to a specific texture causes an instant crash at the point of assigment. Changing to vector creates the same problem. I can convert it to hold an array/vector of sf::Sprite with the Textures assigned, and then all is well. Any idea what the problem could be?

sf::Texture PlantTextures[plantTexNum];

int main(){
  PlantTextures[0] = carrotTex;
}
 

20
General / Is it possible to have an array/vector of Textures?
« on: March 17, 2020, 08:35:16 pm »
Is it possible to have an array/vector of Textures or do they have to be Sprites?

21
Graphics / Re: Drawing text immediately crashes
« on: February 26, 2020, 09:56:56 pm »
If it crashes on that specific line, then you should definitely be able to get some basic information with your debugger. The call stack (ie. where it crashes inside SFML) would be very helpful.

But as I said, such crashes on apparently valid code often occur because of environment issues. Are you 100% sure that the SFML release that you downloaded was compiled with the exact same compiler version as your application? If you're not sure, you can also recompile SFML yourself.

I checked and double checked everything I can think of. Compiler version is exactly the same. Can you perhaps give me some exact things to check in the build options? Maybe I'm missing something obvious.

22
Graphics / Re: Drawing text immediately crashes
« on: February 25, 2020, 08:27:18 am »
So what you say is that your code doesn't even start? From your first message I understood that it was working, and suddenly crashed on some code that you added to draw text.

Code that doesn't start (ie. nothing shows in the debugger) might be caused by a missing DLL.

My program works 100% fine, including all sfml features I have used. I reached a point where I needed to draw text on the ui and as soon as I implement renderWindow.draw(text), in any capacity, it crashes. I can modify the text, I can std::cout any and all of it's information, but as soon as I uncomment renderWindow.draw(text) it crashes as soon as it reaches that line of code.

23
Graphics / Re: Drawing text immediately crashes
« on: February 24, 2020, 09:36:18 pm »
Quote
1. Process terminated with status -1073741510 (0 minute(s), 5 second(s))
Nothing in stdout/stderr?

Quote
2. Debugger doesn't do or say anything except "finsihed with status 1"
Probably because you don't know how to use it ;)
That would be something to learn in priority.

Quote
3. ?
Typically, running a debug build that links to release SFML libraries can lead to such crashes.

Quote
Windows 7 64 bit/Codeblocks 17.12/MinGW compiler/sfml 2.5.1
Make sure that your version of MinGW exactly matches the one that SFML was compiled with (it's clearly mentioned on the download page).

1. nothing at all

2. Know how to use it, but that is all it says. The program instantly crashes when I attempt a debug and it doesn't show anything.

3 && 4. I've checked all compiler/debugger settings. Unless I'm missing something, everything is as it should be.


24
Graphics / Re: Drawing text immediately crashes
« on: February 24, 2020, 04:52:26 pm »
1. Check the console output
2. Use a debugger, to figure out at least where it crashes
3. Check your build configuration (no debug/release mix)
4. Post details about your environment (OS, compiler, version of SFML)

Thank you.

1. Process terminated with status -1073741510 (0 minute(s), 5 second(s))
2. Debugger doesn't do or say anything except "finsihed with status 1"
3. ?
4. Windows 7 64 bit/Codeblocks 17.12/MinGW compiler/sfml 2.5.1

25
Graphics / Drawing text immediately crashes
« on: February 23, 2020, 10:42:20 pm »
I just... don't understand why...

I am writing a large application and after some 500 lines of code I need to draw text to the screen for the first time. And it just won't. I opened up a new project to recreate the code doing the work to try and find the problem, but it just crashes with even the bare minimum.

int main(){
  sf::RenderWindow renderWindow(sf::VideoMode(800, 600), "Test app");
  sf::Event event;
 
  sf::Font font;
  font.loadFromFile("Image/arial.ttf");
  sf::Text test ("Hello", font);
 
  while (renderWindow.isOpen()){
    while(renderWindow.pollEvent(event)){
      if (event.type == sf::Event::Closed){
        renderWindow.close();
      }
    }
    renderWindow.clear();
    renderWindow.draw(test);

    renderWindow.display();
  }
}
 

26
General / Re: All sprites in vector are moving in the exact same pattern
« on: February 16, 2020, 06:56:46 am »
Hi Zel. I've already attempted that method, and used rand(). I really do not believe the problem to be a randomizing error. As I said, even if one of the sprites is given specific instructions to got to a specific location, no random numbers involved, ALL the sprites follow in the same direction, despite their own instructions to flit about randomly.

27
General / Re: All sprites in vector are moving in the exact same pattern
« on: February 15, 2020, 06:56:21 am »
Hmm. The seeding is done at object creation. I have no idea how I would go about reseeding with each iteration.

class AnimalObj{
private:
    //std::random_device rd; Commented out because it returns error "use of deleted function that I can't fix
    std::mt19937 mt;
    std::uniform_int_distribution<int> dist;
public:
    AnimalObj : mt(), dist(0, 4);
 

28
General / All sprites in vector are moving in the exact same pattern
« on: February 14, 2020, 10:45:51 pm »
I have been bashing my head against the wall for the last 4 days trying to figure out where in the name of holy pasta salad I'm going wrong here. I cannot begin to vent my frustration.

class AnimalObj{
    sf::Sprite animalSprite;
    void MoveAnimal(int direction){
        //Moves in the appropriate direction
        if (direction == 1){
            //Go up
            if (animalSprite.getPosition().y - animalMoveDist >= 0){
                animalSprite.move(0.0, -animalMoveDist);
                AnimateAnimal(1, 1);
                previousMove = 1;
            }
        }else if (direction == 3){
            //Go down
            if (animalSprite.getPosition().y + animalMoveDist <= 800){
                animalSprite.move(0.0, animalMoveDist);
                AnimateAnimal(3, 3);
                previousMove = 3;
            }
        }else if (direction == 2){
            //Go right
            if (animalSprite.getPosition().x + animalMoveDist <= 1000){
                animalSprite.move(animalMoveDist, 0.0);
                AnimateAnimal(2, 2);
                previousMove = 2;
            }
        }else if (direction == 4){
            //Go left
            if (animalSprite.getPosition().x - animalMoveDist >= 0){
                animalSprite.move(-animalMoveDist, 0.0);
                AnimateAnimal(4, 4);
                previousMove = 4;
            }
        }else{
            AnimateAnimal(0, 0);
            previousMove = 0;
        }
    }

std::vector<Chicken> animalArr;
int main{
    AnimalObj NewChicken;
    NewAnimal.animalSprite.setTexture(henTex);
    NewAnimal.animalSprite.setPosition(400, 400);

    AnimalObj new_chicken;
    NewAnimal.animalSprite.setTexture(roosterTex);
    animalArr.push_back(new_chicken);

    while (renderWindow.isOpen()){
        for(int animal = 0; animal < animalArr.size(); animal++){
            animalArr[animal].MoveAnimal(RandomDirection()); //RandomDirection returns a random direction
            renderWindow.draw(animalArr[animal].animalSprite);
        }
    }
}
 

I hope I didn't post too much code. I purged as much as I could that I thought was surplus/unnecessary.

The problem is that each sprite will move in the same direction, regardless of where they are going. If one goes left, all sprites go left. If it goes right... all of them go right. At first I thought it was an issue with my random number generation, but I programmed in instructions to move to a particular position for one of the sprites, and all sprites would then move in the appropriate direction, regardless of where they are spawned. Once the first sprite arrives at location, it stops moving. I've pretty much narrowed down the error to the MoveAnimal function that I posted above, but I have no idea why it's doing that. It seems that the .move() function is causing all sprites in the vector to move in the same direction despite them being told to move randomly I checked, the appropriate MoveAnimal are receiving instructions to move randomly, but are ignoring them in favor of following the direction of the first sprite until it arrives at location, then all the rest continue to move in sync.

I don't know if I'm just being incredibly dense here, but any help will be greatly appreciated. Seriously. I'd like to stop banging my head on the table, so if anyone can help me put an end to that, that would be great.

Pages: 1 [2]
anything