# Help and Questions

**URL:** https://forum.makecode.com/t/help-and-questions/1335
**Category:** Help
**Created:** [March 5, 2020, 10:48pm UTC](https://forum.makecode.com/t/help-and-questions/1335 "2020-03-05T22:48:55Z")
**Posts on this page:** 20
**Page:** 5

<div class="post-metadata">

### Author: ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)
#### Post date: [February 8, 2024, 6:28pm UTC](https://forum.makecode.com/t/help-and-questions/1335/89 "2024-02-08T18:28:12Z")

</div>

fixed!

---

<div class="post-metadata">

### Author: ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)
#### Post date: [February 8, 2024, 8:02pm UTC](https://forum.makecode.com/t/help-and-questions/1335/90 "2024-02-08T20:02:31Z")

</div>

working on dithering:

> **[2-d raycasting](https://arcade.makecode.com/45935-66617-77306-17791)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

### Author: ![randomuser](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/randomuser/32/32505_2.png) [@randomuser](https://forum.makecode.com/u/randomuser)
#### Post date: [February 8, 2024, 8:03pm UTC](https://forum.makecode.com/t/help-and-questions/1335/91 "2024-02-08T20:03:47Z")

</div>

WOOOOOAAAAAAAHHH!!  
That’s stunningly beautiful! The raycasting in itself is an art, this would look so good combined with a game…

---

<div class="post-metadata">

### Author: ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)
#### Post date: [February 8, 2024, 8:06pm UTC](https://forum.makecode.com/t/help-and-questions/1335/92 "2024-02-08T20:06:14Z")

</div>

shadowcasting is a more accurate term! I should probably have renamed the project

---

<div class="post-metadata">

### Author: ![Mr\_Duck](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/mr_duck/32/13442_2.png) [@Mr\_Duck](https://forum.makecode.com/u/Mr_Duck)
#### Post date: [February 8, 2024, 9:05pm UTC](https://forum.makecode.com/t/help-and-questions/1335/93 "2024-02-08T21:05:15Z")

</div>

Wow that’s cool

---

<div class="post-metadata">

### Author: ![Mr\_Duck](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/mr_duck/32/13442_2.png) [@Mr\_Duck](https://forum.makecode.com/u/Mr_Duck)
#### Post date: [February 8, 2024, 9:05pm UTC](https://forum.makecode.com/t/help-and-questions/1335/94 "2024-02-08T21:05:18Z")

</div>

And I’m glad you noticed because I put that intentionally 😃

---

<div class="post-metadata">

### Author: ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)
#### Post date: [February 8, 2024, 9:21pm UTC](https://forum.makecode.com/t/help-and-questions/1335/95 "2024-02-08T21:21:53Z")

</div>

dithering is now available in the extension! It runs pretty well even though I haven’t optimized anything yet. Expect it to get faster, though!

---

<div class="post-metadata">

### Author: ![YuHayate](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/yuhayate/32/8275_2.png) [@YuHayate](https://forum.makecode.com/u/YuHayate)
#### Post date: [February 9, 2024, 9:40pm UTC](https://forum.makecode.com/t/help-and-questions/1335/96 "2024-02-09T21:40:22Z")

</div>

nice!

---

<div class="post-metadata">

### Author: ![YuHayate](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/yuhayate/32/8275_2.png) [@YuHayate](https://forum.makecode.com/u/YuHayate)
#### Post date: [February 9, 2024, 9:40pm UTC](https://forum.makecode.com/t/help-and-questions/1335/97 "2024-02-09T21:40:29Z")

</div>

pretty cool, but when using the normal 16x16 tilemap you dont get to see much of the dithering  
most of the time you only see half of the dithered tiles, so i was thinking maybe adding a setting for that?

---

<div class="post-metadata">

### Author: ![YuHayate](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/yuhayate/32/8275_2.png) [@YuHayate](https://forum.makecode.com/u/YuHayate)
#### Post date: [February 9, 2024, 9:43pm UTC](https://forum.makecode.com/t/help-and-questions/1335/98 "2024-02-09T21:43:50Z")

</div>

hey @richard, i was making a dithering algorithm i mad faster by using bit shifting but i does not work anymore, it does not give me a error but the dithering does not work anymore?  
with bit shifting

> **[ditering #2 bit shifting](https://arcade.makecode.com/06924-79837-31980-33383)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

without

> **[ditering #2 no bit shifting](https://arcade.makecode.com/25396-75284-88982-39163)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

i tried to add parentheses when i made this post but that also didn’t work

> **[ditering #2 bit shifting and parentheses](https://arcade.makecode.com/55863-03105-31982-45800)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

what am i doig wrong?  
(if you want to test with a smaller image you can change the return block in the “TheImage” function, also do it in blocks it will save you some problems) (for creating a new image i havent made a website for it yet as I’m still stuck on html so for now you can use [this](https://onlinetools.com/image/convert-image-to-hex-codes))

---

<div class="post-metadata">

### Author: ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)
#### Post date: [February 9, 2024, 10:32pm UTC](https://forum.makecode.com/t/help-and-questions/1335/99 "2024-02-09T22:32:23Z")

</div>

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

@YuHayate looks like you’re trying to do bitshifting in order to replace the division by 16 in your code. Bitshifting does indeed work for that, but it’s integer division. That means it will cut off the decimal point component of the result. All of those fractions above have numerators that are less than 16, meaning that bitshifting to the right by 4 will simply return 0.

---

<div class="post-metadata">

### Author: ![YuHayate](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/yuhayate/32/8275_2.png) [@YuHayate](https://forum.makecode.com/u/YuHayate)
#### Post date: [February 11, 2024, 9:52pm UTC](https://forum.makecode.com/t/help-and-questions/1335/100 "2024-02-11T21:52:47Z")

</div>

if that’s so shouldn’t the dithering just not spread the error instead of not working?

---

<div class="post-metadata">

### Author: ![YuHayate](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/yuhayate/32/8275_2.png) [@YuHayate](https://forum.makecode.com/u/YuHayate)
#### Post date: [February 11, 2024, 9:52pm UTC](https://forum.makecode.com/t/help-and-questions/1335/101 "2024-02-11T21:52:55Z")

</div>

also now that i read this twice idk if you looked at what i sent  
those variables are there only in the one without bit shifting (only used there)  
insted of doing

```auto
errR * 7/16
errG * 7/16
errB * 7/16
// ect

```

i did

```auto
(errR * 7) >> 4
(errG * 7) >> 4
(errB * 7) >> 4

```

---

<div class="post-metadata">

### Author: ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)
#### Post date: [February 12, 2024, 7:18pm UTC](https://forum.makecode.com/t/help-and-questions/1335/102 "2024-02-12T19:18:03Z")

</div>

@YuHayate i’m not really sure what your code is trying to do, so it’s tough for me to debug it. were you basing this off of some pre-existing code?

---

<div class="post-metadata">

### Author: ![YuHayate](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/yuhayate/32/8275_2.png) [@YuHayate](https://forum.makecode.com/u/YuHayate)
#### Post date: [February 12, 2024, 10:14pm UTC](https://forum.makecode.com/t/help-and-questions/1335/103 "2024-02-12T22:14:53Z")

</div>

yea its the floyd steinberg dithering algorithm

---

<div class="post-metadata">

### Author: ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)
#### Post date: [February 12, 2024, 11:11pm UTC](https://forum.makecode.com/t/help-and-questions/1335/104 "2024-02-12T23:11:05Z")

</div>

I’m pretty sure my earlier comment on this stands. This algorithm requires the decimal component of the error for whatever reason so bitshifting isn’t going to work.

If you really wanted to do bitshifting, you could represent everything as fixed point numbers (that’s what the Fx8 stuff in Arcade is for). That being said, it’s not going to make your program faster in the browser. On hardware, yes, but your computer has absolutely no trouble doing regular old division.

---

<div class="post-metadata">

### Author: ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)
#### Post date: [February 12, 2024, 11:33pm UTC](https://forum.makecode.com/t/help-and-questions/1335/105 "2024-02-12T23:33:33Z")

</div>

if you’re looking to speed up this code, I think you might want to reconsider how you’re representing your image. A string of all the hex codes is going to be tough to work with and parsing all those many thousands of pixels will be pretty slow.

How did you generate this string in the first place? I think you’ll have more luck if you rewrite whatever script you have to output a buffer instead. Buffers are like arrays of bytes and you can define them using the syntax:

```auto
hex`00112233445566778899aabbccddeeff`

```

Each two numbers in that string represents a byte in hexadecimal format. Fun fact, those HTML color codes you have in your string are also hexadecimal strings, so you can convert it into a hex buffer simply by removing the #, space, quotes, and comma characters from your string and wrapping it in the `hex`` ` syntax!

Once you have it in a buffer, you can access pixel data like so:

```auto
const myImage = hex`aabbcc`

function getR(image: Buffer, index: number) {
    return image[index * 3]
}

function getG(image: Buffer, index: number) {
    return image[index * 3 + 1]
}

function getB(image: Buffer, index: number) {
    return image[index * 3 + 2]
}

```

---

<div class="post-metadata">

### Author: ![YuHayate](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/yuhayate/32/8275_2.png) [@YuHayate](https://forum.makecode.com/u/YuHayate)
#### Post date: [February 15, 2024, 12:06am UTC](https://forum.makecode.com/t/help-and-questions/1335/106 "2024-02-15T00:06:38Z")

</div>

hmmm. brain hurt. (👉ﾟヮﾟ)👉

---

<div class="post-metadata">

### Author: ![unknown\_Ink1](https://avatars.discourse-cdn.com/v4/letter/u/8797f3/32.png) [@unknown\_Ink1](https://forum.makecode.com/u/unknown_Ink1)
#### Post date: [February 15, 2024, 12:06am UTC](https://forum.makecode.com/t/help-and-questions/1335/107 "2024-02-15T00:06:40Z")

</div>

@richard How do I make a sprite clip through a wall in 3D rendering mode?

---

<div class="post-metadata">

### Author: ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)
#### Post date: [February 15, 2024, 12:11am UTC](https://forum.makecode.com/t/help-and-questions/1335/108 "2024-02-15T00:11:14Z")

</div>

@unknown_Ink1 did you try setting “ghost through walls” on the sprite?

![ghost-through-walls](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/6/61c9fe5235347f8dfa0e9960295ee4d4cbb6739b.gif)

[Previous page](https://forum.makecode.com/t/help-and-questions/1335.md?page=4)

[Next page](https://forum.makecode.com/t/help-and-questions/1335.md?page=6)
