![]() |
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. |
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. |
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! |
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" |
Open 15, 8, 15, ... err, what were we talking about again?
Poke 53280, 1 Peek 53281... I can't remember?!. |
All times are GMT -8. The time now is 06:04 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project