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

Pages: [1]
1
General / Re: Taking a Screenshot (Issue)
« on: March 31, 2016, 07:55:50 pm »
Hello eXpl0it3r, I'm not sure I follow how your instructions with the logic.

And embarrassingly I don't understand what you mean by render texture, I'm pretty new to SFML

2
General / Re: Taking a Screenshot (Issue)
« on: March 31, 2016, 12:14:52 pm »
Hey Cire, this is true. My only problem is that Generate_Item needs to exist, If I just left the code within generate item out in the loop it's in it would generate an items nonstop and my whole code wouldnt work

I can't figure out how to both have a continual one at a time weapon generation system while being able to take screenshots

3
General / Re: Taking a Screenshot (Issue)
« on: March 31, 2016, 04:16:36 am »
Hello eXpl0it3r, thank you for replying so quickly!

I want the screenshot to be taken when the user presses 'z' and I want it to take a screenshot of the currently generated image, everything on screen aside from "text4" and "text"

I'm not entirely sure I understand the steps I need to take,

my screenshots come out fine, but I can't get the code to take a screenshot of the current weapon, it's always the next weapon, I want to get it to instantly save the current weapon as a screenshot

I can provide the entire source if nececarry, but I am very confused and have tried shuffling the code around numerous ways for the last two days, the only difference is the kind of errors I run into.

4
General / Taking a Screenshot (Issue)
« on: March 31, 2016, 12:31:55 am »
Hello, I am using SFML to create a random weapon generator, for the time being it just makes wooden planks, it works pretty well and I am very happy with how easy it is to do the basic stuff I'm doing with SFML, my only issue is screenshots, I've tried my best to make this work but to no avail.

When the user presses the 'Z' key, a variable called Take_Screenshot becomes true and then during the generation of the weapon it saves the screenshot. The problem is that when you press 'Z' the weapon has already been generated. So it instead saves a screenshot for the next weapon instead because only when you press enter does the screenshot code get run.

So I've tried moving the screenshot code outside of the Generate_Item, but the problem is that the screen gets cleared before then, I've tried a great deal of things and none of them resulted in an instant screenshot, I feel like perhaps it's just a case of logic and I'm missing something but I can't for the life of me figure it out,

Any help would be appreciated!

    while (window.isOpen())
    {
        sf::Event event;

        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();

            if (event.type == sf::Event::KeyPressed)
            {
                if (event.key.code == sf::Keyboard::Return)
                {
                    Generate_Item = 1;
                }
                else if(event.key.code == sf::Keyboard::Z)
                {
                    Take_ScreenShot = 1;
                }
            }
        }

        if(Generate_Item == 1)
        {
            Generate_Item = 0;
            window.clear(sf::Color::Black);

            GenerateMaterial();
            window.draw(MaterialSprite);

            int Condition_Amount = 5;
            Condition_Amount = rand()%Condition_Amount;

            if(Condition_Amount == 0)
                Condition_Amount = 5;
            else
                Condition_Amount = 4;

            Condition_Amount = rand()%Condition_Amount;

            if(Condition_Amount >= 1)
            {
                while(Condition_Amount != 0)
                {
                    Condition_Amount --;
                    GenerateCondition();
                    window.draw(ConditionSprite);
                }
            }

            text.setString("        PROCEDURAL WEAPON GENERATION!");
            text.setCharacterSize(25);

            text1.setString(" (" + Weapon_Name + ")");
            text1.setPosition(100, 85);
            text1.setCharacterSize(15);

            if(Weapon_Dura == 0)
                text2.setString(" (" + Wep_Damage + " DMG / BROKEN / $" + Wep_Value + ")");
            else
                text2.setString(" (" + Wep_Damage + " DMG / " + Wep_Dura + " DURA / $" + Wep_Value + ")");

            text2.setPosition(140, 105);
            text2.setCharacterSize(15);

            text3.setString(Weapon_Description);
            text3.setPosition(120, 125);
            text3.setCharacterSize(15);

             text4.setString("Press enter to generate a new weapon\nPress Z to save weapon as image");
            text4.setPosition(150, 355);
            text4.setCharacterSize(15);

            window.draw(text1);
            window.draw(text2);
            window.draw(text3);

            if(Take_ScreenShot == 1)
            {
                sf::Image screenshot = window.capture();
                screenshot.saveToFile("screenshots/" + Weapon_Name + ".png");
            }

            window.draw(text4);
            window.draw(text);
            window.display();
        }
    }

5
Thanks for all the responses, this is a very smart and active community!

I went and looked up clipping masks so I understand what they, wasn't sure how exactly they work but I guess mortal got the ball rolling and Hapax has just answered my last question!

Thanks a bunch everyone!

6
@Noct, it's not a bad idea but I am dead set on procedurally generated graphics

@eXpl0it3r, I recall clipping masks in photoshop, I am not to sure how I'll go about it but I'm sure I'll figure it out.

My current issue is down to something I don't quite understand, it's not an SFML issue as far as I can tell, it's just because I'm quite new to graphical programming.

but I'm putting the textures over a rectangle, and that's fine, but is it possible to instead of drawing a rectangle, drawing a shape that looks like a baseball bat or a sword, and then putting the textures over that?

I've seen how 3D models work, where you have the model and then the texture, but of course that's probably different in 2D graphical development.

Thanks for the help so far by the way guys, I'm gutted I never came to SFML sooner, it's well made and easy to work with and the few little projects I've done in my first week have been mindblowing to me!

7
Thank you, I thought as much and have managed to get it working with two different overlaying textures.



Though another issue I'm having trouble understanding is, how can instead of using a rectangle shape, have the textures placed over a baseball bat shape?

8
Hello,

To start, I'm a game developer who has recently come over to sfml and it's a breath of fresh air and I've enjoyed learning it, but my problem is one of the features I'll need to code for my upcomming game requires me to have multi layered textures.

What I need is for an inventory system, items are randomly created and can look different so for example:
"bloodied oak baseball bat" - "scratched steel baseball bat" would both look different, both would use a baseball bat blank sprite, then the first would use the oak texture, the problem is bloodied is an extra condition, I would need to layer it on top of the oak texture. Perhaps using a sprite sheet with some transparency and then having a bloodied texture on the sheet that is blood splatters among transparent space, but how do I layer that on top of the other texture? do I create a second sprite and place it directly above the existing one?

The same would apply for the steel bat, it would use a steel texture then place transparent scratches on top of it, I'm fairly new to graphical programming in general but I'm getting the hang of it, I may be completely off but if anyone has a clue what I should do, I'm all ears! :)

Thanks a bunch for reading

Pages: [1]
anything