C
C#2y ago
shuffle

❔ ✅ Text Based Game Assignment

my best gues from my limited coding knowledge would be to use a 3d array
22 Replies
shuffle
shuffleOP2y ago
that somehow clears the console every time the object is moved and prints the updatated version of the "map" if you would like to see all the code let me know i want the map to be represented in a text form
exokem
exokem2y ago
You can use a 2d array of chars Designate a specific char to represent an obstacle (or use multiple chars for obstacles if you want) You can also manually set the cursor position (look at System.Console.SetCursorPosition) which would let you just re-print each space over what it was before
shuffle
shuffleOP2y ago
so im not sure what i need cursor position for as its all text based. even the options you have to write with your keybard would you mind exlpaining
exokem
exokem2y ago
Cursor position is not the mouse position
shuffle
shuffleOP2y ago
oh okay let me do some quick googling then so ive started with
string[,] map = { {"x","","","",""}, {"x", "", "x", "x", "" }, { "o","","x","x","" }, {"","x","x","","x"}, {"","x","C","","x"} }
string[,] map = { {"x","","","",""}, {"x", "", "x", "x", "" }, { "o","","x","x","" }, {"","x","x","","x"}, {"","x","C","","x"} }
exokem
exokem2y ago
I would use a space for empty tiles
shuffle
shuffleOP2y ago
right yea ive changed that but my biggest issue is how do i make "C" move idk how to make it move around the array
exokem
exokem2y ago
Store its X and y position separately from the array When you would change the position, clear the tile at its current position before changing the position, then update the position and put c at the new coordinates
shuffle
shuffleOP2y ago
i attempted to print the array as a map
No description
shuffle
shuffleOP2y ago
but it just doesnt look very user friendly
exokem
exokem2y ago
You can always use special characters https://en.m.wikipedia.org/wiki/Box-drawing_character
Box-drawing character
Box-drawing characters, also known as line-drawing characters, are a form of semigraphics widely used in text user interfaces to draw various geometric frames and boxes. These characters are characterised by being designed to be connected horizontally and/or vertically with adjacent characters, which requires proper alignment. Box-drawing charac...
exokem
exokem2y ago
There is also a character that looks like a filled rectangle but I can't remember where it was
shuffle
shuffleOP2y ago
right thank you got those do you know any articles that cover the use of coordinates within a 2d array and how to move an object within one
exokem
exokem2y ago
I don't know any articles but the concept should be relatively simple The objects need to be associated with a coordinate position that determines where they should be placed in the array The array should not determine their position
shuffle
shuffleOP2y ago
okay ill do some googling thank you for the help
ZacharyPatten
ZacharyPatten2y ago
@shuffle this sounds similar to "wumpus world". I have an example of wumpus world on GitHub. would you like me to link it?
shuffle
shuffleOP2y ago
yes please
ZacharyPatten
ZacharyPatten2y ago
https://github.com/dotnet/dotnet-console-games/tree/main/Projects/Wumpus%20World It's not exactly the same but in wumpus world (at least this version) it is a 4x4 grid where you try to find the gold while avoiding pits and a wumpus
shuffle
shuffleOP2y ago
my only concern is my proramming knowledge isnt advanced enough to undesrtand him using a lot of these things for example
yield return Map
yield return Map
or
void play
void play
Murten
Murten2y ago
Have you ever written code before?
shuffle
shuffleOP2y ago
yes but not much i stated that at the start i can show u the code to my program if youd like !close
Accord
Accord2y ago
Closed! Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.

Did you find this page helpful?