05-13-2004, 05:17 PM | #1 (permalink) |
Insane
Location: Toronto
|
Old Tymey programming
Hi. I'm writing a program in Borland Pascal to get in touch with some old schoolery, and I wanted to know if there's a way to make two proedures run at the same time.
What I mean is, the Pascal way of making sounds from the internal speaker is like this.. sound(220); delay(500); NoSound; What that would do is play a tone at 220 hz, wait 500 ms, then cut the sound. However, I can't have a 500 millisecond delay if I want a sound to play in the middle of a game. I think you know what I mean now... any input is appreciated.
__________________
wra |
05-13-2004, 09:02 PM | #2 (permalink) |
I am Winter Born
Location: Alexandria, VA
|
Concurrency - any complicated game will not be a single thread.
I'm not entirely sure what Pascal's support for concurrency is - in CS class we used the "cobegin" instruction to deal with concurrently executed statements, but I'm not sure if that's a real instruction or a teaching aid.
__________________
Eat antimatter, Posleen-boy! |
05-16-2004, 02:49 PM | #3 (permalink) |
Location: Waterloo, Ontario
|
If you have no thread objects you can use (and you probably don't), you can just do what game programmers used to do (especially for console games).
You will undoubtedly have a main loop where you poll for input and render each frame of your game animation. Well, instead of timing your sounds to last a certain amount of time, time your sounds to last a certain number of game loop iterations. If your game runs smoothly, these two things will be equivalent. If not, well, your game didn't run smoothly anyways, so who's surprised that the sound was off? Anyway, you sound rather new to programming, so good luck! Last edited by KnifeMissile; 05-25-2004 at 10:45 AM.. |
05-17-2004, 08:30 AM | #4 (permalink) |
Professor of Drinkology
|
Agh... I had 4years of Pascal and now I can't remember the precise line of code you want...
I remember it had something to do with keypressed(); It was a library command that would detect when a key was pressed and return the value of true. So, you could develop a loop to play the 500Hz sound while keypressed(var)!=1 ... upon keypress, you would launch into a case statement (or whatever) to perform the requested action and then return to the sound loop. The delay should be short enough to be where your users would only hear a small click... Aside from that, I remember in HS we would occassionally "forget" the nosound(); command and have gawd-awful sounds coming from our PCs until we recompiled and executed a program *with* nosound(); But, its been a while since I played with Pascal. You've gotten me nostalgic for Turbo Pascal... maybe I'll play with it later. This guy has it in action: http://www.bowron.us/FILES/Languages/pascal Just Ctrl-F for "keypressed"
__________________
Blah. Last edited by tritium; 05-17-2004 at 08:33 AM.. |
Tags |
programming, tymey |
|
|