I want to make a 2D game in java that is run on command prompt. However instead of redrawing the map as a character moves across it I wanted to see if there was a way to edit the the map already written
Asked
Active
Viewed 292 times
-1
-
1Sounds interesting. Good luck, and head back when you have a question! – admdrew Feb 11 '14 at 19:12
-
And in what way is this related to editing text written in the command prompt? How are you visualizing the maze data? – Chris Zhang Feb 11 '14 at 19:13
-
Linux, Mac, or Windows? – Reinstate Monica -- notmaynard Feb 11 '14 at 19:14
-
@ChrisZhang It looks to me like he's creating a text-only game not unlike Nethack. So he would need to change what characters are showing in the command window as the character moves through the map. – cf- Feb 11 '14 at 19:16
-
1See https://en.wikipedia.org/wiki/ANSI_escape_code; you can use these escapes to move around the console, e.g. `System.out.print("\u001b[1;1fWhere am I?");` will print at the upper-left-corner. Not sure if it works on Windows, though. – Reinstate Monica -- notmaynard Feb 11 '14 at 19:19
1 Answers
1
How to do it can depend on the operating system used. But in general, it is surely possible to do what you want.
Typically you can for example use \b
character (backspace) to go a position back on the console. Be aware that it won't work in Eclipse though.
But what you really want is probably a library giving you a "Curses" port (not sure if there is a native Java one), or Lanterna perhaps?

Community
- 1
- 1

ChristopheD
- 112,638
- 29
- 165
- 179