Something to note with Set Position block - referring to position values

Hey Hops :slight_smile: I was using the Set Position block and realised there seems to be a certain behaviour if you use position value inside it :thinking:

Set Position to X 0, Y 250
Set Position to X 500, Y (x position)

I haven't tested this out, but if you use this on an object, what will its final Y position end up being? :thinking:

We have set it to be its x position value. It could be 0, since that was its previous X position value. But we also just set its current X position to 500, so will it take that X position value instead?

I can test it out, but you know what, you can join in and find out too, even if it's just something little :slight_smile:

15 Likes

Hmmm...
Yeah, I've tried it, it's zero.
always zero.
There's nothing in the box!
Nothing = 0

I've tried it before lol
@anon14801539

4 Likes

@t1_hopscotch Nice thought experiment. As simple as the question is, it's a great example of why a programmer would need to think though, in detail, how the device will execute the given code.

@DECODECO Glad to see you try. I'm curious though what you meant by "There's nothing in the box"? You got the answer right but maybe not for the right reason.

Which is another good lesson for all of us. Always test your hypothesis.

How about if the code was this (added self reference just to clarify):

Set Position to X 100, Y 250
Set Position to X 500, Y (<self> x position)

What would the final y position be now?

6 Likes

Oh, I'm sorry, I thought the x mean to different because it was lowercase lol

2 Likes

I was thinking about this yesterday.............. And now there's a topic about it...

2 Likes

The X would be 500. The Y would also be 500. Here's the project:
https://c.gethopscotch.com/p/yl6ehp033

1 Like

Does the object set it's Y position after the X, or at the same time? (Or before?) Then in that case, it would be 0, because it wouldn't have been set to 500 yet.

3 Likes