# Help with tile centering

**URL:** <https://forum.makecode.com/t/help-with-tile-centering/3279>\
**Category:** Help\
**Created:** [August 31, 2020, 2:00am UTC](https://forum.makecode.com/t/help-with-tile-centering/3279 "2020-08-31T02:00:38Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [August 31, 2020, 2:00am UTC](https://forum.makecode.com/t/help-with-tile-centering/3279/1 "2020-08-31T02:00:38Z")

</div>

Hello all!

I’m making a game for the Traffic Jam (which I hope will come soon!) and I’m stuck on something.  
My game allows you to switch lanes, using the up or down keys. But it’s really easy to crash into a car by 1 pixel, which can be very annoying. So, I’m in the process of implementing smooth lane changing, so it will change to the next lane and align perfectly, instead of having you to align it yourself, kinda like a really expensive car that lane changes for you. 😉

For some reason, changing lanes down (right if you hold it at 270) is perfectly fine, while changing lanes up (left), it will not align to the road. I for the life of me cannot understand why my game is doing this to me and you are all smarter than me. 😉

Here is the troubling game:  
(All the controls should be explained in the start screen - if you don’t get it just ask!)

> **[HONK!](https://arcade.makecode.com/53896-76787-44823-68265)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

I also remember this code (by reyhanPanci256):

> **[grid movement](https://arcade.makecode.com/30838-31825-86878-32087)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

from this thread:

> [@Grid movement](https://forum.makecode.com/t/grid-movement/2004):
>

but it doesn’t seem to work in this version ☹

---

<div class="post-metadata">

**Author:** ![felixtsu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/felixtsu/32/12024_2.png) [@felixtsu](https://forum.makecode.com/u/felixtsu)\
**Post date:** [August 31, 2020, 3:20am UTC](https://forum.makecode.com/t/help-with-tile-centering/3279/2 "2020-08-31T03:20:32Z")

</div>

Hi,

I’m going to write down the process of debugging and fixing with blurring.

It’s always:

1. to reproduce the bug in a simplified scenario;
2. locate the cause
3. fix

For step 1, read the code, find the code relevant and remove those not to make testing quick and easy. (I removed the slow cars, which interrupts testing(causing game over)

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/e/ece1e22df98425495273516b44d20deb2ca29951.jpeg)  
After that I’m able to test up / down;

Step 2, locate the bug with logging, logging is the cheapest and easiest way for straightforward bugs. This time, its obvious that y of car is not correct updated after up is released, so I add some logs:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/7/7465c5a4e4e60a12f72ba8247ebcde74ee4319f2.png)  
Also, as you mentioned, releasing down works fine, so we may want to compare them for a better understanding, that’s why logs are added to down releasing event.

Now I can reproduce with logging,

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

Try to locate the cause now.

Hint:

The changes to y for up / down should not be the same, consider the following:  
Let’s suppose the of y of car is now 28,  
a.) for moving up, y should be set to ?  
b.) for moving down, y should be set to ?

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

Hope it helps.

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [August 31, 2020, 1:14pm UTC](https://forum.makecode.com/t/help-with-tile-centering/3279/3 "2020-08-31T13:14:17Z")

</div>

Thank you felixtsu!  
I’m currently not at my computer, so I can’t run through the whole debugging thing.  
Thank you again for the time and effort you out into helping me!  
It’s so tempting just to unblur the hint ! Agh!

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [September 1, 2020, 10:28pm UTC](https://forum.makecode.com/t/help-with-tile-centering/3279/4 "2020-09-01T22:28:23Z")

</div>

Got it to work! Thank you so much for helping me with my game!  
BTW, you accidentally put the answer when you were showing me this photo:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/3/35bcd8eb0172ec24a7b4c47ab3fba50bc1f57ce4.png)  
It includes the `16 - `

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [September 1, 2020, 11:07pm UTC](https://forum.makecode.com/t/help-with-tile-centering/3279/5 "2020-09-01T23:07:50Z")

</div>

Here’s the game if anyone wants to try it out:

> **[HONK!](https://arcade.makecode.com/00278-32030-75474-24968)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![felixtsu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/felixtsu/32/12024_2.png) [@felixtsu](https://forum.makecode.com/u/felixtsu)\
**Post date:** [September 1, 2020, 11:12pm UTC](https://forum.makecode.com/t/help-with-tile-centering/3279/6 "2020-09-01T23:12:32Z")

</div>

Oops！ 🤣

---

<div class="post-metadata">

**Author:** ![jacob\_c](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jacob_c/32/1532_2.png) [@jacob\_c](https://forum.makecode.com/u/jacob_c)\
**Post date:** [September 2, 2020, 12:00am UTC](https://forum.makecode.com/t/help-with-tile-centering/3279/7 "2020-09-02T00:00:32Z")

</div>

Animated title screen is 🔥. Fun/challenging gameplay too!

(Seriously love that text layout on the title screen…)

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [September 2, 2020, 12:15am UTC](https://forum.makecode.com/t/help-with-tile-centering/3279/8 "2020-09-02T00:15:04Z")

</div>

Thank you! Writing the text took forever 😅  
I got the idea from a mobile game that I really liked and decided to create the game in Traffic/Car theme so I could submit it to the Traffic Jam!

---

<div class="post-metadata">

**Author:** ![GameGod](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/gamegod/32/2756_2.png) [@GameGod](https://forum.makecode.com/u/GameGod)\
**Post date:** [November 19, 2020, 10:09pm UTC](https://forum.makecode.com/t/help-with-tile-centering/3279/9 "2020-11-19T22:09:37Z")

</div>

Oh, that snake game thing?

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [November 19, 2020, 11:48pm UTC](https://forum.makecode.com/t/help-with-tile-centering/3279/10 "2020-11-19T23:48:01Z")

</div>

A different game.

---

<div class="post-metadata">

**Author:** ![GameGod](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/gamegod/32/2756_2.png) [@GameGod](https://forum.makecode.com/u/GameGod)\
**Post date:** [November 19, 2020, 11:48pm UTC](https://forum.makecode.com/t/help-with-tile-centering/3279/11 "2020-11-19T23:48:58Z")

</div>

which one?

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [November 20, 2020, 12:27am UTC](https://forum.makecode.com/t/help-with-tile-centering/3279/12 "2020-11-20T00:27:21Z")

</div>

> <https://play.google.com/store/apps/details?id=io.voodoo.firedup>
>
> Fire out balls and break as many blocks as you can!
> 
> Upgrade your tank to become stronger and unlock cool tanks!
> 
> How far can you go?...

---

<div class="post-metadata">

**Author:** ![Sonicblaston](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/sonicblaston/32/19164_2.png) [@Sonicblaston](https://forum.makecode.com/u/Sonicblaston)\
**Post date:** [August 23, 2022, 7:35pm UTC](https://forum.makecode.com/t/help-with-tile-centering/3279/13 "2022-08-23T19:35:33Z")

</div>

Here’s my record

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