Need help with Game music
Author |
Message |
Badsniper
|
Posted: Sun Jun 05, 2011 3:48 pm Post subject: Need help with Game music |
|
|
What is it you are trying to achieve?
I am trying to make my game change the music it plays depending on the level you are on. And it has to keep playing that same song as long as you stay on the same level.
What is the problem you are having?
My program will play the correct level song, but it won't loop that song, it actually goes to a different process and plays that song.
Describe what you have tried to solve this problem
I've put loops in and out of the process, and I've tried moving the Music.PlayFileStop, but to no avail.
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Please note, This code won;t work without all of the include files and stuff, so don't try running it.
Turing: |
var credits : int := Pic.FileNew ("CREDITS.bmp")
var screen : int
var menu1, menu2 : boolean := false
var save : int := 1
var levelend : boolean := false
screen := Window.Open ("graphics:800;500;nobuttonbar;offscreenonly;nocursor")
var creditscroll := - 1 * Pic.Height (credits ) + maxy
include "Movement.t"
include "CustomMovement.t"
include "menu.t"
process MUSIC
loop
Music.PlayFile ("Songs\\ODIWUAACMUSIC" + intstr (level ) + ".mp3")
exit when levelend
end loop
end MUSIC
process CUSTOM_MUSIC
loop
Music.PlayFile ("Songs\\ODIWUAACMUSIC1.mp3")
end loop
end CUSTOM_MUSIC
process MENU_MUSIC
loop
Music.PlayFile ("Songs\\ODIWUAAC_MUSIC_MENU.mp3")
end loop
end MENU_MUSIC
process CREDITS_MUSIC
Music.PlayFile ("Songs\\ODIWUAAC_CREDITS_MUSIC.mp3")
end CREDITS_MUSIC
proc CREDITS
cls
Pic.Draw (credits, 0, creditscroll, 0)
View.UpdateArea (0, 0, maxx, maxy)
loop
cls
Pic.Draw (credits, 0, creditscroll, 0)
creditscroll + = 2
View.UpdateArea (0, 0, maxx, maxy)
delay (50)
exit when creditscroll >= 0 or hasch
end loop
Music.PlayFileStop
delay (2000)
cls
View.Update
end CREDITS
proc NEW_GAME
levelend := false
menu1 := false
menu2 := true
cls
loop
x := 150
y := 75
movement
if done = false then
level + = 1
save := level
levelend := true
cls
else
done := false
levelend := true
exit
end if
exit when level = 2
end loop
if level = 2 then
CREDITS
end if
end NEW_GAME
proc CUSTOM
level := 1
for b : 1 .. 3
cls
levelend := false
x := 150
y := 75
custommovement
if done2 = false then
level + = 1
levelend := true
else
done2 := false
levelend := true
exit
end if
end for
end CUSTOM
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
menu1 := true
loop
fork MENU_MUSIC
MENU
Music.PlayFileStop
if start = 4 then
fork CREDITS_MUSIC
CREDITS
Music.PlayFileStop
elsif start = 45 then
fork CUSTOM_MUSIC
CUSTOM
Music.PlayFileStop
elsif start = 55 then
fork MUSIC
NEW_GAME
Music.PlayFileStop
elsif start = 87 then
fork MUSIC
level := save
NEW_GAME
Music.PlayFileStop
end if
end loop
|
Please specify what version of Turing you are using
4.1.1 |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Raknarg

|
Posted: Sun Jun 05, 2011 3:59 pm Post subject: RE:Need help with Game music |
|
|
Why are you using processes for it, out of curiosity? |
|
|
|
|
 |
Badsniper
|
Posted: Sun Jun 05, 2011 4:32 pm Post subject: Re: Need help with Game music |
|
|
Because that's the only way I know how to get music to play in the background while running the game... |
|
|
|
|
 |
Raknarg

|
Posted: Sun Jun 05, 2011 4:37 pm Post subject: RE:Need help with Game music |
|
|
Why don't you try:
|
|
|
|
|
 |
Badsniper
|
Posted: Sun Jun 05, 2011 5:07 pm Post subject: Re: Need help with Game music |
|
|
Well, that sort of helped. My code now looks like this:
When I run my custom levels, the process (CUSTOM_MUSIC) works fine, and so does the MENU_MUSIC. However, the MUSIC process doesn't play songs anymore...
I have checked what level equals, and it equals 1. So it should play the same song as the the Custom Music process... but it's not... |
|
|
|
|
 |
Raknarg

|
Posted: Sun Jun 05, 2011 5:31 pm Post subject: RE:Need help with Game music |
|
|
I meant that so that you don't need processes at all. In fact, you could do the exact same thing that way, just without processes. If I were you, I would use a string variable for the name and just change that whenever I changed the music.
If you dont want to try it, then I can't really help you beyond that. |
|
|
|
|
 |
Badsniper
|
Posted: Sun Jun 05, 2011 5:44 pm Post subject: Re: Need help with Game music |
|
|
Thank you for the No-Processes suggestion.
Everything works now. THANKS! |
|
|
|
|
 |
|
|