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

#1 2012-08-26 13:36:21

Jodymoses
Scratcher
Registered: 2012-05-03
Posts: 100+

Autocharacter Scrolling

Can Anyone Show me How To Make e.g 6 characters scroll in a random direction in a 3x3 environment.
3x3 meaning 3 different areas as your X
                    3 different areas as your Y

An awesome example is Virtual Villagers
PS my theme is based on that


http://i46.tinypic.com/2hxwx9s.png
I Have Huge Ideas, But Only If You Listen And Talk To Me...

Offline

 

#2 2012-08-26 13:53:11

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

Re: Autocharacter Scrolling

<First create the environment. A simple example of that can be found here. Making the 6 characters scroll is a little more complicated. As you're using a random direction, you'll need to find the x and y components of their resultant movement. This can be done with trigonometry. Find the x and y components like this.

set [x v] to ((V) * (cos (direction)))
set [y v] to ((V) * (sin (direction)))
where V is the speed/velocity of the character.

You'd then need to make this work in the scrolling environment. Construct a script like this:
go to x: (0) y: (0)
point in direction (pick random (-180) to (180))
set [x v] to (0)
set [y v] to (0)
forever
change [x v] to ((V) * (cos (direction)))
change [y v] to ((V) * (sin (direction)))
set x to ((scrollx) - (x))
set y to ((scrolly) - (y))
if <<((abs (x position)) > (240))> or <((abs (y position)) > (180))>>
hide
else 
show 
end
end
I hope this is what you were looking for  smile

Last edited by Prestige (2012-08-26 13:55:48)


"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

 

#3 2012-08-26 13:58:43

BirdByte
Scratcher
Registered: 2012-07-07
Posts: 1000+

Re: Autocharacter Scrolling

Prestige wrote:

<First create the environment. A simple example of that can be found here. Making the 6 characters scroll is a little more complicated. As you're using a random direction, you'll need to find the x and y components of their resultant movement. This can be done with trigonometry. Find the x and y components like this.

set [x v] to ((V) * ([cos v] of (direction)))
set [y v] to ((V) * ([sin v] of (direction)))
where V is the speed/velocity of the character.

You'd then need to make this work in the scrolling environment. Construct a script like this:
go to x: (0) y: (0)
point in direction (pick random (-180) to (180))
set [x v] to (0)
set [y v] to (0)
forever
change [x v] by ((V) * ([cos v] of (direction)))
change [y v] by ((V) * ([sin v] of (direction)))
set x to ((scrollx) - (x))
set y to ((scrolly) - (y))
if <<([abs v] of (x position)) > (240)> or <(180) < ([abs v] of (y position))>>
hide
else 
show 
end
end
I hope this is what you were looking for  smile

Fixed!  big_smile


http://i50.tinypic.com/312u714.jpg

Offline

 

#4 2012-08-27 10:42:53

Jodymoses
Scratcher
Registered: 2012-05-03
Posts: 100+

Re: Autocharacter Scrolling

Not Really but it is appreciated


http://i46.tinypic.com/2hxwx9s.png
I Have Huge Ideas, But Only If You Listen And Talk To Me...

Offline

 

#5 2012-08-27 10:59:52

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

Re: Autocharacter Scrolling

Could you explain further what you're looking for?


"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

 

#6 2012-08-27 17:00:39

Jodymoses
Scratcher
Registered: 2012-05-03
Posts: 100+

Re: Autocharacter Scrolling

Have you played virtual villagers or any game with the same consept?


http://i46.tinypic.com/2hxwx9s.png
I Have Huge Ideas, But Only If You Listen And Talk To Me...

Offline

 

Board footer