# Grid Extension - Dev Input Requested

**URL:** <https://forum.makecode.com/t/grid-extension-dev-input-requested/265>\
**Category:** Arcade\
**Created:** [June 17, 2019, 10:40pm UTC](https://forum.makecode.com/t/grid-extension-dev-input-requested/265 "2019-06-17T22:40:58Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlexK](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/alexk/32/33339_2.png) [@AlexK](https://forum.makecode.com/u/AlexK)\
**Post date:** [June 17, 2019, 10:40pm UTC](https://forum.makecode.com/t/grid-extension-dev-input-requested/265/1 "2019-06-17T22:40:58Z")

</div>

**Update** : I have released this extension via GitHub. Refer to the announcement here: [Grid extension](https://forum.makecode.com/t/grid-extension/282)

For the course that I’m writing, I’m thinking about a game similar to the Memory card game. I’m going to need to build a grid similar to that used in the _Memory_ game found in **Blocks Games** or that John Park uses in his _Re-MakeCode Racing Game_. Since it might be a useful construct for others, I figured I’d create an extension.

The extension is basically done, but I’m looking for some input. You can find my current work here:

> **[Grid Demo](https://arcade.makecode.com/50865-86478-95067-82842)**
>
> Made with ❤️ in MakeCode Arcade.

Use the arrow keys to move the taco around the grid. Pressing **A** will add columns to the grid; **B** will add rows.

Some thoughts that I’m pondering:

- ~~When switching to JavaScript, and then switching back to Blocks, the `grid.drawGrid()` call renders as a JavaScript block. Any ideas as to why? (Does the same in beta.)~~ Fixed. Thanks, @richard!!! 😃
- I’ve created `moveDown()`, `moveLeft()`, `moveRight()`, and `moveUp()` functions that you can bind to the appropriate keys. Is that a reasonable way to implement this, or should I go the route of `controller.moveSprite()`? If the latter, what’s the best way of going about that?
- ~~The indexing for the rows and columns begins at 1. Is that reasonable, or should it start with zero?~~ I’ve switched the indexing to begin at zero per the conversation below. If you feel strongly otherwise, feel free to comment.
- I’ve added the ability to animate the transition from one coordinate to the next as @peli suggested.
  - In the demo, when you move right or down, the taco “slides” to the next location. When you move left or up, the taco “teleports.” In addition, in the demo, the grid “wraps around,” so moving the taco off of an edge will send it to the other side of the grid.
  - The default action is to teleport. If you feel like it should be the other way around, feel free to comment.
  - How do you feel about the “slide” from, say, the right side to the left?
  - Do you think that it should jump to the opposite side instead, even if teleporting is turned off?
  - Do you think this should be a global setting (all sprites either teleport or slide), a per-sprite setting (each sprite can either teleport or slide as it moves), or a per-direction setting as currently implemented?

I’m always happy to entertain other thoughts and ideas, so feel free to share them!

Happy Monday!

---

<div class="post-metadata">

**Author:** ![peli](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/peli/32/12_2.png) [@peli](https://forum.makecode.com/u/peli)\
**Post date:** [June 17, 2019, 11:49pm UTC](https://forum.makecode.com/t/grid-extension-dev-input-requested/265/2 "2019-06-17T23:49:40Z")

</div>

- could move the sprites smoothly between points? instead of just “teleport”, interpolate their position quickly to smooth the moves.

---

<div class="post-metadata">

**Author:** ![peli](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/peli/32/12_2.png) [@peli](https://forum.makecode.com/u/peli)\
**Post date:** [June 17, 2019, 11:53pm UTC](https://forum.makecode.com/t/grid-extension-dev-input-requested/265/3 "2019-06-17T23:53:35Z")

</div>

> indexing  
> Starting at 0 is more consistent with arrays, pixels on screen. I would go for that.

---

<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:** [June 18, 2019, 12:14am UTC](https://forum.makecode.com/t/grid-extension-dev-input-requested/265/4 "2019-06-18T00:14:34Z")

</div>

You need to add `img.fieldOptions.decompileIndirectFixedInstances="true"` to the comment annotations on the declaration of `grid.drawGrid()` to fix the grey block.

Sorry, that one is definitely not obvious! That annotation is only required for arguments of “fixed instance” types (Image is the only one in arcade that I can remember off the top of my head).

---

<div class="post-metadata">

**Author:** ![AlexK](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/alexk/32/33339_2.png) [@AlexK](https://forum.makecode.com/u/AlexK)\
**Post date:** [June 18, 2019, 12:32am UTC](https://forum.makecode.com/t/grid-extension-dev-input-requested/265/5 "2019-06-18T00:32:48Z")

</div>

Thanks so much, @richard, for that one! I’m pretty sure that shows up in some of my other extensions. I’ll have to add it to those, too.

---

<div class="post-metadata">

**Author:** ![AlexK](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/alexk/32/33339_2.png) [@AlexK](https://forum.makecode.com/u/AlexK)\
**Post date:** [June 18, 2019, 1:02am UTC](https://forum.makecode.com/t/grid-extension-dev-input-requested/265/6 "2019-06-18T01:02:19Z")

</div>

> [@peli](#):
>
> indexing  
> Starting at 0 is more consistent with arrays, pixels on screen. I would go for that.

I tend to agree, @peli. The _Memory_ game uses a base index of zero; John’s game, IIRC, uses a base index of one. Zero is more consistent with JavaScript, so the updated version (which I’ll post shortly) will switch to that. Game authors can use an index of -1 to move the sprite to the top or left edge of the screen.

---

<div class="post-metadata">

**Author:** ![jedgarpark](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jedgarpark/32/202_2.png) [@jedgarpark](https://forum.makecode.com/u/jedgarpark)\
**Post date:** [June 18, 2019, 2:41pm UTC](https://forum.makecode.com/t/grid-extension-dev-input-requested/265/7 "2019-06-18T14:41:04Z")

</div>

@AlexK this is really cool! This will be very useful, thanks so much for making it and sharing.

---

<div class="post-metadata">

**Author:** ![AlexK](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/alexk/32/33339_2.png) [@AlexK](https://forum.makecode.com/u/AlexK)\
**Post date:** [June 18, 2019, 3:19pm UTC](https://forum.makecode.com/t/grid-extension-dev-input-requested/265/8 "2019-06-18T15:19:35Z")

</div>

Thanks so much, John! Welcome to the community!

I love your videos. Thanks so much for the incredible work and for sharing it with the world!

---

<div class="post-metadata">

**Author:** ![jedgarpark](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jedgarpark/32/202_2.png) [@jedgarpark](https://forum.makecode.com/u/jedgarpark)\
**Post date:** [June 18, 2019, 3:27pm UTC](https://forum.makecode.com/t/grid-extension-dev-input-requested/265/9 "2019-06-18T15:27:02Z")

</div>

Hi, Alex, very nice to be here, and thanks so much for the kind words!

---

<div class="post-metadata">

**Author:** ![mmoskal](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/mmoskal/32/20_2.png) [@mmoskal](https://forum.makecode.com/u/mmoskal)\
**Post date:** [June 19, 2019, 1:23am UTC](https://forum.makecode.com/t/grid-extension-dev-input-requested/265/10 "2019-06-19T01:23:16Z")

</div>

Melody also uses fixed instances. Maybe we can simplify block syntax, now that there is more and more folks writing block extensions?

---

<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:** [June 19, 2019, 9:05pm UTC](https://forum.makecode.com/t/grid-extension-dev-input-requested/265/11 "2019-06-19T21:05:19Z")

</div>

To simplify it, we need to cut features that are used in other editors
