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

Pages: [1]
1
Graphics / Re: Request: Weaponized Text Wrapping Example
« on: May 28, 2016, 07:38:21 pm »
I can't put this in the main loop because the game crashes
you can, actually sfml provides two ways to handle the input, you already tried one way but there is another way to do it. from what you are trying to achieve is better to consider real time input

I think we had a miscommunication, it works fine when I have it as just a key press, but I want it to automatically wrap the text. If I move this code out of key-press and into the main loops so it evaluates the string on every loop, the game crashes.

2
Graphics / Re: Request: Weaponized Text Wrapping Example
« on: May 28, 2016, 04:19:56 am »
OK, I have this:

                                if (event.key.code == sf::Keyboard::F4)
                                {
                                        // Lets try this instead
                                                const auto containerWidth = textline1.getCharacterSize();
                                                for (auto i = 0u; i < textline1.getString().getSize(); ++i)
                                                {
                                                        if (textline1.findCharacterPos(i).x >= containerWidth)
                                                        {
                                                                gameGlobals.sceneText.insert(i, " \n");
                                                                //textline1.setString(gameGlobals.sceneText);
                                                        }
                                                }
                                }

If I un-comment the //textline1.setString(...); the game crashes when I press F4, but I have that exact same line in my main game loop and it works fine. When I press F4, the text box clears itself and has nothing inside of it... Not sure what I'm doing wrong :/

Edit: Update! I see why it's "crashing". I put in a break; after the textline1.setString(...); and it moved the ENTIRE text line down one spacing... o.o So basically it was just inserting newlines until the end of eternity...

Also, a newline is actually farther down than I want it... any way to scootch/change that spacing? :3

---

New New Update!

I did this:

const auto containerWidth = 750;

and it wraps properly now, but it cuts off the words mid-letter, any way to stop that from happening?

---

New New New Update ;_;

I can't put this in the main loop because the game crashes

3
Graphics / Re: Request: Weaponized Text Wrapping Example
« on: May 28, 2016, 03:46:23 am »
Can I ask what <string> and <iostream> are for?

4
Graphics / Re: Request: Weaponized Text Wrapping Example
« on: May 24, 2016, 12:48:15 am »
The debugger kinda flips out about missing syswow files. The code does nothing at all, I don't see any changes happening to my text displayed on screen :/

5
Graphics / Re: Request: Weaponized Text Wrapping Example
« on: May 23, 2016, 10:03:15 am »
Also tried this way with no luck:

                                        // Let's wrap the text
                                                        sf::String str("blahblah");

                                                        textline1.setString(str);

                                                        float width = 30.f;
                                        // Wrap the text
                                                        for (auto i = 0u; i < str.getSize(); ++i)
                                                        {
                                                                auto position = textline1.findCharacterPos(i);
                                                                if (position.x > width)
                                                                {
                                                                        //insert a newline in string at i;
                                                                        str.insert(i, "\n");
                                                                        textline1.setString(str);
                                                                        break;
                                                                }
                                                        }

6
Graphics / Re: Request: Weaponized Text Wrapping Example
« on: May 23, 2016, 02:26:45 am »
I'm still having a bit of trouble, here is the code:

                                if (event.key.code == sf::Keyboard::F4)
                                {
                                        // Lets try this instead
                                        const int containerWidth = 20;
                                        for (auto i = 0u; i < textline1.getString().getSize(); ++i)
                                        {
                                                if (textline1.findCharacterPos(i).x > containerWidth)
                                                {
                                                        auto str = textline1.getString();
                                                        str.insert(i, "\n");
                                                        textline1.setString(str);
                                                        break;
                                                }
                                        }
                                }

I had to change size to getSize (I hope that's ok) and I changed text to textline1 (which is my sf::text name). The game "crashes" if I press F4 because I think it's not evaluating anything and getting stuck in the FOR loop? I threw break; in there to see if I could just get one line break maybe but it doesn't affect the text in any way. In my game loop I have it refresh the text string:

      textline1.setString(gameGlobals.sceneText);

As you can see the actual char string is a global char "std::string sceneText;". Should I be passing that to this function instead? VS doesn't seem to like me putting a global string in the place of the sf::string... I hope I made sense :P

Edit: Oh I also made i = 0u because the compiler was whining about signage so I put in the 'u'.

7
Graphics / Re: Letterbox effect using a view - not on position 0,0
« on: May 21, 2016, 05:30:28 am »
Yeah that looks very nice :D

8
Graphics / Re: Letterbox effect using a view - not on position 0,0
« on: May 21, 2016, 03:25:06 am »
        // Create the main window w/ Viewscope Function
        float resX = 800.f;
        float resY = 600.f;
        sf::RenderWindow window(sf::VideoMode(static_cast<int>(resX), static_cast<int>(resY)), "RE:Union", (sf::Style::Resize | sf::Style::Close));
        // Slow Down Input
        window.setKeyRepeatEnabled(false);

        // Create a view. This can be of any size, but in this example it will be the same size as the window.
        // After creating it, it applies the letterbox effect to it; this is not neccesary if the view
        // is the same size as the window initially, but let's do this just in case.
        sf::View view;
        view.setSize(resX, resY);
        view.setCenter(view.getSize().x / 2, view.getSize().y / 2);
        view = getLetterboxView(view, static_cast<int>(resX), static_cast<int>(resY));

Those two lines with the static_cast for resX and resY :)

I converted resX and resY to floats to stop the compiler from warning then casted them in those two instances to stop the 2 new warning errors :P

9
Graphics / Re: Letterbox effect using a view - not on position 0,0
« on: May 21, 2016, 12:56:35 am »
This is because the code uses doubles to perform calculations on floats without explicit casting. Change the functions doubles to floats and that should fix those warnings. (i.e. 2.0 -> 2.f)
EDIT: I've updated that code to use floats so you can copy it again if you'd like ;)
Yeah the awesome guys in #sfml helped me fix it by changing it to floats and then casting INT to the stuff x3 Thanks though!

10
Graphics / Re: Letterbox effect using a view - not on position 0,0
« on: May 20, 2016, 07:22:03 am »
Sorry to kinda hijack this thread, but I found what you linked very useful for my game, but do you get warnings at build time about changing 'double' to 'float' ? Have you found a way to stop that? The game still works fine but I don't like errors >_>

11
Graphics / Re: Why my sf::Text isn't updating every time?
« on: May 20, 2016, 07:17:40 am »
So I'm really new and totally useless, but I think you may be running into issues because you aren't using ELSE IF. I found in my game that even though I change variables, other nested IFs will "bleed" data because everything is happening sort of... all at once sequentially down your IF tree. Try adding ELSE to all your nested IF's after the first one and see if that fixes it, I -suspect- your enemyatk is bleeding and causing issues but... I dunno >_>

12
Graphics / Re: Request: Weaponized Text Wrapping Example
« on: May 20, 2016, 07:13:20 am »
Yikes, that's a lot to take in :o Thank you for the effort, I really appreciate it, but I don't think I'm to the point yet where I can take all this and adapt it >_> I'll tinker with it but it seems a bit daunting going from

sftd_calc_bounding_box(&textWidth, &textHeight, font, 15, 375, gameGlobals.sceneText);
sftd_draw_text_wrap(font, 30, 165, RGBA8(255, 255, 255, 255), 15, 375, gameGlobals.sceneText);
 

in my 3DS C code to all of that xD If I had a clear concise example of it working with SFML font sizes and put to use in an example, it would help a ton. I really learn fastest by reversing and toying with working examples made my competent coders.

13
Graphics / Re: Request: Weaponized Text Wrapping Example
« on: May 20, 2016, 03:25:52 am »
Basically it means "fully functional"

I'm coding in C/C++ on Windows using Visual Studio.

I'm using a font too, so it would be handy to have it look at the text/pixel length when conforming it to the rectangle...

14
Graphics / Request: Weaponized Text Wrapping Example
« on: May 20, 2016, 01:20:59 am »
I see many posts of people asking for this, and almost all of them are people linking to other (sometimes dead) threads or people saying "yahoo I got it" but not posting examples. Laurent says to:

"Otherwise, short answer: compute the position of every character (text.findCharacterPos) and insert a line break when the position exceeds the width of the container."

However I'm extremely new to coding. I'm trying to port my visual novel homebrew game over from 3DS (written in C), but the library on there has a very simple function where you define a rectangle size, position, and character limit and it just kinda does the rest for you.

I was wondering if anyone could take the time to throw together a working example of text wrapping (and maybe as a bonus changing the rendered string with a button press or something?) for all of us beginners @.@ It's pretty much the only thing I'm stuck at currently to finish porting over my game...

Pages: [1]