Turing Music
Author |
Message |
Polar
|
Posted: Tue Apr 19, 2016 5:21 pm Post subject: Turing Music |
|
|
I want music to play on command by clicking a button. I have three buttons set up alongside the rest of the game. My goal is to have a song play when you click the button, along with having a title appear. However, clicking the buttons does not do anything. Help.
Relevant Code: (Note that this is in a larger loop)
%Song Buttons
drawfillbox (880, 100, 980, 200, black)
drawfillbox (890, 110, 970, 190, grey)
Font.Draw ("Lance's", 895, 160, font3, blue)
Font.Draw ("Theme", 895, 130, font3, blue)
drawfillbox (1000, 100, 1100, 200, black)
drawfillbox (1010, 110, 1090, 190, grey)
Font.Draw ("Cynthia's", 1012, 160, font4, blue)
Font.Draw ("Theme", 1015, 130, font3, blue)
drawfillbox (1120, 100, 1220, 200, black)
drawfillbox (1130, 110, 1210, 190, grey)
Font.Draw ("Lake", 1145, 160, font3, blue)
Font.Draw ("Trio", 1148, 130, font3, blue)
Mouse.Where (mX2, mY2, button2)
if (button2 = 1) and (mX2 >= 890) and (mX2 <= 970) and (mY2 >= 110) and (mY2 <= 190) then
fork lance
Font.Draw ("Song: Pokemon HeartGold & SoulSilver - Vs. Lance", 890, 220, font, black)
elsif (button2 = 1) and (mX2 >= 1010) and (mX2 <= 1090) and (mY2 >= 110) and (mY2 <= 190) then
fork cynthia
Font.Draw ("Song: Pokemon Diamond, Pearl, & Platinum - Vs. Cynthia", 890, 220, font, black)
elsif (button2 = 1) and (mX2 >= 1130) and (mX2<= 1210) and (mY2 >= 110) and (mY2<= 190) then
fork trio
Font.Draw ("Song: Pokemon Diamond, Pearl, & Platinum - Vs. Azelf/Mesprit/Uxie", 890, 220, font, black)
end if |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Dreadnought
|
Posted: Tue Apr 19, 2016 8:22 pm Post subject: Re: Turing Music |
|
|
The relevant code doesn't say very much. Can you make the buttons do anything? If so, then the problem is elsewhere. If not, how often do you check if the buttons are being clicked?
EDIT: Also, please wrap your code with syntax tags like this to make it easier to read.
code: | [syntax="Turing"]
Your code here
[/syntax] |
|
|
|
|
|
![](images/spacer.gif) |
lordroba
![](http://compsci.ca/v3/uploads/user_avatars/59807821047352e408f0e3.jpg)
|
Posted: Tue Apr 26, 2016 9:25 pm Post subject: Re: Turing Music |
|
|
It might be a good idea to put your Mouse.Where command inside of a loop so the user has more than one chance to click. They might accidentally click outside the boxes.
For debugging purposes I like to use the code from the Turing reference manual. This way you know exactly what the x and y coordinates are, and what the button value is while you are testing your program.
Turing: |
var x, y, button : int
loop
Mouse.Where (x, y, button )
Text.Locate (1, 1)
if button = 0 then
put x : 4, " ", y : 4, " button up"
else
put x : 4, " ", y : 4, " button down"
end if
end loop
|
For testing purposes you could also have it display the song name when you click the appropriate box. At least this way you know that it enters the fork even though you can't hear the music for some reason.
For example:
Turing: |
process lance
Text.Locate (1, 1)
put "Playing song number 1"
Music.PlayFile ("Pokemon HeartGold & SoulSilver - Vs. Lance.mp3")
end lance
|
|
|
|
|
|
![](images/spacer.gif) |
|
|