So if anybody played Manamon or Paladin of the sky, they'd be familiar with this concept. For anybody who hasn't, here's a brief rundown.
When moving around, you'd hear tones in relationship to your character. Those tones represent walls, and made it hell of a lot easier for you to find your way through the mazes. I'm not gonna attempt building something like that, no. However, I was always wondering how did that happen. How did the computer know whenever I was near a wall?
As I learned python, that question became much less mysterious, and so here's my take on it, at least on paper.
First of all, I'm assuming that my map is a dictionary. I have tried using lists within a small 2d thingy I've built, they broke, horribly. All I'm gonna say on that topic. I will also assume that we want to hear walls when they're 4 steps away from us.
Second, I would create a list with 4 values. The first 2 are for the left and right, and the second 2 are for forward and backward scans.
in my third step I would create a function that takes in player's x and y as it's parameters. When that's done, I would create two loops within that function, one for the x, and 1 for the y values. Those loops will scan the terrain (read, the dictionary), and retrieve the values from it. If any contain wall tiles, the fun will begin.
If it's in my x-range loop, I'd see if the x is less than or greater than the player's x coordinate. If it is, I would update the first 2 values within my list. If it's my y loop, I'd update the second 2 values.
The fourth and the final step would be me checking if any values equal 4, or the total number of iterations of the loops. Remember, the conditions would be something like for i in range(x-4,x+5). If the counters equal 4, it means there are no walls. If they aren't equal, well, that's when the sounds will come in. I should also mention that I would reset the list every time the function gets called.
So how far am I from the mark? Do I need to go back to the python school and relearn a thing or two? Is my solution more complicated than it needs to be? I'm curious as to what yall think. Even if my solution would work, is there a better method that vgstorm probably uses?
Pages 1