Skip to content
Sign upLog in
← Back to Community

ANSI console game - in Java!

Profile icon
OrionSmithHacker

I didn't think this was possible until a week ago, and now here I am showing off a game that is really a way to demonstrate more interesting ANSI console output tricks in Java.

Really what this means to me is that I can now do more interesting projects with my AP Computer Science students, since our district has Chromebooks and we need to do all our work in online environments. I know, Swing is also an option. But I think we can all agree that the Swing implementation is not a great place to learn to code, with its long load times and challenging feedback mechanisms. Plus Swing programs are often much larger than console programs, making them harder to use in the classroom.

Thank you Repl.it for using a shell environment capable of ANSI and raw character input mode. Enjoy the game, and I'd love to work with anyone that wants to create a simple Repl.it-compatible, single-file ANSI helper system to use with future projects. (Or if anyone can show me how to use existing solutions like JANSI in jar form, that'd be great too.)

Voters
Profile icon
GabrielleFlores
Profile icon
DaltonLuce
Profile icon
memmojs
Profile icon
ERICTONG
Profile icon
NishyTheFishy
Profile icon
Tmholt02
Profile icon
OrionSmith
Comments
hotnewtop
Profile icon
SatokoMuramatsu

Thanks for sharing that code with us. I am really like it. I am a college student and I am searching for it online and I am glad I have found it in your post. I am also searching for casino game developers online and if you know any, please let me know or share their contact details with us.

Profile icon
MrLane

Hello

@OrionSmith

I am a CS teacher in Ontario Canada and due to the pandemic had to switch to cloud based programming so all of my students could work on whatever device they had available. In the past we used eclipse and I created a game engine for them to work in there.

Sadly, repl doesn't allow for such things. I was trying to find some middle ground but could not get around the wait on key input issue. Then I came across this program you built and in particular the two input commands that Start and Stop character input in raw mode.

It was just what I needed to get over the hump. I have built a pretty detailed Console based game engine in the two weekends. There are still a few kinks mainly due to handling multiple simultaneous keys and the unbeatable device level repeat delay when holding a key.
These are things I have come to terms with, which will limit the types of games that can be made, but that is alright.

In any case, I wanted to put an attribution in my Input class to you, and wanted to know how you would prefer I do that.

Thanks for your efforts and sharing.

Profile icon
OrionSmith

@MrLane
oh my goodness, I hadn't checked back on this page in a long time and finally saw your post when I noticed a different comment notification more recently. I'm thrilled that someone found it useful! In my school district we switched over to Chromebooks three years ago and I guess you could say I was a little more ready for 2020 from that perspective than some. Anyway, I'd love to see what you made!

Profile icon
AllAwesome497

You can always extract jars to get their source code.
Just unzip then w/ a tool like 7zip (which I have found to be the best archive manager tool despite the gui). Other than that, I've used repl on school chromebooks many times and it works just fine. All u have to do is make sure it's not blocked by the school firewall (although most don't block it)
Might want to look into the Github for education also, many great opportunities w/ that.
https://education.github.com/

Profile icon
OrionSmith

@AllAwesome497
Thanks for the jar file tip, I didn't know that. I use 7-Zip also.

So I peeked into the JAR file for the JANSI system and, unsurprisingly, found .class bytecode files instead of .java source files. I don't think repl.it supports .class files in JDK projects at this time. I suppose I could always download the original source, but the JANSI project also uses a bunch of other libraries stored as bytecode. Would I then have to decompile or otherwise track down source for all those? If you have a simpler solution by all means let me know, but what I'm suggesting is that making my own version was really just starting to look like less work...

Profile icon
AllAwesome497

@OrionSmith
you could try the source code from here https://github.com/fusesource/jansi