Help with pixel art end math issue's

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

1 Like

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

1 Like

@YuHayate I’m afraid that screenshot is a tad too small for me to read. Can you share a link to the code?

2 Likes
1 Like

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.

5 Likes

but it it already is

1 Like

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!

3 Likes

i works but the camera dosent move from zones

1 Like

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

3 Likes

I like it though.

2 Likes

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

2 Likes

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

any idea what im doing wrong?

1 Like

Looks like there are a few errors in this code.

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

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!

2 Likes

I see thank you very much

1 Like

i seems that the “Image” type is not what it seams
this is what i get ------ image
this is what i want ---- image

do you have any more tips for me?

1 Like

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

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))
                }
            }
        }
    }
}
2 Likes

i see, thanck you

1 Like

it seems i’m doing something wrong


image

1 Like

and i dont even know what to attempt here

1 Like

cant waite for the next streem @richard

2 Likes