ScratchData LogoScratchData
Back to kriblo_test's profile

Bouncing Bug

KRkriblo_test•Created January 27, 2021
Bouncing Bug
9
7
66 views
View on Scratch

Instructions

This is to illustrate a problem which occurs when using the pen to draw, while using a hitbox costume with the "if on edge, bounce" block. The costume is the same size as the pen dot. As you should be able to see initially, it bounces too early. The problem occurs when the sprite is hidden and the "set rotation style" is not set to "don't rotate" (the default is "all around"), and manifests itself by bouncing the sprite before it actually touches the edge of the screen. The problem is resolved by setting rotation style to "don't rotate". It also bounces properly if the sprite is shown (even if ghosted). Press the R key to toggle rotation style. Press the S key to show and hide the sprite. All code by me (@kriblo).

Description

@papipupepappa figured out that the sprite is bouncing of a (rotating) square bounding box when it's hidden. Check out his remix: https://scratch.mit.edu/projects/479563779 Observation by @papipupepappa: Very interesting. It seems like hiding the sprite sets its bounding box to a rectangle, and it is the edges of that rectangle that detects the edges of the screen. If you the direction to 0, 90, 180 or 270, it won't bounce too early. And changing the direction by a couple of degrees from that makes it bounce only slightly early. This appears to support my assumption. It would also explain why setting the rotation style to anything but "all around" fixes it. I tried changing the shape of the sprite to an ellipse, and the results were consistent with my prior observations. The bounding box seems to be the culprit of both this bug and the "cropped sides" bug.

Project Details

Project ID479355553
CreatedJanuary 27, 2021
Last ModifiedJanuary 27, 2021
SharedJanuary 27, 2021
Visibilityvisible
CommentsAllowed