I am making a carnival game (Will be called Roll 'em in! if you want to play on it when its done), and I need a coin sprite to point in a random direction. I know how to make it point in a random direction, but if I use send the coin to a wall, I need it to point towards a random direction every time it touches it, but not so it wont stop doing it.
I cant use 'forever if' block because if it touches it, it keep pointing in a random direction continually.
I cant use the 'if' block because it only makes the coin point in a random direction once and if it touches it again, it won't do it.
PLEASE HELP!!! THIS HAS TO BE DONE BY NEXT MONDAY!!!
I will be happy to answer any solutions, suggestions, questions or anything else,
Thanks!!
Offline
Maybe something like this?
when gf clicked forever move //whatever way you want it to move if <touching [edge/wall v]?> point in direction (pick random (-179) to (179)) end endIf this isn't what you meant or doesn't work, just let me know, and I'll be happy to help!
Last edited by powerpoint56 (2012-07-02 13:13:44)
Offline
Hi Powerpoint,
Sorry, this doesn't work because the coin is always moving and I don't need that, I can already sort that problem out, I just need it to point in a random direction as it either just points once or when it touches a wall, points in a random direction and does that forever. PLEASE HELP!! THIS HAS TO BE DONE BY NEXT MONDAY!!!
Offline
If you want it to bounce off, just avoid turning altogether.
You will need 2 variables. One called XVel and another one called YVel. You will also need to separate your walls so that the walls at the top and bottom are a separate sprite.
Now, this script:
when gf clicked go to x: (0) y: (0) point in direction (pick random (-180) to (180)) move (4) steps //Adjust this number to adjust coin speed. set [XVel v] to (x position) set [YVel v] to (y position) forever if <touching [wallstopandbottom v]?> set [YVel v] to ((YVel) * (-1)) repeat until <not <touching [walltopandbottom v]?>> change x by (XVel) change y by (YVel) end end if <touching [wallssides v]?> set [XVel v] to ((XVel) * (-1)) repeat until <not <touching [wallssides v]?>> change x by (XVel) change y by (YVel) end end change x by (XVel) change y by (YVel) end
Last edited by SciTecCf (2012-07-04 03:19:27)
Offline
SciTecCf wrote:
If you want it to bounce off, just avoid turning altogether.
You will need 2 variables. One called XVel and another one called YVel. You will also need to separate your walls so that the walls at the top and bottom are a separate sprite.
Now, this script:when gf clicked go to x: (0) y: (0) point in direction (pick random (-180) to (180)) move (4) steps //Adjust this number to adjust coin speed. set [XVel v] to (x position) set [YVel v] to (y position) forever if <touching [wallstopandbottom v]?> set [YVel v] to ((YVel) * (-1)) repeat until <not <touching [walltopandbottom v]?>> change x by (XVel) change y by (YVel) end end if <touching [wallssides v]?> set [XVel v] to ((XVel) * (-1)) repeat until <not <touching [wallssides v]?>> change x by (XVel) change y by (YVel) end end change x by (XVel) change y by (YVel) end
ScitecCf, I have been trying to help him for a while now, his problem is that all his coins move, hen only 1 is suppose to, This has been posted atleast 3 times now.. lol check out the project, I think you could fix it, I couldn't!
Dan
Offline
But it needs to turn, not bounce, And the 'wall', a sprite that is actually in the middle of the screen, not the wall on the outside of when you're creating a project...
the link to the glitched project is:
http://scratch.mit.edu/projects/DoowNimajneb/2647353
the board that is smaller than the rest of the sprites is not the glitch, download and the board will be fixed like its supposed to.
The glitch is with the coin... try it and youll see...
Offline