Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Keyboard piano game

Author
Message
vid1987
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Oklahoma
Posted: 23rd Jan 2005 08:33
Hello i built a piano keyboard game. I need to make it where you can play 2 or 3 notes at the same time. can someone help me? here is the code


Vid
Gil Galvanti
19
Years of Service
User Offline
Joined: 22nd Dec 2004
Location: Texas, United States
Posted: 23rd Jan 2005 09:02
why dont u just do
if keystate(whatever)=1
play sound blah
endif
would that work?

Video games…they can take you places unreachable, impossible, unfeasible. They put you in the book...they put you in the movie...they put you in a world, a world that before could only be imagined.
vid1987
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Oklahoma
Posted: 23rd Jan 2005 10:56
i already did that but it wont play both sounds at the same time

Vid
vid1987
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Oklahoma
Posted: 23rd Jan 2005 10:56
how

Vid
Gil Galvanti
19
Years of Service
User Offline
Joined: 22nd Dec 2004
Location: Texas, United States
Posted: 23rd Jan 2005 13:36
hmm...idk why it wouldnt play them both

Video games…they can take you places unreachable, impossible, unfeasible. They put you in the book...they put you in the movie...they put you in a world, a world that before could only be imagined.
ReD_eYe
21
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 24th Jan 2005 00:58
Its because your stopping all the sounds playing each time before playing the latest sound...

Just take out the "gosub stopmusic" bit on each part of it.


http://www.dbspot.com/NYC
New years competition... Fo Shizzle.
vid1987
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Oklahoma
Posted: 24th Jan 2005 04:52
Yes i know but if i take out the gosub stopmusic: play music command it wont let you play a note more than 1 time

Vid
vid1987
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Oklahoma
Posted: 24th Jan 2005 11:24
i want to build a game where you have to press a key at the right time to get a score can someone help me?

Vid
vid1987
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Oklahoma
Posted: 24th Jan 2005 11:29
plz

Vid
Whisper Wind
21
Years of Service
User Offline
Joined: 5th Apr 2003
Location:
Posted: 24th Jan 2005 12:22
Here's a really simple solution - in your 'if' statements when you check for a keypress, add an 'else' in there to make it stop that specific piece of music if the keystate does not equal 1. Then simply take out the 'gosub stopmusic'.

It works because you're not ending all of the music, but instead only ending the certain pieces of music that have no keypress activating them.

Searching for file 'sanity'...
Sorry, no results were found.
wmf
19
Years of Service
User Offline
Joined: 6th Nov 2004
Location:
Posted: 24th Jan 2005 20:36
Quote: " I need to make it where you can play 2 or 3 notes at the same time"

there is no dbp command that will let you play 2 or 3 notes at the same time.
Visigoth
19
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 25th Jan 2005 13:36 Edited at: 25th Jan 2005 13:38
what if you converted to .wav, and used play sound instead of play music? Maybe I'll try....
edited to add:
you'll probably have to check for each sound, to see if it's already playing..
I'm assuming you have DBPro...
look up sound commands...
Visigoth
19
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 25th Jan 2005 14:43
ok, this works, but, you have to probably tweak it from here
(like check to see if a sound is playing, so it doesn't restart if you hold the key down)
name your .wav files in this format
pmidx.wav, where the x = 1 to 5 and put them in your project directory




I used a loop to load the .wav files....when you press the keys (a,s,d,e,r) then the .wav files play, until they reach the end. For you to make it work, you have to convert your .mid files into .wav files. Then use playsound instead of playmusic. With this example, if I press all the keys, all the .wav files play at the same time, over each other. I think there will be a limit to how many you can play at once, I think this is the voices capability of a soundcard. So, if you have a 32 voice soundcard, you should be able to play 32 different sounds, at once, but, I'm no expert on this, just my guess here. Hopes this helps...you were definitly on the right track...
Visigoth
19
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 25th Jan 2005 16:18
ok, here, this is better..
It only plays the sound file while the key is depressed, and, will play multiple sound files while multiple keys are depressed. I just got to playing with it because it seemed like a cool challenge, I'm sure it can be streamlined, but, it works!


For increment = 1 to 5
load sound "pmid" + str$(increment) + ".wav", increment
next increment

do

If keystate(30) = 1
If sound playing (1) = 0 then play sound 1
endIF
If keystate(30) = 0 then stop sound 1

If keystate(31) = 1
If sound playing (2) = 0 then play sound 2
endIf
If keystate(31) = 0 then stop sound 2

If keystate(18) = 1
If sound playing (3) = 0 then play sound 3
endIF
If keystate(18) = 0 then stop sound 3

If keystate(32) = 1
If sound playing (4) = 0 then play sound 4
endIF
If keystate(32) = 0 then stop sound 4

If keystate(19) = 1
If sound playing (5) = 0 then play sound 5
endIF
If keystate(19) = 0 then stop sound 5

loop

return
vid1987
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Oklahoma
Posted: 25th Jan 2005 21:44
Wow i didnt know you could convert files on dbpro thats pretty tight but there's 1 problem.. you cant load a midi as a sound it has to be specified as a music so i would need to convert the midis on another program and save them as wav or mp3 then load them as sound but i tried converting them to wav and mp3 and i cant get them to play and darkbasic doesnt even recognize them do you know any thing i could do?

Vid

Login to post a reply

Server time is: 2024-09-23 10:21:08
Your offset time is: 2024-09-23 10:21:08