I'm taking some college courses on programming, and thought that I'd try to make a dungeon-crawler/text adventure game as practice in my free time. So far, it's going pretty well. Whenever I start trying to think out how to do something, we just happen to have a lecture on what would help me for that particular part the next day. For example, I'm trying to think of the easiest way to implement character stats, and one or two days later we start learning about structures. I start wondering about interpreting user input, and we start learning about tokenizing strings. (which means that if I'm careful about how I line things up, I could make a text parser that should be able to understand natural sentence structure instead of strictly "Walk North", and giving the game more of a DnD vibe.) I've got one problem that I can't seem to figure out, though.
I want to make a first-person view appear on screen. After looking things up and doing a bit of research, I think I have the best way to do this figured out. I want to use a 2D array and make changes to it depending on what's around the player. Once everything has been worked out, print the array to the screen to make an ASCII image of a first-person view. The problem is, I need to make changes to the array in sections. If there's a wall to the player's left, I need to essentially make a trapezoid shape of entries on the left third of the array "image" without touching the rest of the array. I'd need to do the same on the right side of the array if there's a wall to the right, without touching the left side of the array at all.
I know that if I'm creating the array, I can put it together like: array[][] = {{1,2,3,4,5},{1,2,3,4,5},{1,2,3,4,5}}. This was what got me thinking that arrays are the way to go, since it would be very easy to read my code if I put each part of the array in a separate line and use white space to essentially let me see what the finished "picture" section will look like inside of my code. However, asking my teacher about it during a few minutes between classes revealed that while I can create an array like that, I can't necessarily edit the array like that without placing something like "0" inside of the extra spots, which would erase all of the other parts of the array. I could just code the change for each individual slot separately, but that's going to be a nightmare as far as readability goes, and if I find a better more-appealing way to draw part of the dungeon in ASCII art later on, making adjustments would be insanely difficult.
Does anybody have any ideas how I can get this done? I really want to use arrays, since I realize that it would be easier to increase "draw distance" by making more checks and drawing more "layers" onto the array image. If I just use pre-determined full images, I'm going to need to place a TON of images so I can cover every single possibility.
I want to make a first-person view appear on screen. After looking things up and doing a bit of research, I think I have the best way to do this figured out. I want to use a 2D array and make changes to it depending on what's around the player. Once everything has been worked out, print the array to the screen to make an ASCII image of a first-person view. The problem is, I need to make changes to the array in sections. If there's a wall to the player's left, I need to essentially make a trapezoid shape of entries on the left third of the array "image" without touching the rest of the array. I'd need to do the same on the right side of the array if there's a wall to the right, without touching the left side of the array at all.
I know that if I'm creating the array, I can put it together like: array[][] = {{1,2,3,4,5},{1,2,3,4,5},{1,2,3,4,5}}. This was what got me thinking that arrays are the way to go, since it would be very easy to read my code if I put each part of the array in a separate line and use white space to essentially let me see what the finished "picture" section will look like inside of my code. However, asking my teacher about it during a few minutes between classes revealed that while I can create an array like that, I can't necessarily edit the array like that without placing something like "0" inside of the extra spots, which would erase all of the other parts of the array. I could just code the change for each individual slot separately, but that's going to be a nightmare as far as readability goes, and if I find a better more-appealing way to draw part of the dungeon in ASCII art later on, making adjustments would be insanely difficult.
Does anybody have any ideas how I can get this done? I really want to use arrays, since I realize that it would be easier to increase "draw distance" by making more checks and drawing more "layers" onto the array image. If I just use pre-determined full images, I'm going to need to place a TON of images so I can cover every single possibility.