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.

DarkBASIC Discussion / The true question I need to ask!

Author
Message
Guitar_M
21
Years of Service
User Offline
Joined: 2nd Oct 2003
Location:
Posted: 3rd May 2004 01:40 Edited at: 3rd May 2004 01:52
Ok, I got distracted with games. The truth is I bought this program so I could make a program called the six- string guitar. It will have every note. Ok, what I do is I record each note from the guitar and save it. Well, now I am trying to figure out how I put "if a key()=1 then play sound something.mp3..wav..etc, AND like I could click on the part of the string I wanted (I found out how to draw the neck of the guitar) like where I could click on a fret and it would play the sound. Could some one show me How to write that out....and would I need a Gosub or anything like that? Please help me. Let me add...I will never bug you guys again if someone will show me. (acctually I probably won't come to this site anymore!)

Thank you
Mike
GameKit
22
Years of Service
User Offline
Joined: 6th Mar 2003
Location: USA, Staring Blankly at a Computer
Posted: 3rd May 2004 17:59
Well... First you have to load all of the sounds you would want your guitar to play...

Load Sound "G.wav",1
Load Sound "B_Flat.wav",2

...ect...Make sure the sound files are in the same folder as your project...

Then... you have a couple of choices on how to make it play the sound when you press a button... you could use Inkey$() or Keystate()... personally I would use keystate although it is harder to understand...

If Keystate(5)=1 and sound playing(2)=0 then loop sound 2
If Keystate(5)=0 and sound playing(2)=1 then stop sound 2

Let me break this down for you... "If Keystate(5)=1" If you are pressing the "4" key,(5-1=4)..."and sound playing(2)=0" and the sound number 2 is not already playing... "then loop sound 2" then play sound number 2 over and over again...
The second line works more or less the same way...If your not pressing the "4" key and the sound number 2 is currently playing then it will stop the sound number 2 from playing...
(I hope that made sense...but I doubt it...lol)

To check to see if the user clicks a certain spot on the screen you would say...

If mousclick()=1 and MouseX()+5>20 and MouseX()-5<20
If MouseY()+5>130 and MouseY()-5<130
Play Sound 1
Endif
Endif

This would tell the computer that if the user used the left mouse button to click within 5 units of the XY screen coordinates then it will play the sound number 3...

Well... I hope that helps...

Previously known as "Game_Creator". Thou shalt not thwart the way of the dragon. For thou tasteth like chicken.
Guitar_M
21
Years of Service
User Offline
Joined: 2nd Oct 2003
Location:
Posted: 4th May 2004 04:17
THANK YOU SO MUCH....YOU ARE AWESOME!
GameKit
22
Years of Service
User Offline
Joined: 6th Mar 2003
Location: USA, Staring Blankly at a Computer
Posted: 4th May 2004 17:27 Edited at: 4th May 2004 17:28
Let me fix something... wouldn't let me use the edit button...

If mousclick()=1 and MouseX()+5>20 and MouseX()-5<20
If MouseY()+5>130 and MouseY()-5<130
Play Sound 3
Endif
Endif

This would tell the computer that if the user used the left mouse button to click within 5 units of the XY screen coordinates 20,130 then it will play the sound number 3...

Glad I helped...I do my best (or at least try)...

Previously known as "Game_Creator". Thou shalt not thwart the way of the dragon. For thou tasteth like chicken.
BadMonkey91
21
Years of Service
User Offline
Joined: 13th Jan 2004
Location:
Posted: 4th May 2004 18:09
That's a lot to do on your first program. Get ready for a lot of trail and error.

If it hooks your attention, you'll most likely hang yourself!

Guitar_M
21
Years of Service
User Offline
Joined: 2nd Oct 2003
Location:
Posted: 6th May 2004 07:13 Edited at: 6th May 2004 07:47
Hell yeah it is, but I have learned a ton. I am just starting to make it where you can record your sounds. Thank you for all your help, but I have on more question. How do make the A through z key play?

thanks
Mike
GameKit
22
Years of Service
User Offline
Joined: 6th Mar 2003
Location: USA, Staring Blankly at a Computer
Posted: 6th May 2004 17:46 Edited at: 6th May 2004 17:47
Type this near the top of your loop...

Set Cursor 0,0
Print Scancode()

Then run your program and press any key and watch as a number appears on the top-left of the screen...(Pressing the "A" key will give you the number 30... the "Z" key would be 44)

Now... use the keystate command again...
If Keystate(30)=1 and sound playing(2)=0 then loop sound 2
If Keystate(30)=0 and sound playing(2)=1 then stop sound 2

...now, if the "A" key is pressed it will loop the sound... If not, it will stop the sound...

Go to this thread http://darkbasic.thegamecreators.com/?m=forum_view&t=22030&b=7 scroll down a bit and you will see a picture with all the keystates listed on it...

Previously known as "Game_Creator". Thou shalt not thwart the way of the dragon. For thou tasteth like chicken.
Guitar_M
21
Years of Service
User Offline
Joined: 2nd Oct 2003
Location:
Posted: 7th May 2004 06:06
THANK YOU SO MUCH!!!!!All you guys are really nice! you have tought me alot. I just want to think you all...especially Game kit....YOU HELPED ME OUT TONS. Thank you
bibz1st
22
Years of Service
User Offline
Joined: 2nd Jan 2003
Location:
Posted: 8th May 2004 15:18
slightly on the same topic, I tried making a program (some fishtank thing) when run it was supposed to randomly recorded samples (of the person/people looking at it) and played them back ( also randomly )but couldnt get it working, anybody care to try it?
rob
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 11th May 2004 00:17
in Pro recording sound has this bug where you can only record to a sound number that was a sound (if you get my drift), just trying to create a sound from scratch will not work, thats why the example works but a real app won`t if you rely on it working as the help files say, if you check the example scource it uses the same sound number as a previously loaded sound to record to, (can`t say what since DB isn`t installed at the mo) so it works, not having a sound already loaded results in nothing, maybe thats the same problem you have (thought I would mention it), oh well!, hasten on patch 6.

Mentor.

PC1: P4 hyperthreading 3ghz, 1gig mem, 2x160gig hd`s, Nvidia FX5900 gfx, 6 way surround sound, PC2: AMD 1.2ghz, 512mb ram, FX5200 ultra gfx, stereo 16 bit soundblaster, ups.
bibz1st
22
Years of Service
User Offline
Joined: 2nd Jan 2003
Location:
Posted: 11th May 2004 22:28
thanx for that, it may be the problem.
I'm using DBC by the way
rob

Login to post a reply

Server time is: 2025-05-23 19:10:56
Your offset time is: 2025-05-23 19:10:56