8
2
This challenge is based on one proposed on the usenet group rec.games.roguelike.development a few years ago. I can't find the original newsgroup post, but you can have a look a the Github repo of solutions. It was only golfed in a couple of languages and I'd love to see some more!
Objective
The aim is to build a program that presents a top-down view of a dungeon using ascii characters. There will be an @
sign representing the player that can be moved through the free space in the dungeon (represented by ), though it cannot pass through the walls (represented by
#
).
The map of the dungeon must look like this:
#### ####
# # # #
# #### #
# #
## ##
# #
# #
## ##
# #
# #### #
# # # #
#### ####
The player must begin at location {2,2}, where {0,0} is the top left-hand corner.
Interface
The user needs to be able to move the player in the four cardinal directions using the arrow keys on the keyboard.
There needs to be some way for the user to exit the program. It does not need to be a graceful exit (for example, it doesn't matter if an exception is printed).
The map and player need to be drawn before any input has been taken, and the player needs to be updated after each input.
Libraries
Feel free to use established libraries for console input or output, such as Curses. Just mention in your answer what you are using.
Scoring
This is code golf, shortest code wins!
Pretty close to a duplicate of Build an engine for a maze game which could certainly use some additional entries. Thoughts?
– dmckee --- ex-moderator kitten – 2012-08-24T02:46:33.733@dmckee It's definitely pretty similar. I hope the simpler input mechanism and the challenge of efficiently hardcoding the preset map will make it different enough. – Paul Prestidge – 2012-08-24T02:51:14.680
I'll certainly buy the hardcoded map bit. Now just let me just think on how I might adapt my previous solution... – dmckee --- ex-moderator kitten – 2012-08-24T02:52:32.633
2
I just can't help but mention the game that introduced me to C: http://www.nethack.org/
– SeanC – 2012-08-24T04:53:37.770