[Question]
  [
## Input
* A binary matrix \$M\$ representing the walls of a dungeon.
* The position \$(x,y)\$ of the player within the dungeon.
* The direction \$d\$ that the player is currently facing (0 = North, 1 = East, 2 = South, 3 = West)
## Output
A pseudo-3D representation of the walls that are in the field of view of the player, as an ASCII art of \$30\times 10\$ characters.
Below are several possible output frames, along with the corresponding map and compass to help getting the hang of it (but drawing the map and the compass is not part of the challenge).
[![animation](https://i.stack.imgur.com/KZGWO.gif)](https://i.stack.imgur.com/KZGWO.gif)
## Specification
### Field of view
The player has \$13\$ walls in his field of view, labeled from \$A\$ to \$M\$. Below are the positions of the walls relative to the player (in yellow), in all possible directions.
[![field of view](https://i.stack.imgur.com/ee4Vv.png)](https://i.stack.imgur.com/ee4Vv.png)
### Drawing the walls
The walls are supposed to be drawn from \$A\$ to \$M\$ in this exact order, given that any part drawn previously may be overwritten by closer walls. You may of course implement it differently as long as the final result is the same.
The entire output is drawn with 7 distinct characters: `" "`, `"'"`, `"."`, `"|"`, `"-"`, `"_"` and `":"`.
Because detailing the shapes of the walls in the body of this challenge would make it too lengthy, they are instead provided in the following TIO link:
[**Try it online!**](https://tio.run/##ZZNbd5pAFIXf/RVTX4TiDW/osrYLNQka8YaKmuYBBRwQGeQmQ1f61y0X05qGB84M@5s9ezigS77k7G3NcgsmkpXrVWRHIwF0QFYZhjJddoRDyA66Xq9lVfrcMwzZxYbR5gvYLFcgXzuw2w3ljba75rZXF0p81fJpsXs@BpVusO/r7HqLpnY4r@j8Fj8emzwMDrPpFOryxttWhyNhua8qA8mwnt0zf5Y4oSxXG8za2e4hY3A6r1HWAXNes9IKWuteMKqdBjtudXEaJUUu1bh1acCVwxAfxRk3rHODHVU3ZjVdbO1Pvih25UujP5ANR3g49urcBm10/WmOqa42phFqQFlt0oLB@6zk6O7R0rmV7U24iSfJVkmXHmeBh@pPJchcmqguUOHTqLcQH7CvV/nwWTFpf@nJ49AYT@AEcyyvLgPIrCwdTlDNRBzfZFc7cwGXtdHD3tNGwXA2FB@3DF8ZM7Lfnzv@dIV6a4dZlnZIXJ60QPVUv271YZ9R2dOq1sm2MxlbOXuarRC50NB2ObLomaFmEaZyAV1PVRW7qNroRCQty4PsTnKURi1L5gGh2HYe7BKGBJ3v4FcGABXZhBl1ttwGJvgG6GpUKYpMNAAukmFEYrqm6CLBtTXzQJBFxzI0l8j9NKP9HUPbK5HJV0CX86DwOx2R7cQhOGmxPU4LDUrRTjdBChIhKYWbkkhxJpxmwnGmuP7LlOpBqgeRXo3rvQ6AphJx9Bf8@hK8gi8dkPuRu9f/5uIlFxajIRHP8yC4pU4v/B@DEwZ/YG7HSBkpIOL5Z5@PDE6Ye5@3zH1N73tkOshQigY6EDkxbkQOUCDtQNLiHpTsXvR7Eo16JJjkze/DugWygKGobvTUNhUbSC4gYpvk@BTI5RNTfJuRURNETXZhlDZ@npwGFN5pmoyhiOEU7QDddwinEL6H4g/jc5y4J0UdRa8yAe7Bt8wb2b5e/wA "JavaScript (Node.js) – Try It Online")
The characters that are not part of a given wall are marked with a `"?"` in these diagrams. They must be treated as 'transparent' characters that are not drawn at all. On the other hand, all spaces within a wall are 'solid' and must overwrite any other characters that may have been previously drawn there.
## Rules
### About the input
* You may take \$M\$, \$x\$, \$y\$ and \$d\$ in any reasonable format.
* You may use either 0-indexed or 1-indexed coordinates.
* You may use 4 distinct values of your choice for the directions.
* The matrix is guaranteed to be at least \$3\times 3\$.
* You may assume that there will always be surrounding walls on the edges.
* The player is guaranteed to be located on an empty square.
* The input is guaranteed to be valid.
### About the output
* The walls must be drawn exactly as described.
* However, the output format is also flexible: single string, array of strings, matrix of characters, etc.
* Leading and trailing whitespace is acceptable as long as it's consistent.
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'").
## Test cases
All test cases are using the following matrix:
```
[ [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ],
  [ 1, 0, 1, 1, 1, 0, 0, 0, 0, 1 ],
  [ 1, 0, 1, 0, 1, 0, 0, 1, 0, 1 ],
  [ 1, 0, 0, 0, 0, 0, 1, 1, 0, 1 ],
  [ 1, 0, 0, 1, 0, 0, 0, 1, 0, 1 ],
  [ 1, 0, 0, 1, 1, 0, 1, 1, 0, 1 ],
  [ 1, 1, 1, 1, 0, 0, 0, 0, 0, 1 ],
  [ 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 ],
  [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ]
```
The following inputs are using 0-indexed coordinates, with \$(0,0)\$ pointing to the top-left corner.
```
x=3, y=3, d=0
x=6, y=4, d=3
x=4, y=4, d=1
x=1, y=5, d=2
x=7, y=7, d=3
x=6, y=6, d=1
x=8, y=1, d=2
x=7, y=6, d=1
```
Expected outputs:
```
------------------------------    ------------------------------
 x=3, y=3, d=0:                    x=6, y=4, d=3:
------------------------------    ------------------------------
__                          __    '.                          .'
  |'.                    .'|        |                        |  
  |   '.--------------.'   |        |----.                   |  
  |    |              |    |        |    | '.--------.       |  
  |    |              |    |        |    |  |        |       |  
  |    |              |    |        |    |  |        |       |  
  |    |              |    |        |    | .'--------'       |  
  |   .'--------------'.   |        |----'                   |  
__|.'                    '.|__      |                        |  
                                  .'                          '.
------------------------------    ------------------------------
 x=4, y=4, d=1:                    x=1, y=5, d=2:
------------------------------    ------------------------------
                            .'    __ ________________________ .'
                           |        |                        |  
-------.              .----|        |                        |  
       | '.--------.' |    |        |                        |  
       |  |        |  |    |        |                        |  
       |  |        |  |    |        |                        |  
       | .'--------'. |    |        |                        |  
-------'              '----|        |                        |  
                           |      __|________________________|  
                            '.                                '.
------------------------------    ------------------------------
 x=7, y=7, d=3:                    x=6, y=6, d=1:
------------------------------    ------------------------------
'.                                '.                            
  |'.                               |'.                         
  |   '.                            |   '.                      
  |    | '.                 .-      |    |--.--------.--------.-
  |    |  |:               :|       |    |  |        |        | 
  |    |  |:               :|       |    |  |        |        | 
  |    | .'                 '-      |    |--'--------'--------'-
  |   .'                            |   .'                      
  |.'                               |.'                         
.'                                .'                            
------------------------------    ------------------------------
 x=8, y=1, d=2:                    x=7, y=6, d=1:
------------------------------    ------------------------------
'.                          __    '.                            
  |'.                    .'|        |                           
  |   '.              .'   |        |----.--------------.-------
  |    | '.        .' |    |        |    |              |       
  |    |  |:      :|  |    |        |    |              |       
  |    |  |:      :|  |    |        |    |              |       
  |    | .'        '. |    |        |    |              |       
  |   .'              '.   |        |----'--------------'-------
  |.'                    '.|__      |                           
.'                                .'                            
```
---
***Related challenge:***
*[This challenge from 2013](https://codegolf.stackexchange.com/q/15932/58563) is closely related. But it has a different winning criterion (code-challenge), a much looser specification of the output, and requires interactive I/O.*
  
[Answer]
# [Clean](https://github.com/Ourous/curated-clean-linux) (with [Snappy](https://github.com/google/snappy)), ~~800~~ ~~785~~ ~~670~~ 644 bytes
*~~460~~ 402 bytes of code + ~~360~~ 242-byte string literal  
(escaped here and on TIO because it isn't valid UTF-8)*
You can verify the length of the literal [here.](https://tio.run/##1VQ9T8MwEJ2bX3FpBi/EBcaKTIUBiQGpI0WR5bjFkmNHtltUZOWnE5wPkiaidGHhlFPuzvfO7zlyqGBEVrnK9oJBTriseF4obWFtswd5uFqpjFG8UnmhmTFcSbyWpCiOATOUFCxLDf9gQIOZAwpJAmhzjcD1iT5N5EkyR7BYACUSWfDzGNHAJQgld2Cs5v4luGWaCBPMZgnc1hso@8b0OzeshnIDByJ4VsPIBNNAboIuaykmYPb5y5j1ZgP0Ll6aRlFKO5EwD8MwxhCCWzYeI/CVyHuJ4878cumgM98zTtB324DsbRhxUhzQl4rD6HZyzwc84a4dEB5ij/4xxijsSXpsPWvKcMKz5zNh9Vd1NN7XC4zStO3xtB3qNNbwRqBr0RcDrzRNHW5kRmUJ6Rnzn3TKbczyny2e0@nCCOHmJH91f2Dz12ptif8bJHB6mapPuhVkZ6r48am6P0qSc9omz4LYrdJ5FQv/tBfrCw)
```
import StdEnv,Data.List,Data.Maybe,Codec.Compression.Snappy,Text
@a b|b<'~'=b=a
$m x y d=map(@' ')(foldl(\a b=[@u v\\u<-a&v<-b])['~~'..][join['
']k\\Just(Just 1)<-[mapMaybe(\e=e!?(x+[u,v,~u,~v]!!d))(m!?(y+[~v,u,v,~u]!!d))\\u<-[-2,2,-1,1,0,-1,1,0,-1,1,0,-1,1]&v<-[3,3,3,3,3,2,2,2,1,1,1,0,0]]&k<-nub[q\\w<-split"#"(snappy_uncompress"\211\6\44\41\41\41\55\56\40\41\40\174\72\5\4\60\55\47\40\41\41\41\43\41\41\41\176\56\55\r\1\24\56\40\41\176\174\40\r\1\4\174\72\72\r\0\0\47\r\46\35\72\25\1\31\103\0\41\25\24\35\113\176\25\0\31\133\11\224\r\152\20\56\40\40\40\41\21\217\10\40\47\56\31\14\4\40\174\126\14\0\4\56\47\21\74\0\47\1\74\1\340\r\220\25\242\11\1\25\250\25\360\11\1\25\253\376\30\0\21\30\25\333\11\1\24\47\41\41\43\137\137\11\154\20\41\40\40\174\47\r\344\1\157\5\341\1\11\5\336\172\11\0\34\56\47\41\137\137\174\56\47\1\347\20\43\176\176\40\137\132\1\0\4\40\41\75\211\76\1\0\1\356\5\150\116\1\0\376\35\0\376\35\0\126\35\0\132\347\0\20\137\174\41\43\47\101\337\51\74\41\133\122\4\0\10\56\47\40"),q<-let l=[[c\\c<-:rpad s 30'~']\\s<-split"!"w]in[l,map reverse l]]])
```
[Try it online!](https://tio.run/##fVRra9swFP2eX6FkpbapHCQ/Yhg2K7T7sNHBoPtmmaLEzvDqR@pHlsDIT593rxTTlCVFN4l077lHR0d2VkUmq6Gs077ISCnzasjLTd105LFLP1dbei87OX/I207Pvsn9MqN3dZqt5nd1uWmyts3rav5Yyc1mT39ku25yK8nyzzI0Dka0jOTkqiQ7sidpVMqNeWsQwzLXdZEWpgBcFN/2ZCtEH9ryehvay8SKjcPBmM@T@FedV7ExMZJnIb72bWfiF@FWaMdApZSYIouy6SdzdxP3dEsPPT1sk@k0tSyzhPT@Jj5sqa7otNopth3qUJtTTtmZnwSFxC4dh6MGpxrBkuT6ObSrfhm/CPE7tNtNkXezDzOzVR489dXqaMxMOJyLhfA84fFj@L7wIcPUkgkeeCJwhC88sWBY9IKxqMN9nfNggb0AagQXjvdKhBVkghWWvJEWohEMBrA2wlsI18ec4wPIhTbmCtUPCaCDIueuIoMEUwgX1lCHKhD70MrGXdlxbwcjAC61DrCMjSBmPB93FriGquoNsCXwtCo1AzFKuQPsSoqDm2pZvkq5YM5ryhUuaHTxYEDlaoRWqnxBD0f3uBvoD9R8D/Vr44/alDGuhxq4D@JhjiSARkp0VWkBM0bxWB85gzGJJwgUuXu8DGWSBgKDOrz2K/DVU4EgyEIjXilsjgfUOXU4/3SCDuoJkOFODPcaJRwfE7wDoIOkr1z1jtfnOALN5mw8AJtZ9CW0i6wjRRTHKyFWof2x2ciUtMRl8N4mQrTjgz2d/U7gPSwovHOkybZZ02akSJLEGh47CX8UETGvSJqtZV90T6XsmnxHOPGJY00mb9OTiMQwOL0cJKETojHsJM9O4n8MO8Hwc5g37Zcx/C3sEoZf5jkr@H09ZzHv@EOS4e9qXcif7WB/eRju95Us85VefC9kt66bcrALCP1/NNjLfw "Clean – Try It Online")
Snappy compression actually does pretty well in this case, despite being speed-focused, because there are so many single-character runs in the string being compressed.
The uncompressed string (with `#` replaced with `\n` for clarity) is:
```
!!!-. ! |:! |:!-' !!!
!!!~.--------. !~|        |:!~|        |:!~'--------' !!!
!!!~~~~~~~~~~.--------.!~~~~~~~~~~|        |!~~~~~~~~~~|        |!~~~~~~~~~~'--------'!!!
!!-------.   !       | '.!       |  |!       |  |!       | .'!-------'   !!
!!~~~~~~~.--------------.!~~~~~~~|              |!~~~~~~~|              |!~~~~~~~|              |!~~~~~~~|              |!~~~~~~~'--------------'!!
__      !  |'.   !  |   '.!  |    |!  |    |!  |    |!  |    |!  |   .'!__|.'   !
~~ ________________________ !~~|                        |!~~|                        |!~~|                        |!~~|                        |!~~|                        |!~~|                        |!~~|                        |!~~|________________________|!
'. !  |!  |!  |!  |!  |!  |!  |!  |!.' 
```
This encodes the left-side versions of the different screen components with `!` instead of newlines, and `~` instead of `?`, which are then right-padded with `~` to 30 characters before having themselves and their line-reversals added to a lookup list.
The rest of the code simply handles coordinate lookup with out-of-bounds cases ignored.
[Answer]
# [Python 2](https://docs.python.org/2/), ~~864~~ ~~854~~ ~~848~~ ~~826~~ 810 bytes
```
L=[zip(*[iter(w)]*30)for w in zip(*[iter("eJzdllESgyAMRL+5Rf7yRQ7AZbhIDl9BwTqzSVtHrbKffR0Mm13HEM5SFHIoadpNI3snDyaS6NCknhU+JfZOvq8kLoIBU1oEI+RTbiePGzBa3QM0rf78TGl17+CZr5ZrUXBN+ECfY1GvGKEqtDsSI4s6xTn5jgqyqNcTTnUjTQO2FAEqTC0ngCrtpywenX5le6or1SsGi9ZLBKt0HuXtVEeUNGdzG6EsRNmo2EzLxuBbqFH8njmfwnqGcl+VY+s5+5ezSYXVel4dxaRK/6F15SatK1frvm//y4aoT4Ckj6XWfY2cbvz2fLSCPiiVvR+3ZuerzDwPSqeSvgAP9woa".decode('base64').decode('zip'))]*300)]
E=enumerate
def f(m,x,y,d):
 D=eval(`[[' ']*30]*10`);w,h=len(m[0]),len(m);a=[m,zip(*m)[::-1]][d%2];x,y=[x,y,w+~x,h+~y,y,w+~x,h+~y,x][d::4];X=sum([[0]*(x<2)+list(l)[x-2+(x<2):x+3]for l in[l*2for l in[a,[l[::-1]for l in a[::-1]]][d/2]*2][y:y+4]],[])
 for d,w in zip(L,'sropqmklhfgca'):
  for j,l in E(d):
   for i,q in E(l):
    if q*X[ord(w)%32]>=' ':D[j][i]=q
 for l in D:print''.join(l)
```
[Try it online!](https://tio.run/##fVNpb9pKFP3Or7AqRbbxtPFO4jw/KYADlKUJNpQwGqkGj8HEC17Ay4f@9bzB5EWJmlQa6c4cnzn3@p47@zLbRqH4/DzSYeXtmSb0MpwwOYuaEs@6UULllBdSbz59wd8rx/cNc1PejqcjTpm6rXL60LpdrraDrn/dzq24MudZP1kNXXfKjwNB6htjxbzrDyLb2U8GUhp2S9tUJ52ncDvjvrvLH8f46mkUDdozITIG3NRaefi@V7Vt6WHMJ27ryur5QovrLBNlmcwW7QlndNxHoXfsDY0466bmQE7VwgqV3SYu48nassLZznr4Id7dGrHV4cNNJ8n2ZY7DheJjNUoEM@1518tRe5jx/cMimxt4Nuk5VU810ukkiESjGhWH9iq@61@Fu8DNw7i39rn5I5cqnIIr83Exx77sFPZ0eKneCYppZ0PBTY7B5WUp25Eld5526uKn@yiuV8dKdEdm597z5scpJy0POKm6@b0ZY/O4ub2/ziP7yzcHryMHM/TKTrEq0@wrQFpPs7UdPIsaho7DQ4ATO8MNB7uUywSgACVwWK1BdXV8tH3mF4Q0RZ9uoKbA/2JvcrDVfRwyAeQRC@ode2PrMAC1rwELNe2rgBB0LkR0Q@R0eNLMud8F2HK/y3f7gtA0TUY3Cz09BAwkmk2m@EdkOd9LM8ZnYfFV5GpEKzgJnWbIJzME/ab4urcB9M9J/4co@6UIIn8poqaIYKmVnIwQgIhtUCeeA16HcQToNIn2cfDkb93N2qZP/1@TdqCWM5i6JWfMA/EZ888Y5blU3FzAKHHIqF9IIvpXJy3TunCHoIf0@JyvFupq@8QLM5r@tou8kCg8j3VIQUoAny8KAZKm5vBvcP7N@pPDv@EIH3HeXf@cI7ynfcYRPtf5sOC/1/Mh5y/9oVCjcWpxPbunNkMJSIAnZqtABhKJMokCiQJQgEhiC7RqXAVqjV8B4QU/nYmtjs44nMheyA2qdow5vwtiJTN@eSPP/wE "Python 2 – Try It Online")
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), ~~500~~ 332 bytes
```
Ｆ⁴≔⮌Ｅ§θ⁰⁺00⭆θ§μλθ≔Ｅ✂θ⊖ζ⁺⁶ζ¹✂ι⊖η⁺⁶η¹θＦε≔⮌Ｅ§θ⁰⭆θ§μλθＢ³⁰χ Ｆ²«‖ＦΦ⪪⟦“ ｜0⟧Ｐ+Ｎ？⟧‹Ｇ”³¦⁰”{➙d⊟ＥＸ⍘k↧D({Ｖt⍘gＲd◨ⅉ^δ#T；”³¦¹“ ¶↖+9Ｇ₂pＦ^c1e⌈¬；”³χω⁰χ”{➙∧⊟∧◨ηü∧↖z↨⁸\G'λＩ∧¡∕⪫θＪoΣ³⊖Ｉ⊟ζ⊙”²¦⁰”{➙∧⊟∧◨ηü∨§·◧﹪d‹⟲ ＯzºκＦⅉＲï⎇”²¦⁷ω⁰χ”{➙∧⊟≔⊘⬤|↔3Ｚθ✂≔÷t⍘ε✂↨≔⧴×ld≕≡⌕m⟧6ψ=Ｚ”⁰¦⁰”}∧80ＫυgCAêＪm⟦↘/§‖Ｃk⮌Ｃ₂¡μ↗Ｗ”⁰¦²ω⁰χ”{⊟∨·◧¤∨¶⧴⬤2ＧＬ▷⁸ê5Ｇψ”⁰¦⁰⟧³Ｉ§⭆θ⭆³§μ⎇ι⊕ξ⁻⁵ξλ«Ｊ⁻⊟κ×²⁹¬ι⊟κ⊟κ
```
[Try it online!](https://tio.run/##tZPLbuIwFIbX8BRH2cSRTJRAL@rMqp3RSB2pFSrsWhRFqVushoQmbsVMw7OnxzeIJaBsapzgy@f//HZ8snlaZWWat@1TWQE5CeCyrvlzQe7YO6tqRm7SJbkU18UjW5FXClFAYZy/1cSLIo/CRFS8eJYMzllsQSEPZKHwGvzsG0EJTXKeMYn@ZlnFFqwQ7JH8t5JnFGQ7xkeD3AXnHXCuQBNBWWfHWD/oV4tdlSsyilAdHw88Kz8M4KPfu2NPOcsEwdGeGv7Dc8EqMlnmXJB7bxDCQwHND/Ma@ICHNMLYqBUOTJFMA6ZIzOn4FrNrY7vWgJs/RRpGBvBUHNXcRJKcFQc/7HSg2dcJfXRuPYB0MXR3sHX8VctuRmucuyaTxGIY1bde5WJtVMk0x7Wk5yRpQmM40oYh6ZTOObs2v6HbjavtDN29@6He7FGv0Ld7muHXxnv6K63F5mo7d3rbGTkXfMqqIq3@yZS6LrYptUKxG15gTp1SWJmkVckgb3vv79tiOS2JJsblkrzg9JQvWE2GFxRuS0G4WqLnZFb0xmhAkO3Aur9u23uQv5jurzCjfXl4ioo6M1Gn7qKiDhXvphyJQ1Tsgvup@JDWTutf@dpDHTgv5OBE1XjWDt7zTw "Charcoal – Try It Online") Link is to verbose version of code. Somewhat boring approach, I'm afraid; lots of printing of compressed string literals. Explanation:
```
Ｆ⁴≔⮌Ｅ§θ⁰⁺00⭆θ§μλθ
```
Pad the array with two extra `0`s on each side.
```
≔Ｅ✂θ⊖ζ⁺⁶ζ¹✂ι⊖η⁺⁶η¹θ
```
Slice a `7x7` subsection of the array centred on the given coordinates.
```
Ｆε≔⮌Ｅ§θ⁰⭆θ§μλθ
```
Rotate the array as appropriate for the given direction.
```
Ｂ³⁰χ 
```
(note trailing space) Draw an empty `30×10` box so that the output is always a consistent size.
```
Ｆ²«‖
```
Draw each half separately, reflecting in between.
```
ＦΦ⪪⟦...⟧³Ｉ§⭆θ⭆³§μ⎇ι⁻⁵ξ⊕ξλ«
```
Take an array of wall descriptors, split into chunks of (string, y-coordinate, x-coordinate), filter on those chunks that have a wall at the relevant position in the relevant half of the array, and loop over the walls. The position is calculated by extracting 12 walls from the array and indexing them using the chunk index as this is golfier than locating the wall directly using the chunk index.
```
Ｊ⁻⊟κ×²⁹¬ι⊟κ⊟κ
```
Jump to the coordinates of the wall and print it. Note that reflecting negates the X-coordinates from `[0, 30)` to `(-30, 0]` so that on one pass the canvas is effectively shifted 29 characters to the left.
[Answer]
# [Ruby](https://www.ruby-lang.org/), ~~412 391 385~~ 383 bytes
```
->a,x,y,d{b=Array.new(97){[" "]*10}
e=[-1,0,1,0]
14.times{|i|m=-i%3-1
w=[31,25,15,9][n=i>2?4-i/3:(m*=2;3)]
(a*3)[y+n*e[d]+m*c=e[d-3]][x+n*c-m*e[d]]&&[p=w*(m*2-1)/2,r=[12,7,4,3][n]*m*m.abs+m/3].min.upto([q=w*(m*2+1)/2,r].max){|j|t=" .'"*9
b[j+15]=(p<j&&j<q ?%w{-%2s- -%4s- _%7s_}[-n]%"":t[k=(j^j>>9)%(36/-~n)]+"   :|  |    |"[k%13]*(k/3*2)+t[-k]).center(10).chars}}
b[0,30].transpose}
```
[Try it online!](https://tio.run/##nZNtb5swEMff8ylOSGRgbMCYJEtWp9rnsLyKJHSDDIfyoCQC9tVTl1Z7k6Sikc6nk@9/vzud7LJZn87P/ExWMT7iE962a/6zLOOTp5KDvZg7rTDBlIgGvZFwQSgOsD7SoJFXp3lStV3a5ZykFiPUOHDBKA6nmE7xQgrF01X4GJHUZ0s7Rzz8wRxp2DFijji5CiViK90cbbgOCJNSHPXlhuRDQk4mouAHpAtDQh0/xCUXNMRzHGGm2RLlKPfideXmPpNeniqvKeq9LV4@itz3Ip2Kj07bZV3NTfC@mWhhrEXm0qnkdvGQTSbZwws8WoeWWGFFgFiR9k/WvHrqBVHSMs1lLXbczn5lq9XCsWw288k/5UjXBIBlB6BNO1PsLMoksnc@Q6Hj1oLspONtElUnpU0DHf6Jy6rvdfsAs0B6dRmrqthXSX/eNup3sldcgIC6bBJ8lweJDfhPUOlfuKZ8v7/0nxMu4@vZa4TPOn6FcIv5VcKt/dwijN/hfXsYQ7jvPYA0jKKpK3gWH08MAxssePsYxdv3Tb1sn6p@0F2IZxgirR8njgaj48QUwxRDOE48H4yNnnk2eozvwyTjx7hKPr8C "Ruby – Try It Online")
Takes input as an array of truthy/falsy values (note `0` is truthy in Ruby, but `nil` is falsy.) 
Outputs an array of characters.
**Explanation**
Blocks are drawn front to back with distance `n` decreasing and side to side position `m` cycling through `-1,1,0` left,right,middle. The middle block E in the furthest row is actually drawn twice because we need to check both blocks A/B and blocks C/D. `n,m` and `d` are used to modify the `x` and `y` values to search array `a`. If `x` is out of range `nil` is returned for an out of range cell and no error is thrown, but if `y` is out of range `nil` will be returned for the row and Ruby will throw a type error when it tries to search for the cell. To avoid this the array is triplicated in the vertical direction prior to searching. If a truthy value is found a block is drawn.
The output is built in an array `b` of 10-element arrays representing the columns of the output, and is transposed into 10 rows at the end of the function. The full front face of all blocks is drawn (whether it appears in the viewport or not) so additional space is needed in the array to avoid out of range errors. The range of `j` values in the viewport is from `-15` to `+14`, this is offset by 15 when saving to the array to give a range of `0` to `29`. For each block drawn three values are calculated: `p` and `q` for the left and right corners of the front wall respectively, and `r` for the back of the side wall. `j` is iterated from the minimum to the maximum of these three values drawing the columns in turn.
There are 3 types of lines: horizontal `-` or `_`, vertical `|` or `:`, and diagonal with a repeating `" .'"` pattern. Where `p < j < q` columns containing spaces capped with `-` or `_` are drawn to form the front face. Where `j` is outside this range, columns containing space, `|` or `:` are drawn capped with symbols from `t=" .'"` to form the edges and/or side face. This is managed by variable `k=j` where `j` is positive or `k=-j-1` where `j` is negative. The number of characters between the top and bottom caps is `k/3*2`. In order to correctly handle the outer edges of the furthest blocks where `n=3`, `k` must be taken modulo 9, but this must not be done for smaller values of `n`. `k` is therefore taken modulo `36/-~n`, where `-~n` evaluates to `n+1`.
**Ungolfed code**
```
->a,x,y,d{
  b=Array.new(97){[" "]*10}                                        #Set up array for output, allow space for plotting outside viewport
  e=[-1,0,1,0]                                                     #Direction offsets from player position
  14.times{|i|                                                     #Iterate through all blocks including block E twice 
    m=-i%3-1                                                       #Cycle -1,1,0 = left, right, centre
    n=i>2?4-i/3:(m*=2;3)                                           #Distance n=4-i/3. But if i/3==0 n=3 and double m for blocks A,B 
    w=[31,25,15,9][n]                                              #Width of front face of block
    r=[12,7,4,3][n]*m*m.abs+m/3                                    #Value of j for back edge of block. m/3 offsets by -1 when m negative 
    (a*3)[y+n*e[d]+m*c=e[d-3]][x+n*c-m*e[d]]&&(                    #If a block is present at the location then
      [p=w*(m*2-1)/2,r].min.upto([q=w*(m*2+1)/2,r].max){|j|        #Calculate left and right edges of front of block p,q and iterate
        t=" .'"*9                                                  #t=character constant for diagonal lines 
        k=(j^j>>9)%(36/-~n)                                        #k=j for positive j=distance from centre. For negative j, k=-1-j by XOR with j>>9=-1. If n=3 take modulo 9 for correct output of outer side of block. 
        b[j+15]=(p<j&&j<q ?%w{-%2s- -%4s- _%7s_}[-n]%"":           #If j between p&q, draw horizontal lines separated by 2,4 or 7 spaces depending on value of n
        t[k]+"   :|  |    |"[k%13]*(k/3*2)+t[-k]).center(10).chars #else draw space or vertical line capped by diagonal markers
      }
    )
  }
b[0,30].transpose}                                                 #Truncate values outside viewport, transpose, and return value.
```
]