How to use this

139 views
Skip to first unread message

Alwin Schneider

unread,
Oct 2, 2022, 3:49:29 AM10/2/22
to jline-users
Hello Guys,
I am new to programming and i just finished my first project, a console tic tac toe.

I need this libary for making a console snake game.I need jline3 for refreshing the console characters based on user input instead of printing a new matchField for the game

unfortunalety this is the first time im using a libary ever.
Can somebody send me a link how to use this?

Brad Wood

unread,
Oct 2, 2022, 5:19:25 PM10/2/22
to jline...@googlegroups.com
I've actually built a Snake game with JLine in my CommandBox CLI tool.  Here is the code (written in CFML, a JVM language)


You can download CommandBox here if you want to see the game in action.  Run it as `box snake`

Really, all that matters is this line here where I pass an array of AttributedString "lines" which represent the characters I wish to display on the screen.  I'm doing so in a timer thread that redraws the screen every so many ms.


The other important bit of code is my waitForKey() method, which listens for the user's keyboard input in another thread and lives here:

Listening for keyboard input isn't quite as easy as you may expect if you're used to listening to key input from JavaScript, etc.  You've got to create bindings for all the key chars you want to listen to.  You can see in my method, I have a handful of common bindings I set up to make a reusable method.  

On a related note, I'm working on an entire curses library for my JLine-powered console tool called Escher which is all built around the basic concept of my snake game.  Here's a demo I showed last month at a conference: 

Thanks!

~Brad

Developer Advocate
Ortus Solutions, Corp 

ColdBox Platform: http://www.coldbox.org 



--
You received this message because you are subscribed to the Google Groups "jline-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jline-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jline-users/22097503-0989-470d-9966-5be750147701n%40googlegroups.com.

Alwin Schneider

unread,
Oct 3, 2022, 2:22:07 AM10/3/22
to jline-users
Thank you so much brad. This is a very helpful suggestion!
Unfortunalety i got rid of java and i am now using C#.
It is better for beginners i think and i dont have so much problems since i use it.

Thank you anyways!
This is a very helpfull ressource for other users that search for an answer.

Thank you!

Your Alwin
Reply all
Reply to author
Forward
0 new messages