Good day,
I don’t know how to describe my problem (which is more like a challenge)
but I’ll do my best.
I am working on a text-based game and as your character moves, you get informations such as the room name and below, a description (Lorem ipsum in the example) which is an array of string. I would like to know how to append characters to it. I am actually
trying to display a minimap made of ASCII character. See the second bloc
code for an example.
From:
Room Name Here
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis tempus
orci diam. Curabitur hendrerit augue et lorem vulputate semper. Nullam
aliquam eleifend sapien nec bibendum. Donec accumsan leo eu orci
elementum semper in mollis metus. Ut ipsum diam, suscipit vel bibendum
non, congue eu nisi. Donec justo dolor, scelerisque nec fringilla nec,
aliquet sit amet elit. Morbi elementum pharetra odio, nec accumsan
velit lacinia quis.
[Exits: none] [Doors: none]
Into:
Room Name Here
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis +-----+
tempus orci diam. Curabitur hendrerit augue et lorem vulputate | # |
semper. Nullam aliquam eleifend sapien nec bibendum. Donec |#-#-#|
accumsan leo eu orci elementum semper in mollis metus. Ut ipsum | # |
diam, suscipit vel bibendum non, congue eu nisi. Donec justo +-----+
dolor, scelerisque nec fringilla nec, aliquet sit amet elit. Morbi
elementum pharetra odio, nec accumsan velit lacinia quis.
[Exits: none] [Doors: none]
The game itself is made in VB.NET but a solution in pseudo-code is also
welcomed.
Also, each line’s length is aproximatively the maximum length it must be.
Thank you guys!
Edit:
The desired output must be an array of strings because this data is later send to a client connected using sockets.
If we use an assumption that your line length is 80 characters, Limit the max length of your text line to 70 characters. If the actual length is less than 70 add the difference in spaces to the front of the map data you are wishing to add. This is also dependent on using a monospaced font.
edit: added arrays, used Courier New Font
Edit: You can create a function and grow the array if the number of lines is less than 5 to make sure you have space for the map.