Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • CreatiCode
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

CreatiCode Scratch Forum

  1. CreatiCode Forum
  2. Knowledge Base
  3. 2D Blocks
  4. The "Distance between" Operator Block

The "Distance between" Operator Block

Scheduled Pinned Locked Moved 2D Blocks
1 Posts 1 Posters 713 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • CreatiCodeI Offline
    CreatiCodeI Offline
    CreatiCode
    wrote on last edited by admin
    #1

     

    Prerequisite

    • Working with Blocks

     

    What is “Direct” and “Manhattan” distance?

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/7c2bf897-310e-49a5-a88d-d5bc45d22cf5.PNG" width="700" style="">

    Suppose you are at the start point on the map above, and you want to travel to the stop point. If you can walk in a straight line, then the length of this line is the direct distance between these 2 points. This is shown as the yellow line on the map.

    However, in many situations, you can not travel in a straight line. For example, there may be houses or buildings between the street blocks, as in the case of Manhattan city. In this case, you have to walk along the vertical or horizontal streets. The total length of these lines is the “Manhattan distance” between the 2 points.

    Below are some more examples of Direct and Manhattan distances between the START and STOP points;
     
    Example 1:
    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/7c2bf897-310e-49a5-a88d-d5bc45d22cf5.PNG" width="700" style="">
     

    Example 2:
    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/3aa83650-2d56-4dad-8293-604ca1f5c770.PNG" width="700" style="">
     
    Example 3:
    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/c582f903-93e1-498c-8865-f0e5cb365722.PNG" width="700" style="">
     
     

    The Block

    The “Distance between x() y() and x() y()/ direct” is a reporter block in the operators category.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/ca0e0d81-1d3b-458b-a193-963da917cd49.PNG" width="850" style="">
     

    How does this block work?

    This block tells the distance between two specified points.

    In CreatiCode, a “point” or “position of a sprite” is defined by an “x position” and a “y position”. https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/ea06711e-f524-47c4-adf9-9a02aa126a92.PNG" width="600" style="">

     
    You need to input the position values of two different points in the block, and choose “Direct” or “Manhattan” by clicking on the drop-down menu. https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/75638ba4-9fc5-46bf-8c67-84ec8e3b9b02.PNG" width="400" style="">

    Here is how it works;

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/6790c144-ce75-4d42-b471-a19a51265261.gif" width="700" style="border-radius: 5px; border: 1px solid #29622d;">
     

    1 Reply Last reply
    0

    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

    With your input, this post could be even better 💗

    Register Login
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • CreatiCode