2

I'm currently working on a "hang man"-esque game written in java. The program as a whole works fine (the core is very simple) but i want to do something fancy with the terminal output. In most versions of hangman, you draw a little stick figure body-part-by-body-part after each incorrect guess. When the stick figure is completely drawn, it means you have used all of your guesses and you lose. Is there any way to accomplish this in java without having to println a bunch of white spaces to "clear the board?" I've been messing around with basic java animations (i forget which package this comes with) but don't understand it well enough to do something large scale such as a hangman figure.

for anyone who's curious, this is how the output should look when it's "game over"

 ________
 |   | 
 |  *_* 
 | --+--  
 |   | 
 |  / \\  
 |--------

...and this is how the default board should appear

 ________
 |  
 | 
 |  
 |   
 |  
 |--------

i want to do a line by line animation of the figure starting with the head and ending with the feet. All i know how to do with basic animation is animate a single character sequence (i.e., i can do a loading animation by animating the characters "|/-\")

edit 1: spelling/grammar

satincorvo
  • 173
  • 1
  • 2
  • 12
  • You could use escape codes to clear the screen and then redraw to give an animation illusion. – TheFooBarWay Apr 29 '16 at 16:56
  • i want to accomplish animation without having to clear the board (via println spaces or escaping/clearing text) the little research i've done has given me the easy way out, but i want to do something over-the-top. – satincorvo Apr 29 '16 at 16:58
  • How the terminal behaves is not a java thing. It depends on the terminal and whether it supports special control characters. Many terminals such as the console window of your IDE probably don't support such mechanics at all. http://stackoverflow.com/questions/4888362/commands-in-java-to-clear-the-screen has some info for clearing screen – zapl Apr 29 '16 at 17:03
  • i know i can animate some characters because i've done it in the past. essentially what i want to accomplish is having a larger string in a binary animation state and have the second half of the animation, well animate, upon command. as i said, i can do this with individual characters. What i need help with is approaching larger strings (such as 5 or 6 characters long) and animating those. – satincorvo Apr 29 '16 at 17:05
  • i appreciate the time you've taken to find the link to rending the text in the terminal window, but i really want to do something more if that is at all possible. – satincorvo Apr 29 '16 at 17:06

0 Answers0