GDC-WM / Parryt

Play as Pari the parrying parrot
MIT License
7 stars 0 forks source link

Add dialogue system #136

Open aaronamk opened 3 years ago

BlastWind commented 3 years ago

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 commented 3 years ago

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