This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-10-04 15:08:02

bbart20
Scratcher
Registered: 2009-10-28
Posts: 3

the command "if on edge, bounce" anyway or ideas how to create a

the command "if on edge, bounce"  anyway or ideas how to create a similar action for if a sprite is touching a certain colour or other sprite(preferably) without going through every x/y possibility and making sure that it moves that amount of x and that amount of y away from it ? i started trying with "move -x amount of steps" but that only really works if you're sprite is a perfect circle... in my situation the hands get in the way and he gets carried up the map by a flow of darkenss from the edge...

Offline

 

#2 2012-10-04 15:21:11

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: the command "if on edge, bounce" anyway or ideas how to create a

There is a way, but it's really fiddly and hard to get right. I don't know it.


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#3 2012-10-04 15:28:50

bbart20
Scratcher
Registered: 2009-10-28
Posts: 3

Re: the command "if on edge, bounce" anyway or ideas how to create a

as long as it works on any shape change(map change) and dont have to do a big list of sprites, cause i've done that before but i took a screenshot of every side and then depending on if it was  the side or the bottom it was pushing up or away to the opposite side, but every single border side had to have a whole script to it self and when i was designing a veeery large map that took me a few months.

Offline

 

#4 2012-10-04 17:42:48

Prestige
Scratcher
Registered: 2008-12-15
Posts: 100+

Re: the command "if on edge, bounce" anyway or ideas how to create a

Try this?

when gf clicked
go to x: (0) y: (0)
point in direction (pick random (-179) to (180))
set [Move Speed v] to [0]
forever
move (Move Speed) steps
if <touching [edge v]?>
change x by (([sin v] of (direction)) * ((0) - (Move Speed)))
if <touching [edge v]?>
point in direction ((180) - (direction))
else
point in direction ((0) - (direction))
end
change x by (([sin v] of (direction)) * (Move Speed))
end
Taken from the scratch wiki.


"Don't insult someone until you've walked a mile in their shoes. That way, if they don't like what you have to say, you'll be a mile away and still have their shoes  smile  "

Offline

 

#5 2012-10-04 22:35:22

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: the command "if on edge, bounce" anyway or ideas how to create a

Are you saying that your sprite changes costumes and, as a result, ends up occupying space it normally wouldn't?  I'd say your best bet is either to always switch back to a single costume during sensing or to use an invisible square sprite for all things movement-related (as a "collider") and have your costume-changing sprite always go to its location.


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#6 2012-10-05 15:44:29

bbart20
Scratcher
Registered: 2009-10-28
Posts: 3

Re: the command "if on edge, bounce" anyway or ideas how to create a

Prestige wrote:

Try this?

when gf clicked
go to x: (0) y: (0)
point in direction (pick random (-179) to (180))
set [Move Speed v] to [0]
forever
move (Move Speed) steps
if <touching [edge v]?>
change x by (([sin v] of (direction)) * ((0) - (Move Speed)))
if <touching [edge v]?>
point in direction ((180) - (direction))
else
point in direction ((0) - (direction))
end
change x by (([sin v] of (direction)) * (Move Speed))
end
Taken from the scratch wiki.

played around with that and i managed to get it to a workable stage  smile   only 1 minor bug but this will make scripting soo much easier  smile  now back to photoshop to do the maps  wink  thnx alot for the help  smile

Offline

 

Board footer