X position variable is rounded

Use this template to make awesome bug reports:

Your username: Cutelittlepuppydog🐕

What kind of device are you using?: (Also include iOS version, and Hopscotch version) iPad Pro 4th generation, iOS 15.4, HS 3.50.5

1 sentence description of the problem (I was doing _________, and then __________ happened): I was coding, and I realized that a tiny sliver of the screen was showing in my trail art.

Steps that the Hopscotch team can take to reproduce my problem every time:
(this isnt the only way to show this bug, but its the easiest way to visualize it imo)

  1. put in this code:
  2. press play

I expected this to happen: The entire half of that screen would be filled

But instead this happened: I saw a sliver of the screen not filled

Here’s a sweet screenshot:


(turn on dark mode to see the sliver of white)


I tested this bug further and discovered that the X position of my object was in fact 341.5, but the X position variable was stored as 342. This means the object moves 0.5 of a pixel when making this trail art. This resulted in the sliver of white you see when you impliment this code.

And yes, there is an easy fix to this, but I still think the X position variable should be accurate.

6 Likes

It rounds there too, so it actually moved one pixel

5 Likes

could you elaborate?

4 Likes

Ill break that down then:

341 I believe because it moves forward, not back but if you tried storing that variable and it said 342 that’d be correct

The number is also rounded when put in blocks, so its just storing differently as 342 here, which is really weird

3 Likes

yeah thats strange…

i did actually, if you say set text to x position it’s 342

3 Likes

Weird, then either the command is executing incorrectly, the text is incorrect, or somehow… the second number is 34…3?

4 Likes

the variable is incorrect, thats the point of this bug report lol- /nm /t

3 Likes

Yeah I know, im trying to figure out which variable is incorrect

4 Likes

this is not true.


if you do this (so you round manually before hopscotch rounds it (which it doesnt do)), you have a straight white line. This means hopscotch does not round your value input for X

and to prove my last point, if hopscotch rounds the value for X, you’d have a straight white line - but you don’t, you dont have any white on your screen


so the bug here, as said by clpd earlier, is that X position variable is rounding, and Set Position doesnt unlike some people think - so it creates a shift of 0.5

5 Likes

I tested earlier today and it did

4 Likes

can you send your test?

2 Likes

I cant as its for a secret project but I can replicate it, let me do that

Edit: oops, just saw the test and I was using increase y not set position :sweat_smile: sorry

4 Likes

yeah i was told this by some people, idrk how accurate it is

3 Likes

i think those people who discovered that were confused by the bug you just reported - i dont think hopscotch rounds to the units, i think it rounds one decimal later

4 Likes

Set position does set the object’s position to the decimal. Reading the X Position trait returns a rounded value.

So, you’re setting position to 341.5, then 342

5 Likes

is this a bug, or intended?

2 Likes

When you think about it, the position is in pixels. You can’t move half a pixel, and only half a pixel can’t be colored. So it covers the whole pixel.

Does that make sense?

2 Likes

no, if you think deeper, hopscotch’s stage size is always half of your screen (my ipad is 2048x1536 and on hopscotch it shows 1024x768) so yes, you can move a character by 0.5 pixels but not less

in other words, hopscotch’s pixel contains 4 ipad screen pixels.

2 Likes

Oh it is? I didn’t know lol. That’s good tho!

2 Likes

yep it is :+1:

1 Like