# Line tracing (I think)

**URL:** <https://forum.makecode.com/t/line-tracing-i-think/21488>\
**Category:** Help\
**Tags:** graphics-and-math\
**Created:** [July 25, 2023, 9:12pm UTC](https://forum.makecode.com/t/line-tracing-i-think/21488 "2023-07-25T21:12:00Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![broc](https://avatars.discourse-cdn.com/v4/letter/b/8797f3/32.png) [@broc](https://forum.makecode.com/u/broc)\
**Post date:** [July 25, 2023, 9:12pm UTC](https://forum.makecode.com/t/line-tracing-i-think/21488/1 "2023-07-25T21:12:00Z")

</div>

how do you make an object trace a line on its path ( I guess I should call it path tracing)  
like in missile command I tried for hours nothing worked.

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [July 25, 2023, 10:28pm UTC](https://forum.makecode.com/t/line-tracing-i-think/21488/2 "2023-07-25T22:28:21Z")

</div>

Do you want path finding?

If so, there is a built-in “dumb” version:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/c/c49dd71eb13446b643ae4361a4097c8f26e739c6.png)  
(which doesn’t follow around walls)

There is an extension for A\*, a path finding algorithm that works with the walls in a tilemap. Warning: On big tilemaps with long distances and lots of walls, it can be slow.

> **[GitHub - jwunderl/arcade-tilemap-a-star: a star implementation for tilemaps...](https://github.com/jwunderl/arcade-tilemap-a-star)**
>
> a star implementation for tilemaps in pxt-arcade ---beta - GitHub - jwunderl/arcade-tilemap-a-star: a star implementation for tilemaps in pxt-arcade ---beta

* * *

Self-promotion: You can find lots of Arcade extensions like the one above at my website, _Awesome Arcade Extensions._

> **[Home | Awesome Arcade Extensions](https://awesome-arcade-extensions.vercel.app/)**
>
> This is a list of MakeCode Arcade extensions that I find super useful (or just plain cool) in my projects.

---

<div class="post-metadata">

**Author:** ![Luke](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/luke/32/32519_2.png) [@Luke](https://forum.makecode.com/u/Luke)\
**Post date:** [July 25, 2023, 10:32pm UTC](https://forum.makecode.com/t/line-tracing-i-think/21488/3 "2023-07-25T22:32:13Z")

</div>

You could draw lines from the sprite’s current location to its location a set time (idk 1 second) ago. Set an x and y variable and just update them every second so that when you need to read information from them you will have the position the sprite was at 1 second ago and you can easily get the sprites current location.

---

<div class="post-metadata">

**Author:** ![broc](https://avatars.discourse-cdn.com/v4/letter/b/8797f3/32.png) [@broc](https://forum.makecode.com/u/broc)\
**Post date:** [July 26, 2023, 4:52pm UTC](https://forum.makecode.com/t/line-tracing-i-think/21488/4 "2023-07-26T16:52:24Z")

</div>

yeah that Would work but if you watch missile command gameplay the pixel get drawn every time the missile moves how would I do that

---

<div class="post-metadata">

**Author:** ![AqeeAqee](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/aqeeaqee/32/5424_2.png) [@AqeeAqee](https://forum.makecode.com/u/AqeeAqee)\
**Post date:** [July 26, 2023, 5:03pm UTC](https://forum.makecode.com/t/line-tracing-i-think/21488/7 "2023-07-26T17:03:12Z")

</div>

As @UnsignedArduino said, the A\* extension can find a shortest path between two locations.

Actually, this extension also exposed following path feature, not only the shortest one found, but also any path consis of path waypoints(an arrray of locations). Call this directly with your waypoints maybe your solution I guess.

![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/3/3bf2647b4e6fd0edd6088fcb579742b844edaab2.png)

---

<div class="post-metadata">

**Author:** ![broc](https://avatars.discourse-cdn.com/v4/letter/b/8797f3/32.png) [@broc](https://forum.makecode.com/u/broc)\
**Post date:** [July 26, 2023, 5:27pm UTC](https://forum.makecode.com/t/line-tracing-i-think/21488/8 "2023-07-26T17:27:44Z")

</div>

thank you that worked I’m dumb sorry.  
thank you bye the way

---

<div class="post-metadata">

**Author:** ![jwunderl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jwunderl/32/5308_2.png) [@jwunderl](https://forum.makecode.com/u/jwunderl)\
**Post date:** [July 26, 2023, 5:30pm UTC](https://forum.makecode.com/t/line-tracing-i-think/21488/9 "2023-07-26T17:30:20Z")

</div>

Just to chime in, it’s not dumb to not know something (especially if it’s some weird math thing or whether a program exists or not) – there’s an infinite amount of things to learn out there, not knowing one of them isn’t ever a big deal 🙂.

![image of xkcd "Ten Thousand" comic image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/0/02fdb36d996751cec25ed6617767e986bc9e95e2.png)

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [July 26, 2023, 5:41pm UTC](https://forum.makecode.com/t/line-tracing-i-think/21488/10 "2023-07-26T17:41:50Z")

</div>

More self promotion: I’ve also made an extension that allows you to use joey’s pathing extension between locations on a tilemap, similar to what AqeeAqee said. This is good for games with a predetermined path.

> **[GitHub - UnsignedArduino/TilemapPath: Have sprites follow paths on tilemaps...](https://github.com/UnsignedArduino/TilemapPath)**
>
> Have sprites follow paths on tilemaps in MakeCode Arcade! - GitHub - UnsignedArduino/TilemapPath: Have sprites follow paths on tilemaps in MakeCode Arcade!

> Don’t manually place walls to make your A-star paths do what you want, use this! You can set a sprite to follow a path between tilemap locations and have handlers when they finish. Note that everytime you set a path, it will recalculate the paths using the A-star extension which can take a long time depending on how big the tilemap is and how many elements there are. This extension adds a `TilemapPath` category.  
> [https://awesome-arcade-extensions.vercel.app/?q=tilemappath#UnsignedArduino/TilemapPath](https://awesome-arcade-extensions.vercel.app/?q=tilemappath#UnsignedArduino/TilemapPath)

---

<div class="post-metadata">

**Author:** ![Luke](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/luke/32/32519_2.png) [@Luke](https://forum.makecode.com/u/Luke)\
**Post date:** [July 26, 2023, 9:24pm UTC](https://forum.makecode.com/t/line-tracing-i-think/21488/11 "2023-07-26T21:24:53Z")

</div>

Do you want a visible trail or pathfinding?

---

<div class="post-metadata">

**Author:** ![broc](https://avatars.discourse-cdn.com/v4/letter/b/8797f3/32.png) [@broc](https://forum.makecode.com/u/broc)\
**Post date:** [July 27, 2023, 4:15pm UTC](https://forum.makecode.com/t/line-tracing-i-think/21488/12 "2023-07-27T16:15:42Z")

</div>

a visible trail
