jadepax.blogg.se

How to make something bounce when touching a color in scratch
How to make something bounce when touching a color in scratch









how to make something bounce when touching a color in scratch

If this is in some way not possible in the near future, I would like help on finding the direction that the bullet should turn in. If I am not being clear, what I want is a “if touching (color picker), bounce” block. In my game I randomly generate a maze with black walls, and if the bullets are able to bounce off the walls every time they touch them (because I would set the color picker to black), then the block would become much more useful. However, in a tank game there are many walls that aren't on the edge and I'm suggesting a more usable “if touching color (color picker), bounce” block. It turns in the perfect direction I want it to.

how to make something bounce when touching a color in scratch

However, I haven't worked out a mathematical way of finding the direction, but I noticed that a block (that I hardly ever use), “if on edge, bounce”, does exactly what I want. The advantage of such a block is that it grants a 3rd sprite the ability to sense if another two are touching.So since I'm making a tank game, I want the bullets to bounce off of the walls at the perfect angle.

how to make something bounce when touching a color in scratch

Some Scratchers want a block that detects if two different sprites are touching. However, with this block, if is used in a clone of sprite1, not only will it report true when touching the parent sprite, but also when touching any clone. Normally, most blocks targeting other sprites will not act on one of the sprite’s clones, but for the parent sprite. Checking if the player has touched an enemy in a game.Checking if a sprite is touching the mouse pointer.In a maze, sensing if a sprite has hit a dead-end.In this example, the wall is moving, and the bullet remains fixed. Having a sprite chase another sprite until the chaser touches the other sprite.Moving a sprite until it touches the edge of the screen.Some common uses for the Touching ()? block:

how to make something bounce when touching a color in scratch

The collision detection data of this block can be finicky and inaccurate with large or moving sprites, particularly when applied to physics engines.īecause this block checks if its sprite is touching another sprite or an edge, it is widely used in detecting collisions. For example, if a sprite's Costume is that of a circle, it will have a circular hitbox when detecting if it is touching other sprites. Whether or not a sprite is touching another depends on whether or not a part of the sprite's visual texture (defined by its Costume) is touching that of another.











How to make something bounce when touching a color in scratch