# Help with pixel art end math issue's

**URL:** https://forum.makecode.com/t/help-with-pixel-art-end-math-issues/18809
**Category:** Arcade
**Tags:** extension, make, art, graphics-and-math, game
**Created:** [March 27, 2023, 11:15pm UTC](https://forum.makecode.com/t/help-with-pixel-art-end-math-issues/18809 "2023-03-27T23:15:28Z")
**Posts on this page:** 20
**Page:** 1

<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: [March 27, 2023, 11:15pm UTC](https://forum.makecode.com/t/help-with-pixel-art-end-math-issues/18809/1 "2023-03-27T23:15:28Z")

</div>

ask me any questions you have i will do my best to answer them.

---

<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: [April 3, 2023, 4:36pm UTC](https://forum.makecode.com/t/help-with-pixel-art-end-math-issues/18809/2 "2023-04-03T16:36:01Z")

</div>

@richard  
Do you know what i’m doing wrong here?

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

---

<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: [April 3, 2023, 5:02pm UTC](https://forum.makecode.com/t/help-with-pixel-art-end-math-issues/18809/3 "2023-04-03T17:02:45Z")

</div>

@YuHayate I’m afraid that screenshot is a tad too small for me to read. Can you share a link to the 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: [April 3, 2023, 6:40pm UTC](https://forum.makecode.com/t/help-with-pixel-art-end-math-issues/18809/5 "2023-04-03T18:40:10Z")

</div>

> **[minigame](https://arcade.makecode.com/58794-30411-83594-04985)**
>
> Fait avec ❤️ dans Microsoft MakeCode Arcade.

---

<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: [April 4, 2023, 6:23pm UTC](https://forum.makecode.com/t/help-with-pixel-art-end-math-issues/18809/6 "2023-04-04T18:23:53Z")

</div>

ah, this is a bug in arcade but there’s an easy workaround! you need to make sure a tilemap is defined before calling the “array of all \_\_\_ locations” block.

---

<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: [April 4, 2023, 7:52pm UTC](https://forum.makecode.com/t/help-with-pixel-art-end-math-issues/18809/7 "2023-04-04T19:52:11Z")

</div>

but it it already is

---

<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: [April 4, 2023, 7:58pm UTC](https://forum.makecode.com/t/help-with-pixel-art-end-math-issues/18809/8 "2023-04-04T19:58:42Z")

</div>

ah, i see… looks like there’s another issue in the for loop you posted the screenshot of. the bounds of our for loops are _inclusive_, meaning you want the max to be the length of the array minus 1 and not just the length.

or try using a for-of loop instead!

---

<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: [April 5, 2023, 3:43pm UTC](https://forum.makecode.com/t/help-with-pixel-art-end-math-issues/18809/9 "2023-04-05T15:43:55Z")

</div>

i works but the camera dosent move from zones

> **[minigame](https://arcade.makecode.com/51420-18932-39055-55014)**
>
> Fait avec ❤️ dans Microsoft MakeCode Arcade.

---

<div class="post-metadata">

### Author: ![ChimbroDaPro](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/chimbrodapro/32/15852_2.png) [@ChimbroDaPro](https://forum.makecode.com/u/ChimbroDaPro)
#### Post date: [April 5, 2023, 3:47pm UTC](https://forum.makecode.com/t/help-with-pixel-art-end-math-issues/18809/10 "2023-04-05T15:47:03Z")

</div>

> [@richard](#):
>
> I’m afraid that screenshot is a tad too small for me to read.

I don’t think I’ve EVER heard anyone else say tad in my entire life.

---

<div class="post-metadata">

### Author: ![ChimbroDaPro](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/chimbrodapro/32/15852_2.png) [@ChimbroDaPro](https://forum.makecode.com/u/ChimbroDaPro)
#### Post date: [April 5, 2023, 3:47pm UTC](https://forum.makecode.com/t/help-with-pixel-art-end-math-issues/18809/11 "2023-04-05T15:47:04Z")

</div>

I like it though.

---

<div class="post-metadata">

### Author: ![Sarge](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/sarge/32/19590_2.png) [@Sarge](https://forum.makecode.com/u/Sarge)
#### Post date: [April 5, 2023, 3:48pm UTC](https://forum.makecode.com/t/help-with-pixel-art-end-math-issues/18809/12 "2023-04-05T15:48:40Z")

</div>

Isn’t the MakeCode built-in loop a foreach loop?

---

<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: [April 25, 2023, 4:35pm UTC](https://forum.makecode.com/t/help-with-pixel-art-end-math-issues/18809/13 "2023-04-25T16:35:55Z")

</div>

hello @richard it is me again, im making a automatique textur generator and im making en extention for it

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

> **[test](https://arcade.makecode.com/23904-52774-30951-24031)**
>
> Fait avec ❤️ dans Microsoft MakeCode Arcade.

any idea what im doing wrong?

---

<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: [April 25, 2023, 4:49pm UTC](https://forum.makecode.com/t/help-with-pixel-art-end-math-issues/18809/14 "2023-04-25T16:49:26Z")

</div>

Looks like there are a few errors in this code.

Let’s take a look at how functions are declared in TypeScript:

```auto
function functionName(arg1: Type1, arg2: Type2): ReturnType {
    ...
}

```

Note the order of the argument declarations here: all arguments should be declared with the name followed by a colon and the type. Here we have two arguments, arg1 of type Type1 and arg2 of type Type2. This function also returns a value of type ReturnType, which we list after the argument list. If we wanted to return nothing, we would set “void” as the return type instead.

Alright, with that in mind, let’s take a look at your code. I see a few issues:

1. Your arguments are declared `type: name` instead of `name: type`. Try switching the order around!
2. Your function has a return type of void, but it returns a value on line 26. I think you can just remove that return statement on line 26
3. You have an extra close curly brace on line 19 that you should delete

I hope that helps!

---

<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: [April 25, 2023, 5:57pm UTC](https://forum.makecode.com/t/help-with-pixel-art-end-math-issues/18809/15 "2023-04-25T17:57:43Z")

</div>

I see thank you very much

---

<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: [April 25, 2023, 9:20pm UTC](https://forum.makecode.com/t/help-with-pixel-art-end-math-issues/18809/16 "2023-04-25T21:20:52Z")

</div>

i seems that the “Image” type is not what it seams  
this is what i get ------ ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/a/a9569d343b2442b6211665f30c996963304800b6.png)  
this is what i want ---- ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/7/70a1cbc431307e6d1a6a94262a4378f8d0c2b398.png)

do you have any more tips for me?

---

<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: [April 25, 2023, 10:18pm UTC](https://forum.makecode.com/t/help-with-pixel-art-end-math-issues/18809/17 "2023-04-25T22:18:04Z")

</div>

it’s the right type! you just need to add an annotation to set the “shadow block” for each argument. Something like this:

```auto
namespace custom {
    /**
     * TODO: describe your function here
     * @param myImage describe parameter here
     * @param myImage2 describe parameter here
     */
    //% block="draw $myImage onto $myImage2"
    //% myImage.shadow=screen_image_picker
    //% myImage2.shadow=screen_image_picker
    export function Print(myImage: Image, myImage2: Image): void {
        for (let X = 0; X <= 16; X++) {
            for (let Y = 0; Y <= 16; Y++) {
                if (myImage.getPixel(X, Y) != 0) {
                    myImage2.setPixel(X, Y, myImage.getPixel(X, Y))
                }
            }
        }
    }
}

```

---

<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: [April 25, 2023, 11:26pm UTC](https://forum.makecode.com/t/help-with-pixel-art-end-math-issues/18809/18 "2023-04-25T23:26:57Z")

</div>

i see, thanck you

---

<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: [April 26, 2023, 7:02pm UTC](https://forum.makecode.com/t/help-with-pixel-art-end-math-issues/18809/19 "2023-04-26T19:02:13Z")

</div>

it seems i’m doing something wrong

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/7/75ddb0532a890d001abd5cc8176ebad89ab04be2.png)  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/5/5fe9d6ef935cc2b6fc453629a75fc42171766aa9.png)

---

<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: [April 26, 2023, 8:36pm UTC](https://forum.makecode.com/t/help-with-pixel-art-end-math-issues/18809/20 "2023-04-26T20:36:33Z")

</div>

and i dont even know what to attempt here

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

---

<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: [April 26, 2023, 9:02pm UTC](https://forum.makecode.com/t/help-with-pixel-art-end-math-issues/18809/21 "2023-04-26T21:02:10Z")

</div>

cant waite for the next streem @richard

[Next page](https://forum.makecode.com/t/help-with-pixel-art-end-math-issues/18809.md?page=2)
