I have some music looping in the background of my game and when i run the code, there is a very noticeable gap when the loop ends and starts again. I've uploaded my 9 music files for you guys to mess around with if needed, is it a problem with my coding or do i need to find better quality loops?
here's the code too if you need it:
`setup camera
make camera 1
Set Camera Range 1, 30.0,170000.0
position camera 1, 500, -1000, -1000 `plain is facing toward monitor, so alter z instead of y for raised camera
point camera 1, 500, 0, 1000
`load music
for MusicLoad = 1 to 9
load music "" + str$(MusicLoad) + ".mp3", MusicLoad
next MusicLoad
`create data type for array
type CardInfo
Color as integer
Value$ as string
AlreadyMatched as boolean
FaceDown as boolean
FaceUp as boolean
Suit as integer
CardXPos as integer
CardYPos as integer
endtype
`create arrays and variables
dim Deck(52) as CardInfo `deck
dim FirstCard(1) as CardInfo `first clicked card info holder variable for match detecion
dim SecondCard(1) as CardInfo `second clicked card info holder variable for match detecion
dim Card(1) as CardInfo `function parameter being passed to match detection function
dim Shuffler(1) as CardInfo `variable to hold data during shuffle function
global NumberOfCardsFlipped = 0 `keeps track of how many cards have been flipped over
global FirstCardClicked `1st card clicked, info to be passed to card flipping and match detecting function
global SecondCardClicked `2nd card clicked, info to be passed to card flipping and match detecting function
global CardsToBeMatched `keeps track of how many cards have been passed to match detecting function
global FirstCard `holds info for 1st card sent to match detecting function
global SecondCard `holds info for 2nd card sent to match detecting function
global MatchedCards `holds number of cards that have been matched together for GameOver() function
global NowPlaying = 1 `holds number of song being played in MusicPlayer() function
`setup basic card info
data 0,0, 125,0, 250,0, 375,0, 500,0, 625,0, 750,0, 875,0, 1000,0,
data 0,-175, 125,-175, 250,-175, 375,-175, 500,-175, 625,-175, 750,-175, 875,-175, 1000,-175,
data 0,-350, 125,-350, 250,-350, 375,-350, 500,-350, 625,-350, 750,-350, 875,-350, 1000,-350,
data 0,-525, 125,-525, 250,-525, 375,-525, 500,-525, 625,-525, 750,-525, 875,-525, 1000,-525,
data 0,-700, 125,-700, 250,-700, 375,-700, 500,-700, 625,-700, 750,-700, 875,-700, 1000,-700,
data 0,-875, 125,-875, 250,-875, 375,-875, 500,-875, 625,-875, 750,-875, 875,-875, 1000,-875,
data 0,-1050, 125,-1050, 250,-1050, 375,-1050, 500,-1050, 625,-1050, 750,-1050
for z = 1 to 52
read Deck(z).CardXPos
read Deck(z).CardYPos
Deck(z).FaceDown = 1
Deck(z).FaceUp = 0
Deck(z).AlreadyMatched = 0
`Deck(z).Color = rgb((z*4), (z*4), (z*4))
next z
`start music
play music NowPlaying: loop music NowPlaying
`make cards and put deck on screen
StartGame()
Shuffle()
Deal()
`for tester = 1 to 52
`Deck(tester).AlreadyMatched = 1
`wait 5
`next tester
`********************************************************MAIN LOOP***********************************************************
while escapekey() <> 1 `hit Escape to exit game
rotate object 53, 0,30,0
Clock()
MouseControl()
MusicPlayer()
endwhile
`*****************************************************END OF MAIN LOOP********************************************************
`------------------------------------------------------END OF PROGRAM--------------------------------------------------------
`---------------------------------------------------------FUNCTIONS----------------------------------------------------------
FUNCTION StartGame() `draws the deck onscreen and assigns objects card values and textures
rotate object 53, 0, 3, 0
LastCardPos = 0 `keeps track of z value of card in deck
for a = 52 to 1 step -1
FallHeight = -120
make object box a, 100, 130, 0
`Assign card a value using MOD, and a specific color depending on what card it is, to group the cards by color
value = a mod 13
if value <= 0 then Deck(a).Value$ = "A": color object a, rgb(0, 255, 0): Deck(a).Color = rgb(0, 255, 0)
if value <=9 and value >= 1 then Deck(a).Value$ = str$(value + 1): color object a, rgb((value^value)+ 100, (value*25)+30, value*12):Deck(a).Color = rgb((value^value)+ 100, (value*25)+30, value*12)
if value = 10 then Deck(a).Value$ = "J": color object a, rgb(255,255,255): Deck(a).Color = rgb(255,255,255)
if value = 11 then Deck(a).Value$ = "Q": color object a, rgb(0,0,255):Deck(a).Color = rgb(0,0,255)
if value = 12 then Deck(a).Value$ = "K": color object a, rgb(255,0,0): Deck(a).Color = rgb(255,0,0)
`Assign Suit
Deck(a).Suit = int(a / 13.1) + 1
`make animation for cards falling onto deck
for b = 1 to 5
position object a, 0, 200, FallHeight `y pos is 200 so that deck will sit beyond card dealing area
FallHeight = FallHeight + 20
`wait 1
next b
position object a, 0, 200, LastCardPos `these 2 lines place cards slightly above each other
LastCardPos = LastCardPos - 1 `creating the appearance of a stack of cards
next a
ENDFUNCTION
FUNCTION Deal() `deals the cards out onscreen
for a = 1 to 52
position object a, Deck(a).CardXPos, Deck(a).CardYPos, 1
wait 30
next a
ENDFUNCTION
FUNCTION Shuffle() `randomizes the card data
randomize timer()
for n = 1 to 5000
card1 = rnd(51) + 1
card2 = rnd(51) + 1
if card1 = card2 `make sure each of the 52 cards are represented by making sure that the 2 variables that
while card1 = card2 `store the random object numbers are not the same
card1 = rnd(51) + 1
card2 = rnd(51) + 1
endwhile
endif
Shuffler(1).Color = Deck(card1).Color
Shuffler(1).Value$ = Deck(card1).Value$
Shuffler(1).AlreadyMatched = Deck(card1).AlreadyMatched
Shuffler(1).FaceDown = Deck(card1).FaceDown
Shuffler(1).FaceUp = Deck(card1).FaceUp
Shuffler(1).Suit = Deck(card1).Suit
Deck(card1).Color = Deck(card2).Color
Deck(card1).Value$ = Deck(card2).Value$
Deck(card1).AlreadyMatched = Deck(card2).AlreadyMatched
Deck(card1).FaceDown = Deck(card2).FaceDown
Deck(card1).FaceUp = Deck(card2).FaceUp
Deck(card1).Suit = Deck(card2).Suit
color object card1, Deck(card1).Color
Deck(card2).Color = Shuffler(1).Color
Deck(card2).Value$ = Shuffler(1).Value$
Deck(card2).AlreadyMatched = Shuffler(1).AlreadyMatched
Deck(card2).FaceDown = Shuffler(1).FaceDown
Deck(card2).FaceUp = Shuffler(1).FaceUp
Deck(card2).Suit = Shuffler(1).Suit
color object card2, Deck(card2).Color
next n
ENDFUNCTION
FUNCTION FlipFirstCardUp(WhichCardOne) `flips the first card over that is clicked
if Deck(WhichCardOne).AlreadyMatched = 1 `if the card has already been matched don't continue trying to match it again
exitfunction
endif
if Deck(WhichCardOne).FaceUp = 0 and Deck(WhichCardOne).FaceDown = 1 `if card is face down, set its values to face up
Deck(WhichCardOne).FaceDown = 0
Deck(WhichCardOne).FaceUp = 1
else
for ErrorMessage = 1 to 70 `if its already face up, give error message
text (screen width() - ((Screen width()/10) * 9)), (screen height() - ((Screen height()/10) * 9)), "That card has already been turned over. Please try another card."
wait 1
next ErrorMessage
exitfunction
endif
`text 10,10, Deck(WhichCardOne).Value$
for MoveUp = 1 to 5 `if card is being set to face up, animate the card flipping over and being tilted
move object up WhichCardOne, 6 `toward the player
wait 5
next MoveUp
for TwistLeft = 1 to 10
turn object left WhichCardOne, 18
wait 5
next TwistLeft
for PitchDown = 1 to 5
pitch object down WhichCardOne, 6
wait 5
next PitchDown
wait 1500 `short delay for card to face toward player
for PitchUp = 1 to 5
pitch object up WhichCardOne, 6
wait 5
next PitchUp
for MoveDown = 1 to 5
move object down WhichCardOne, 6
wait 5
next MoveDown
MatchDetector(WhichCardOne) `send the first card's data to match detection functino
ENDFUNCTION
FUNCTION FlipSecondCardUp(WhichCardTwo) `flips 2nd card over that is flipped
if Deck(WhichCardTwo).AlreadyMatched = 1 `same as function above
exitfunction
endif
if Deck(WhichCardTwo).FaceUp = 0 and Deck(WhichCardTwo).FaceDown = 1 `same as function above
Deck(WhichCardTwo).FaceDown = 0
Deck(WhichCardTwo).FaceUp = 1
else
for ErrorMessage = 1 to 70 `same as function above
text (screen width() - ((Screen width()/10) * 9)), (screen height() - ((Screen height()/10) * 9)), "That card has already been turned over. Please try another card."
wait 1
next ErrorMessage
exitfunction
endif
`text 10,10, Deck(WhichCardTwo).Value$
for MoveUp = 1 to 5 `same as function above
move object up WhichCardTwo, 6
wait 5
next MoveUp
for TwistLeft = 1 to 10
turn object left WhichCardTwo, 18
wait 5
next TwistLeft
for PitchDown = 1 to 5
pitch object down WhichCardTwo, 6
wait 5
next PitchDown
wait 1500
for PitchUp = 1 to 5
pitch object up WhichCardTwo, 6
wait 5
next PitchUp
for MoveDown = 1 to 5
move object down WhichCardTwo, 6
wait 5
next MoveDown
MatchDetector(WhichCardTwo) `sends 2nd card's data to match detection function
ENDFUNCTION
FUNCTION FlipCardDown(WhichCard) `turns card back over
for MoveUp = 1 to 5
move object up WhichCard, 6
wait 10
next MoveUp
for TwistLeft = 1 to 10
turn object left WhichCard, 18
wait 10
next TwistLeft
for MoveDown = 1 to 5
move object down WhichCard, 6
wait 10
next MoveDown
Deck(WhichCard).FaceDown = 1 `sets card data back to face down
Deck(WhichCard).FaceUp = 0
ENDFUNCTION
FUNCTION MouseControl() `let player use mouse to interact with cards
if MouseClick() = 1 `if mouse is clicked
NumberOfCardsFlipped = NumberOfCardsFlipped + 1 `increment how many cards have been clicked so far
if NumberOfCardsFlipped = 1
FirstCardClicked = pick object (mousex(), mousey(),1,52) `if 1, send that card data to card flipper
FlipFirstCardUp(FirstCardClicked)
exitfunction
else
if NumberOfCardsFlipped = 2
SecondCardClicked = pick object (mousex(), mousey(),1,52) `if 2 send 2nd card data to card flipper
FlipSecondCardUp(SecondCardClicked)
NumberOfCardsFlipped = 0 `set # of cards clicked back to 0 for next match test
endif
endif
endif
ENDFUNCTION
FUNCTION MatchDetector(Card)
CardsToBeMatched = CardsToBeMatched + 1
if CardsToBeMatched = 1
FirstCard = Card
exitfunction
endif
if CardsToBeMatched = 2
SecondCard = Card
if Deck(FirstCard).Value$ = Deck(SecondCard).Value$
Deck(FirstCard).AlreadyMatched = 1
Deck(SecondCard).AlreadyMatched = 1
hide object FirstCard
hide object SecondCard
CardsToBeMatched = 0
MatchedCards = MatchedCards + 2
exitfunction MatchedCards
else
FlipCardDown(FirstCard)
Deck(FirstCard).FaceUp = 0
Deck(FirstCard).FaceDown = 1
FlipCardDown(SecondCard)
Deck(SecondCard).FaceUp = 0
Deck(SecondCard).FaceDown = 1
CardsToBeMatched = 0
endif
endif
ENDFUNCTION MatchedCards
FUNCTION Clock()
ink rgb(255,153,0), 0
line 5,5,140,5
line 5,5,5,28
line 5,28,140,28
line 140,5,140,28
seconds$ = right$(get time$(), 3)
minutes$ = mid$(get time$(), 4) + mid$(get time$(), 5)
hours$ = left$(get time$(), 3)
set text font "Arial"
set text size 16
text 10,10, "The time is: " + hours$ + minutes$ + seconds$
ENDFUNCTION
FUNCTION MusicPlayer()
if inkey$() = "1" then stop music NowPlaying: play music 1: loop music 1: NowPlaying = 1: exitfunction NowPlaying
if inkey$() = "2" then stop music NowPlaying: play music 2: loop music 2: NowPlaying = 2: exitfunction NowPlaying
if inkey$() = "3" then stop music NowPlaying: play music 3: loop music 3: NowPlaying = 3: exitfunction NowPlaying
if inkey$() = "4" then stop music NowPlaying: play music 4: loop music 4: NowPlaying = 4: exitfunction NowPlaying
if inkey$() = "5" then stop music NowPlaying: play music 5: loop music 5: NowPlaying = 5: exitfunction NowPlaying
if inkey$() = "6" then stop music NowPlaying: play music 6: loop music 6: NowPlaying = 6: exitfunction NowPlaying
if inkey$() = "7" then stop music NowPlaying: play music 7: loop music 7: NowPlaying = 7: exitfunction NowPlaying
if inkey$() = "8" then stop music NowPlaying: play music 8: loop music 8: NowPlaying = 8: exitfunction NowPlaying
if inkey$() = "9" then stop music NowPlaying: play music 9: loop music 9: NowPlaying = 9: exitfunction NowPlaying
if inkey$() = "*" then stop music NowPlaying
if inkey$() = "-" then set music volume NowPlaying, (music volume(NowPlaying) - 10)
if inkey$() = "+" then set music volume NowPlaying, (music volume(NowPlaying) + 10)
ink rgb(255,153,0), 0
line 864,5,1019,5
line 864,28,1019,28
line 864,5,864,28
line 1019,5,1019,28
center text 941,10, "Now Playing: Track No. " + str$(NowPlaying)
ENDFUNCTION NowPlaying
DBPro User
PC: WinXP, AthlonXP 2100+ 1.7ghz, 80gb HD, Nvidia GeForce FX 5200 (128mb onboard RAM), 512mb DDR400 system RAM. Thank you for your help.