Discuss Scratch

sledge10
New Scratcher
3 posts

maze game

I'm trying to make a sort of maze game where a ball sprite has to automatically (no user input) move from the left side of the window to the right while moving around randomly generated “walls”. I'm having trouble making my ball sprite bounce off my walls (right now it circles inside them and then gets spit out). Any ideas on how I should fix this? My ball sprite code:
whenclickedforevermove3stepsifcoloristouching?thenchange pointsby1ifpoints>0thenturn15degreesmove3stepschangepointsby-1ifonedge,bounceend

Last edited by sledge10 (Oct. 5, 2016 20:26:05)

LemonComputer
Scratcher
100+ posts

maze game

Make the maze walls a separate Sprite and use this command to the player Sprite.
whenclickedforeveriftouchingMaze Sprite name?thenmove-AmountofstepsSpritemovessteps

I can't remember exactly how the script is, but I definitely remember the scripts up to the moving part. The instructions are in the Scratch Book that I bought from the Science Museum the other day and I forgot where I left it inside my house.
NoelsNook
Scratcher
40 posts

maze game

whenclickedmovepickrandom180to-180steps
ETC, if you want the ball to move at random around the map, pick the highest and the lowest numbers on the scale.
Also use a:
pointtowards(pick random (240) to (-240))
If you use a point random and a move random it should work. If that doesn't work use a glide to position, and always remember a if on edge bounce. You can check out my ball game 2.0, it has that working ball script.

Powered by DjangoBB