Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dialogue system #136

Open
aaronamk opened this issue Mar 18, 2021 · 2 comments
Open

Add dialogue system #136

aaronamk opened this issue Mar 18, 2021 · 2 comments
Assignees
Labels

Comments

@aaronamk
Copy link
Member

No description provided.

@aaronamk aaronamk added the code label Mar 18, 2021
@BlastWind BlastWind self-assigned this Mar 18, 2021
@rlatosky rlatosky self-assigned this Mar 20, 2021
@BlastWind
Copy link
Member

Here's the high level API design I'm thinking.
We have a Singleton, global Dialogue class with

Dialogue.load(intro_dialogue.txt) // loads a text file, sets a accessible-anywhere boolean isInDialogue=true
Dialogue.advance() // advances to the next line in the file, display the line, calls .end() if no more lines
Dialogue.end() // remove the dialogue box, 

For now, if world isInDialogue, let's skip on PatrolAI::update, health bar display, Pari movement key listening.

Here's where we handle dialogue advance

// in user_view.cpp 
void UserView::pressEvent(...) {
 switch (key.code) {
  ... 
 case sf::Keyboard::Enter: // could trigger on left click too...  
  Dialogue->advance(); 
 }
}

Dialogue.advance() has and needs some nice abstractions because I want to display the dialogue with animations: (See https://www.earthboundtext.com/images/splash.gif)
The advance() code probably looks like:

string nextLine = I/O.fetchNextLine(); 
if(!nextLine): 
 Dialogue.end(); 
 return; 
if isTextAnimating: 
 Dialogue.skipAnimation() // so, when User presses enter, it will skip out on the 
else:
 SFML.draw(nextLine);  

When the uesr presses Enter, if text is animating, we skip out the animation and display the whole text out. If text is not animating, we have displayed the whole line, so let's display the next line.

@rlatosky
Copy link
Contributor

Don't have animations (yet), but I have implemented the pause on dialog, and the advance function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants