ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
First I just want to send nethack some commands and receive the output interactively, then I want to draw the results using pygame or preferably a 3d engine or something. I'm aiming for a fps. Lots of fun in perspective. Luckily, nethack should send relatively constant formated output (for the tty).
I'm thinking of eventually using pygame or a 3d module, but for now I just want to play around with it, see what it does, if it works properly. I just want to input a command and read the output. Have fun with it.
Sorry for the double post. I hadn't noticed there was a second page.
I will look at glhack.
Last edited by S. Chapelin; 02-14-2012 at 02:34 AM.
Reason: double post
Played around with it for a bit.
Here is an example of the output.
Code:
response = [?1049h[H[2J[H[2;1HNetHack, Copyright 1985-2003
[3;1H By Stichting Mathematisch Centrum and M. Stephenson.
[4;1H See license for details.
[5;1H[6;1H[7;1HShall I pick a character's race, role, gender and alignment for you? [ynq]
command = y
response = y[H[2J[H[H[2J[H[4;60H---------------[5;60H|...f.........|[6;60H|.:.@.........|[7;60H|........$....|[8;60H+.............|[9;60H---+-----------[6;64H[23;1HGillesg the Evoker St:11 Dx:12 Co:13 In:18 Wi:10 Ch:11 Chaotic[K
[24;1HDlvl:1 $:0 HP:12(12) Pw:7(7) AC:9 Exp:1[K[1;23H[K It is written in the Book of Anhur:[2;23H[K [3;23H[K After the Creation, the cruel god Moloch rebelled[4;23H[K against the authority of Marduk the Creator.[5;23H[K Moloch stole from Marduk the most powerful of all[6;23H[K the artifacts of the gods, the Amulet of Yendor,[7;23H[K and he hid it in the dark cavities of Gehennom, the[8;23H[K Under World, where he now lurks, and bides his time.[9;23H[K [10;23H[K Your god Anhur seeks to possess the Amulet, and with it[11;23H[K to gain deserved ascendance over the other gods.[12;23H[K [13;23H[K You, a newly trained Evoker, have been heralded[14;23H[K from birth as the instrument of Anhur. You are destined[15;23H[K to
command =
response = recover the Amulet for your deity, or die in the[16;23H[K attempt. Your hour of destiny has come. For the sake[17;23H[K of us all: Go bravely with Anhur![18;23H[K[C--More--[1;22H[K[2;22H[K[3;22H[K[4;22H[K[4;60H---------------[5;22H[K[5;60H|...f.........|[6;22H[K[6;60H|.:.@.........|[7;22H[K[7;60H|........$....|[8;22H[K[8;60H+.............|[9;22H[K[9;60H---+-----------[10;22H[K[11;22H[K[12;22H[K[13;22H[K[14;22H[K[15;22H[K[16;22H[K[17;22H[K[18;22H[K[6;64H[HHello gillesg, welcome to NetHack! You are a chaotic male human Wizard.[K[6;64H[H[K[6;64H[HUnavailable command '^I'.[K[6;64H[H[K[5;64H.[6;64H<f[7;64H.[8;64H@
command = #quit
response = [H# [Kquituititt[H[K[8;64H[HReally quit? [yn] (n) [K
command = y
response = y[K[8;64H[HDo you want your possessions identified? [ynq] (n) [Kn[K[8;64H[HDo you want to see your attributes? [ynq] (n) [K
As you can see, it is rather constant. Shouldn't be too hard to parse. Just have to look for the position markers ([x;xxH) to build the map, then find the stats for the hud, display the messages in a pretty box. First, though, I'm just going to put the map into a two-dimensional array.
Long term puzzle. Lottsa fun in sight.
I've comme across a slight difficulty. See this extract of the output from nethack:
Code:
[5;60H|...f.........|
The [5;60H is the coordinates where nethack draws the map, which is the |, the line of dots and the f.
I have succeded in extracting the coordinates.
In order to extract the map portion, I must go from the H to the little square, which is in reality an escape caracter (0x1B), as I discovered in Hexedit.
So I tried the following line:
Code:
while c_c[i] != 0x1B
and
Code:
while c_c[i] != '0x1B'
and (desperate)
Code:
while c_c[i] != ""
but none of them work.
Code:
$ python test.py
File "test.py", line 40
while c_c[i] != 0x1B
^
SyntaxError: invalid syntax
Believe it or not, this is what the nethack output looks like when it is put into a two dimentional array. Not much, right?
This should be the floor on which the hero will stand and look around from the position occupied by the '@', with his faithfull dog where the 'f' is, ready to be attacked by a lichen (':'), I think it is. What I want to do next is a pseudo3d, that is to say that the hero will be able to look around and move around with the mouse, but although he will probably be able to look up and down, it will be an illusion as he won't be able to move up or down. When he moves up or down a level, there will only be a replacement of the map by another. He won't see the stairs going down. Similarely, when he falls in a hole, in reality only his height will change. Nothing else.
Also, even though hethack is turn based, modern computers are so fast that I wonder if it will make a difference. I don't know. We'll just have to see.
Anyway, lots of fun in sight!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.