# Sneaking Demo

**URL:** https://forum.makecode.com/t/sneaking-demo/4961
**Category:** Arcade
**Tags:** game
**Created:** [December 12, 2020, 12:52am UTC](https://forum.makecode.com/t/sneaking-demo/4961 "2020-12-12T00:52:51Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![felixtsu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/felixtsu/32/12024_2.png) [@felixtsu](https://forum.makecode.com/u/felixtsu)
#### Post date: [December 12, 2020, 2:48am UTC](https://forum.makecode.com/t/sneaking-demo/4961/3 "2020-12-12T02:48:06Z")

</div>

For anyone interested, a simply illustration of the basic idea behind sensing with wall is here:

Sprite A can see sprite B if:  
a) distance between A and B is less than or equal to range of sensing;  
AND  
b) there’s no wall between

For a), distance can be calculated by square root of (deltaX^2 + deltaY^2)

For b), consider the following,

 ![Image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/1/1287f63793fd218ef814202eda01ad0bf02c4121.jpeg)  
in which,

1. finding the critical points requires some geometric calculation (similar triangles, tan/arctan)
2. tilemap ext is useful for checking if a certain tile is wall

An interactive demo is here, the line between the sprites is drawn and critical lat/long tiles are colored (lats are purple, longs are red).

> **[demo.sight](https://arcade.makecode.com/03708-34411-82502-44363)**
>
> 用❤️创造，Microsoft MakeCode Arcade出品。

Try moving sprites and changing range parameter (set to 128, full screen)

After that, on the shoulder of @richard, [the shader ext](https://forum.makecode.com/t/shader-extension/4860) is useful for showing enemy alert range for player.

---

_[View the full topic](https://forum.makecode.com/t/sneaking-demo/4961)._
