Microsoft MakeCode

Is there a way to use block type code to draw a Triangle?

Hi all,

As a general way to explain the concepts of coding, such as loops, variables, is to use the block to draw a triangle picture with repeat steps (moving forward, and angles for turn). These are the common examples which are used in code.org and Scratch.

When I try to deploy the above examples into Arcade game here, I am able to find the block with drawing the line, but could not find the block with angle, so that I can draw the line in the direction of change at the point of triangle, say 120 degree.

I have done some homework before raising above, one way is to create a customized functional block from the function provided by Java script. But I am not that kind of experienced users yet, which I want to check is it a simply way to resolve the above question – use a simply block type code with angle function?

Thanks

Jack

I dont really know how but I saw one

This is it

Thanks, but it use Java script, which is a not a idea way to do so if i like to bring this exercise to the kids. That is why i like to check is there a simply way - which just use block type.

Thanks

Jack

No, we don’t have any “turtle” blocks by default in Arcade. Would make a great extension though!

From the early days of arcade, https://github.com/microsoft/pxt-screen-turtle/

Needs refreshing.

yes, it will be great!

After

  1. Fixing a tiny typo in setPosition()
  2. Changing screen dimension to 160 * 120, (@peli, wondering why the original was 4 * 4, just to make sure I didn’t miss anything. :upside_down_face:)
  3. Adding rightTurn() / leftTurn() / clearScreen() ( Still remember using these as a kid)

And, after almost 30 years, I can still code those classic programs :smile: :smile: :smile:

The extension repo is here if you would like a quick look @Jackyu

I’ve created a pull request.

I’m guessing it was 4x4 because it was forked from the micro:bit turtle extension…

Great thanks for the fixes! I’ve merged and pushed a release --> https://microsoft.github.io/pxt-screen-turtle/