PDA

View Full Version : dos sound


zoviac
11-21-2002, 04:20 PM
ok, so nobody got answer to my collision detection problem, ill focus on that later, but now i would be interested in playing sound in dos wit sound blaster, i would like tuorials or source about wav, woc, and s3m file types. Which would be most simple to program?

sedarious
11-21-2002, 04:59 PM
http://gamedev.net/

You can find stuff on collision detection here too...

sans-hubris
11-21-2002, 11:44 PM
Collision detection is really easy. It's all about understanding the math behind the objects that are colliding. It's what you do once object collide that is the hard part (i.e. implementing the physics.)

zoviac
11-23-2002, 07:35 AM
hmm, ok, but i would appreciate someone giving me a simple collision detection source, for example with ascii characters..

AND I WOULD LIKE SOME HELP WITH SOUND TOO :)

zoviac
12-06-2002, 05:12 PM
hmm, this sucks... comeon u prolly all c gurus, u should know about this :)

jamessan
12-06-2002, 05:20 PM
Most people won't just give you code to do stuff. If you have code that isn't working, people will more than likely help you figure out what's wrong. Just doing a quick search of the link submitted by sedarious (http://gamedev.net), I found 4 articles on collision detection.

zoviac
12-06-2002, 05:23 PM
i know.. but im looking for a bit simpler code.. especially ascii

jamessan
12-06-2002, 05:30 PM
So, adapt the code/algorithms given in those articles to what you are to do.

cverick
12-07-2002, 02:03 PM
http://www.gametutorials.com/Tutorials/c++/Cpp_Pg4.htm

Has 2 tutorials on collision detection that I believe you are looking for.

bwkaz
12-07-2002, 02:33 PM
Wait a minute, collision detection with ASCII characters?!?! That's simple! Just check to see if the x and y of whatever's moving are the same as (or are one off from) whatever it's supposed to be colliding with!

Everything's quantized to one character cell, so it can't be that difficult to figure these things out...

zoviac
12-10-2002, 02:24 PM
hmm, i apparently have said this the wrong way, of course its simple to DETECT the collision, but my real problem is, how to make it actually collide (not go thru the thing, but to freeze 1 block before it), thats what im really asking..
and in the tutorial someone(dont remember the name) gave me, i have that one, its on windows, i would like it on dos..

sedarious
12-10-2002, 03:51 PM
Find the distance between them - if its less than the sqrt(2) then they have collided (assuming integer positions).

Strike
12-10-2002, 04:14 PM
Simple algorithm: Given it's current position and velocity, calculate the next potential cell for travel. If that cell is occupied, boom, collision. If not, move freely into that cell.

zoviac
12-15-2002, 02:41 PM
ok, but i cant make it freeze if the cell is taken... it jumps 2 cells backwards..

skidooer
12-15-2002, 06:32 PM
Originally posted by zoviac
i know.. but im looking for a bit simpler code.. especially ascii
I threw this together for you.


#include <windows.h>
#include <stdio.h>
#include <conio.h>

#define X_SIZE 51
#define Y_SIZE 9

char board[][X_SIZE] = {
"##################################################",
"# #",
"################################################ #",
"# #",
"# ####################### #######################",
"# #1111111111111111111111# #11111111111111111111#",
"# ######################### #####################",
"# #",
"##################################################"
};
HANDLE out;

int valid_move(int x, int y, int *px, int *py) {
if(board[y][x] != ' ')
return 0;

*px = x;
*py = y;

return 1;
}

int print_board() {
int i;

for(i = 0; i < Y_SIZE; i++)
puts(board[i]);

return i;
}

void writeto(int x, int y, char key) {
COORD pos = {x, y};
DWORD len;

WriteConsoleOutputCharacter(out, &key, sizeof(key), pos, &len);
}

void erase(int x, int y) {
writeto(x, y, ' ');
}

void move(int x, int y) {
writeto(x, y, '@');
}

int main() {
int n, x = 1, y = 1;
out = GetStdHandle(STD_OUTPUT_HANDLE);

print_board();
move(x, y);

while(1) {
if(kbhit()) {
n = getch();
switch(n) {
case 72:
erase(x, y);
valid_move(x, y - 1, &x, &y);
move(x, y);
break;

case 75:
erase(x, y);
valid_move(x - 1, y, &x, &y);
move(x, y);
break;

case 77:
erase(x, y);
valid_move(x + 1, y, &x, &y);
move(x, y);
break;

case 80:
erase(x, y);
valid_move(x, y + 1, &x, &y);
move(x, y);
break;
}
}
}

return 0;
}


It's really not hard at all, just don't move if it collides! I do use some Windows specific functions since I was not writing a DOS application, but you should be able to come up with DOS equvalents.

Note: Looks like this thing ate my board array, you'll have to fix it...

zoviac
12-17-2002, 10:23 AM
I got it. Thanks yall, i would like links for some sound tutorials now... (not c++ and not windows links plz)

zoviac
12-29-2002, 04:04 PM
umm. nevermind i got it..