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

#1 2009-02-25 16:48:04

plotiforiy
Scratcher
Registered: 2009-02-25
Posts: 2

problem with integrated scratch notes

im trying to make a program with scratch similar to pong, except when the ball is hit it would produce a sound, using [blocks]<play note( <{ note }> )for( <{ X }> )secss>[/blocks]. i'm trying to make it so when hit, the note would continue playing until hit again by the other paddle, however the time it takes to hit one to the other side varies, depending on how long the gaming session lasts. the tone of the sound will also be a random number from 36 to 84. the problem is when i play the note for X seconds, it loops over and over again, because i dont have a definite variable for the X seconds. how can i get the sound to continue to play; without looping itself; until it hits the other paddle?

example of the problem, the numbers represent how long the sound plays, right now its at 0.5s
ball is hit, 0.5, 0.5, 0.5, 0.5 ball is hit again, 0.5, 0.5, 0.5, 0.4 etc.

what i want it to do:
ball is hit, 2, ball is hit again, 1.9

i've tried everything to try and fix this, please help.

Offline

 

#2 2009-02-25 17:00:47

bosox397
Scratcher
Registered: 2008-02-17
Posts: 1000+

Re: problem with integrated scratch notes

try having <repeat until><touching[ other sprite]

play note note for .5 beats


Dear Scratch Users,
I'm done with scratch, or at least making projects. I have made one last big game, thats both fun and teaches a lesson about water. It'd mean a lot if you gave me feedback.                              http://scratch.mit.edu/projects/bosox397/569201

Offline

 

#3 2009-02-26 10:38:48

plotiforiy
Scratcher
Registered: 2009-02-25
Posts: 2

Re: problem with integrated scratch notes

that would work but as the game progresses the ball also gets slower and faster depending on how its hit, so it could take like 2 seconds to reach the other side or if directly hit it would take about 0.5, so if it's 2 seconds it will play the note 4 times

Offline

 

#4 2009-02-26 13:00:40

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

Re: problem with integrated scratch notes

Here is an approach that uses the Stop All Sounds block to chop a long note off when it is time to change to a new note.  It has a bit of lag to it but it's the best I've been able to come up with so far.

http://scratch.mit.edu/projects/Paddle2SeeFixIt/431745


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

Offline

 

Board footer