microsoft / microsoft/pxt-microbit
Sprite location should be rounded
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 804
- Forks
- 721
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 2
Description
This line I believe implicitly casts the sprite location from a number to an int thus discarding the fractional part:
https://github.com/microsoft/pxt-microbit/blob/5df0bd147f04e3a07b71e6ac580041b4bea25c6e/libs/core/game.ts#L751
This has the effect that sprites can reside at a coordinate value of 0 if they are in the range [0..1) but they can only reside at coordinate value 4 if they are exactly equal to 4. This causes bouncing sprites to move unevenly around the edges of the screen.
This should use some kind of rounding instead so that [0..0.5) maps to the 0 location, and [3.5..4] maps to the 4 location, making the behaviour even on all edges of the screen.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at libs/core/game.ts line 751 and inspect how sprite coordinates are converted. Reproduce bouncing sprites near the screen edges with fractional positions, then verify that edge movement is even and the stated coordinate ranges behave as expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100