[3.0.0 beta3] KeyStroke/KeyType and reading input

62 views
Skip to first unread message

D. Vultures

unread,
Nov 28, 2016, 5:30:02 PM11/28/16
to lanterna-discuss
Hi everyone,


I am very sorry if I am to ask a very simple question regarding Lanterna. It just so happens that I've got nowhere else to turn to.

I've already posted a question on reddit and I doubt if anyone would answer over there. I want to do the simplest of things with Lanterna - create a Terminal and a Screen, draw a character on the top layer and redraw it according to keyboard input. That said, I am attempting to "move" a character in a 80x25 grid.

Besides the straightforward readInput() method implementation for my (Screen) screen which didn't do the right thing, I've also attempted to instantiate an InputDecoder and call the getNextCharacter() method:
InputDecoder indec = new InputDecoder(new InputStreamReader(System.in));
KeyStroke ks = new KeyStroke(KeyType.Enter);

if (indec.getNextCharacter(true).equals(ks)) {
...
}

This also had no actual results; I couldn't redraw anything when calling upon putString(int x,int y,String str) method for my (TextGraphics) tGraphics object.

I have to admit I've found a Lanterna 2 implementation for a roguelike game project (Brown uni cs), but that hadn't helped me much. KeyStroke and KeyType are nowhere to be found in previous Lanterna versions. I seem to be hitting a brick wall and I'd really appreciate any advice you guys could spare.


Best of wishes,
D. Vultures

D. Vultures

unread,
Dec 1, 2016, 4:42:15 PM12/1/16
to lanterna-discuss
Nevermind, the tests helped a lot. (src\test\java\com\googlecode\lanterna\screen\SimpleScreenTest.java)
Reply all
Reply to author
Forward
0 new messages