Wish someone already wrote this code so I wouldn't have to re-invent the wheel.
Getting from notepad formatted.txt to sf::Text is few lines:
std::ifstream file("whatever.txt");
std::stringstream stream;
stream<<file.rdbuf();
sf::Text text(stream.str(),/* some font */,30);
For my craps game, I need to allow the user to enter setup info like different odds payout for the different bets used at different casinos, initial stake amount in $, and stuff like that. Even a console type input where I would list the bets to change with a letter that the user could select and then type the odds desired would be fine. Something like:
A class that your state(assuming you have state engine) will send all caught textentered events and display it every frame and interface with returncodes or link with pointers with your game class.
When the user clicks "HELP", then I'll read the text file and display it in the SFML window, either scrollable or page-by-page.
A state that only displays help and catches arrow keys or mouse moves or scrolls to move around and any other even to quit itself, but I don't know how your (state) engine is laid out.
Getting from notepad formatted.txt to sf::Text is few lines:
std::ifstream file("whatever.txt");
std::stringstream stream;
stream<<file.rdbuf();
sf::Text text(stream.str(),/* some font */,30);
That was simple ;). I'll use that base to form scrollable or page-by-page, forward/backward help info. Thanks :)
A class that your state(assuming you have state engine) will send all caught text entered events and display it every frame and interface with return codes or link with pointers with your game class.
...snip...
A state that only displays help and catches arrow keys or mouse moves or scrolls to move around and any other even to quit itself, but I don't know how your (state) engine is laid out.
Now that I've worked out most of the details, and made my PrimaryMenu and craps table layout in Photoshop, I'm going to start writing my code. I plan to use the "Manage different screens in a game" engine since it should allow exiting the crap table screen, go to the PrimaryMenu screen for user input, then return to the crap table screen with all chips still displayed where they were. Link to that game engine is here:
https://github.com/SFML/SFML/wiki/TutorialScreens (https://github.com/SFML/SFML/wiki/TutorialScreens)
I'll have a PrimaryMenu screen, SubMenu screens depending on which button is clicked, and a GameScreen. The GameScreen will have the image of the craps table and allow the user to place different bets for up to 4 players. It will show the running balance of the stake for each player. It will simulate a real crap table operation exactly as possible with every possible bet.
Thanks,
Raptor
std::ifstream file("whatever.txt");
std::stringstream stream;
stream<<file.rdbuf();
I'm not sure if it is standard. This code is "cleaner":
std::ifstream file("whatever.txt");
std::istream_iterator<char> begin(file);
std::istream_iterator<char> end;
std::string contents(begin, end);
- When looking for input, check which keys the user has pressed.
- Pass ASCII value of pressed keys to input class
No, watch the TextEntered event, not keys!
I'm not sure if it is standard. This code is "cleaner":
std::ifstream file("whatever.txt");
std::istream_iterator<char> begin(file);
std::istream_iterator<char> end;
std::string contents(begin, end);
- When looking for input, check which keys the user has pressed.
- Pass ASCII value of pressed keys to input class
No, watch the TextEntered event, not keys!
Thanks for the code and suggestions Laurent.
Raptor