sound help
Author |
Message |
remember_987
|
Posted: Mon Jan 12, 2009 9:54 am Post subject: sound help |
|
|
I am trying to get some sound working in my program and am having issues. Can anyone tell me what I have done wrong?
Turing: | var px: int:= 10
var py: int:= 100
var key: array char of boolean
var x1, y1, xChange, yChange : int := 1
const RADIUS : int := 5
View.Update
x1 := maxx div 2
y1 := maxy div 2
View.Set ("graphics:1000,600,offscreenonly,title:Pong,position:center;center")
%the above statement sets screen size, positions the screen in the center, and initiates double buffering
process paddlesound
Music.PlayFile ("paddlesound.wav")
end paddlesound
process wallsound
Music.PlayFile ("wallhit.wav")
end wallsound
procedure draw %draws the left paddle
drawfillbox (px,py,px+ 10,py+ 70, white)
end draw
procedure blacky %draws paddle background
drawfillbox (px,py,px+ 10,py+ 70, black)
end blacky
Draw.FillBox (0, 0, maxx, maxy, black)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
loop
Input.KeyDown (key )
if key (KEY_UP_ARROW) and py+ 70<= 600 then blacky py+= 1
elsif key (KEY_DOWN_ARROW) and py+ 70>= 70 then blacky py-= 1
end if
Draw.FillBox (maxx, maxy, 0, 0, black)
Draw.FillOval (x1, y1, RADIUS, RADIUS, 30)
draw
View.Update
x1 + = xChange
y1 + = yChange
if View.WhatDotColor (x1, y1 + RADIUS ) = white then
yChange * = - 1 fork paddlesound
elsif View.WhatDotColor (x1, y1 - RADIUS ) = white then
yChange * = - 1 fork paddlesound
end if
if View.WhatDotColor (x1 + RADIUS, y1 ) = white then
xChange * = - 1 fork paddlesound
elsif View.WhatDotColor (x1 - RADIUS, y1 ) = white then
xChange * = - 1 fork paddlesound
end if
end loop
|
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
DemonWasp
|
Posted: Mon Jan 12, 2009 11:43 am Post subject: RE:sound help |
|
|
What issues are you having? What are the symptoms of the problem? Keep in mind that many here don't have Turing on their computers (by choice), and may not be able to run your code to find out for themselves, particularly if they're missing "wallhit.wav" and "paddlesound.wav". |
|
|
|
|
 |
remember_987
|
Posted: Mon Jan 12, 2009 11:56 am Post subject: Re: sound help |
|
|
There are no "errors" with the code, as far as I can see I have coded it correctly, the only problem is when the sound is supposed to happen it doesn't. I have listened to the sound files outside of turing and they work fine, they have also been used by a friend of mine in a game he had so I'm fairly certain the sounds themselves are fine. Right now I am guessing I have a mistake somwhere that I haven't noticed which is what I'm hoping someone can help me with. |
|
|
|
|
 |
TheGuardian001
|
Posted: Mon Jan 12, 2009 3:16 pm Post subject: Re: sound help |
|
|
I think the problem is with your View.WhatDotColour collisions.
code: |
if View.WhatDotColor (x1, y1 + RADIUS) = white then
yChange *= -1 fork paddlesound
|
if your ball is drawn from y1 out until radius, then the colour at y1 + radius will always be the colour of the ball. try expanding the search a bit farther and it should work. if it doesn't, I have no idea what is wrong |
|
|
|
|
 |
andrew.
|
Posted: Mon Jan 12, 2009 4:23 pm Post subject: RE:sound help |
|
|
You shouldn't use whatdotcolour to make a collision with your ball. All you have to do is check whether y1 + RADIUS is higher than maxy, y1 - RADIUS is lower than 0, x1 + RADIUS is higher than maxx, and x1 - RADIUS is lower than 0 for your wall collisions. Just change the values a bit to make it match the paddle positions. |
|
|
|
|
 |
copthesaint

|
Posted: Mon Jan 12, 2009 8:01 pm Post subject: RE:sound help |
|
|
Umm did you happen to put the sound files in a separate folder or have you put it beside the save file?
If beside the saved file then everything is fine except maybe the collision...
if the sound file is in another folder likes sounds then you must lab el the folder that the sound is in |
|
|
|
|
 |
remember_987
|
Posted: Mon Jan 12, 2009 8:09 pm Post subject: Re: sound help |
|
|
I have updated the code to proper collision detection as you reccomended and I still have no functioning sound, any more ideas?
edit: I fiddled with the code a little, I'm not sure what I did but the sound is working, thanks everyone for the help |
|
|
|
|
 |
|
|