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

#1 2012-11-02 18:40:31

mythbusteranimator
Scratcher
Registered: 2012-02-28
Posts: 1000+

Direction Help!

In ONE SCRIPT, please show me how to do this.

I want to be able to move my ball after it switches to the costume, but the "point in direction" and then "move 2 steps" script isn't working. Is there some trig you do to change x and y by using the direction? I need help.  tongue


http://www.foxtrot.com/comics/2012-04-01-fdb37077.gif
clicky

Offline

 

#2 2012-11-02 19:42:30

mythbusteranimator
Scratcher
Registered: 2012-02-28
Posts: 1000+

Re: Direction Help!

See? I get the trig right for one bounce in this project, but then it starts to keep tailing to the right. What is wrong?  hmm


http://www.foxtrot.com/comics/2012-04-01-fdb37077.gif
clicky

Offline

 

#3 2012-11-02 20:59:19

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

Re: Direction Help!

I personally find it easier to deal with x and y velocities (and ignore direction) if you're dealing with only walls either parallel or perpendicular to the x axis (like you are).

when gf clicked
forever
draw paddle
go to [whereever the ball is supposed to be v]
change x by (xvel)
change y by (yvel)
if<touching color [color of bass]?>
set [yvel v] to ((-1)*(yvel))
change y by (yvel)
end
if<([abs v] of (x position)) > [240]>
set [xvel v] to ((-1)*(xvel))
change x by (xvel)
end
check for goals, etc.


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

Offline

 

#4 2012-11-03 08:23:26

mythbusteranimator
Scratcher
Registered: 2012-02-28
Posts: 1000+

Re: Direction Help!

Okay. I'll try that.  hmm


http://www.foxtrot.com/comics/2012-04-01-fdb37077.gif
clicky

Offline

 

#5 2012-11-03 21:43:34

mythbusteranimator
Scratcher
Registered: 2012-02-28
Posts: 1000+

Re: Direction Help!

Just curious, but when a sprite flashes in test mode (while moving) but hides in presentation mode, what will it do after being uploaded?


http://www.foxtrot.com/comics/2012-04-01-fdb37077.gif
clicky

Offline

 

#6 2012-11-03 21:57:26

mythbusteranimator
Scratcher
Registered: 2012-02-28
Posts: 1000+

Re: Direction Help!

And the bal won't show. Any help, guys?  sad


http://www.foxtrot.com/comics/2012-04-01-fdb37077.gif
clicky

Offline

 

#7 2012-11-03 22:29:36

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

Re: Direction Help!

I'm probably the wrong guy to talk to about stuff like this, but the key to rendering multiple things with one sprite is the slight built-in delay between the end of the loop and the beginning.  This means that you'll probably end up seeing whatever is rendered at the end of the loop.  It also means that when you clear it, you need to make sure the "clear" block is above the rendering script (so the slight delay occurs after rendering, not after "clearing")


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

Offline

 

#8 2012-11-03 22:37:00

mythbusteranimator
Scratcher
Registered: 2012-02-28
Posts: 1000+

Re: Direction Help!

MoreGamesNow wrote:

I'm probably the wrong guy to talk to about stuff like this, but the key to rendering multiple things with one sprite is the slight built-in delay between the end of the loop and the beginning.  This means that you'll probably end up seeing whatever is rendered at the end of the loop.  It also means that when you clear it, you need to make sure the "clear" block is above the rendering script (so the slight delay occurs after rendering, not after "clearing")

The "clear" block is at the top of the script, if that is what you mean.


http://www.foxtrot.com/comics/2012-04-01-fdb37077.gif
clicky

Offline

 

#9 2012-11-04 08:00:39

mythbusteranimator
Scratcher
Registered: 2012-02-28
Posts: 1000+

Re: Direction Help!

mythbusteranimator wrote:

MoreGamesNow wrote:

I'm probably the wrong guy to talk to about stuff like this, but the key to rendering multiple things with one sprite is the slight built-in delay between the end of the loop and the beginning.  This means that you'll probably end up seeing whatever is rendered at the end of the loop.  It also means that when you clear it, you need to make sure the "clear" block is above the rendering script (so the slight delay occurs after rendering, not after "clearing")

The "clear" block is at the top of the script, if that is what you mean.


http://www.foxtrot.com/comics/2012-04-01-fdb37077.gif
clicky

Offline

 

#10 2012-11-04 08:52:59

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

Re: Direction Help!

I'm looking at your script, and I'm a little confused.  Could you tell me exactly what you're trying to accomplish, and why you're using a list when it appears you are only using the first item?


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

Offline

 

#11 2012-11-04 20:24:14

mythbusteranimator
Scratcher
Registered: 2012-02-28
Posts: 1000+

Re: Direction Help!

MoreGamesNow wrote:

I'm looking at your script, and I'm a little confused.  Could you tell me exactly what you're trying to accomplish, and why you're using a list when it appears you are only using the first item?

Right now, the list thing should not be a problem; it is only keeping the length of the score for later in the script (and it works). I want to figure out to show the ball, as it hides in presentation mode/uploaded, but it flashes in test mode.


http://www.foxtrot.com/comics/2012-04-01-fdb37077.gif
clicky

Offline

 

#12 2012-11-04 21:28:14

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

Re: Direction Help!

Put a "stamp" before you "hide" your ball.  I think I got it working but I can't seem to upload a picture and it is way too long for me to type up  tongue

BTW, you can just do this for collisions.  If you move only along the x axis, you can be sure that you're hitting either the left or right side (resulting in a reversal of x velocity).  Likewise, if you move only along the y axis (or, in this case, after you've moved along the x axis), you can be sure that you're hitting one of the horizontal objects.

change x by (xvel)
if<touching [edge v]?>
set [xvel v] to ((-1)*(xvel))
change x by (xvel)
end
change y by (yvel)
if<<touching [edge v]?> or <touching color [color of paddle]?>>
set [yvel v] to ((-1)*(yvel))
if<touching color [color of paddle]?>
add point; make more difficult, etc.
else
if<(y position) < [0]>
lose a life, if >5 stop all, etc.
end
end
change y by (yvel)
end

Last edited by MoreGamesNow (2012-11-04 21:34:41)


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

Offline

 

#13 2012-11-05 08:09:37

mythbusteranimator
Scratcher
Registered: 2012-02-28
Posts: 1000+

Re: Direction Help!

Thanks a TON! I got it working now; I'll be sure to give a lot of credit!  big_smile


http://www.foxtrot.com/comics/2012-04-01-fdb37077.gif
clicky

Offline

 

#14 2012-11-05 11:34:13

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Direction Help!

Closed by request of the topic owner.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

Board footer