Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, ozgur, AbrahamR, wdlmaster), 849 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Sound in lite-c is the biggest problem !!! #267645
05/25/09 17:03
05/25/09 17:03
Joined: Mar 2009
Posts: 17
warkarma Offline OP
Newbie
warkarma  Offline OP
Newbie

Joined: Mar 2009
Posts: 17
Hi all again. I have some more problems like always. I am trying to make sound work in Lite-C but it just doesn't work right. The thing i am trying to do is to make left mouse button shut bullets (a lot of them nonstop) and the right mouse button to explode 1 time a sec. And then i press left mouse button in the beginning it sound goes only one time and after a few moments it start working the way i want it to work but then i try to press right mouse button the explosion doesn't work, but then i hold right mouse button the sound starts working properly but the bullet sound doesn't work again. Anyway try it for your self and if you know the answer how to fix this problem please let me know.

download from here:
http://rapidshare.com/files/237116491/Sound.rar.html
or
http://rapidshare.com/files/237116918/Sound.rar.html

the code:

#include <acknex.h>;
#include <default.c>;
BMAP* sight_png = "sight.png";
SOUND* shoot_wav = "gun_1.wav";
SOUND* explode_wav = "explode.wav";

function gunsound();

function gunsound()
{
while(1)
{
if(mouse_left)
{
snd_play(shoot_wav, 30, 1);
wait(-0.1);
}
if(mouse_right)
{
snd_play(explode_wav,30,-1);
wait(-1);
}
wait(1);
}
}

function main()
{
screen_size.x = 800; // set the screen size
screen_size.y = 600;
video_screen = 2; // Window mode

mouse_spot.x = bmap_width(sight_png) /2; // sets the mouse spot
mouse_spot.y = bmap_height(sight_png)/2;
mouse_map = sight_png; // mouse bitmap
mouse_mode = 1; //mouse mode

gunsound();
while(1)
{
vec_set(mouse_pos,mouse_cursor);
wait(1);
}
} // end main



Thank you for your time


Trust NoOne (only me =])
_________________________
Re: Sound in lite-c is the biggest problem !!! [Re: warkarma] #267656
05/25/09 17:50
05/25/09 17:50
Joined: Mar 2009
Posts: 17
warkarma Offline OP
Newbie
warkarma  Offline OP
Newbie

Joined: Mar 2009
Posts: 17
I have made some progress. But i still can't have two sounds playing same time. The code:

#include <acknex.h>;
#include <default.c>;
BMAP* sight_png = "sight.png";
SOUND* shoot_wav = "gun_1.wav";
SOUND* explode_wav = "explode.wav";


function gunsound2();



function gunsound2()
{
while(1)
{
if(mouse_left)
{
SOUND* wavsound = snd_create("explode.wav");
var wavhandle = snd_play(wavsound,50,0);
wait(-1);
snd_remove(wavsound);
}
if(mouse_right)
{
SOUND* wavsound = snd_create("gun_1.wav");
var wavhandle = snd_play(wavsound,50,0);
wait(-0.1);
snd_remove(wavsound);
}
wait(1);
}
}

function main()
{
screen_size.x = 800; // set the screen size
screen_size.y = 600;
video_screen = 2; // Window mode

mouse_spot.x = bmap_width(sight_png) /2; // sets the mouse spot
mouse_spot.y = bmap_height(sight_png)/2;
mouse_map = sight_png; // mouse bitmap
mouse_mode = 1; //mouse mode


gunsound2();
while(1)
{
vec_set(mouse_pos,mouse_cursor);
wait(1);
}
} // end main


Please HELP !!!


Trust NoOne (only me =])
_________________________
Re: Sound in lite-c is the biggest problem !!! [Re: warkarma] #267657
05/25/09 18:00
05/25/09 18:00
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
var wavhandle;
function gunsound2()
{
while(1)
{
if(mouse_left)
{
wavhandle = snd_play(explode_wav,50,0);
wait(-1);
snd_remove(wavsound);
}
if(mouse_right)
{
wavhandle = snd_play(shoot_wav,50,0);
wait(-0.1);

.............

Last edited by Quadraxas; 05/25/09 18:00.

3333333333
Re: Sound in lite-c is the biggest problem !!! [Re: Quad] #267659
05/25/09 18:17
05/25/09 18:17
Joined: Mar 2009
Posts: 17
warkarma Offline OP
Newbie
warkarma  Offline OP
Newbie

Joined: Mar 2009
Posts: 17
Quadraxas.
Correct me if i am wrong.

The code:
function gunsound2()
{
while(1)
{
if(mouse_left)
{
wavhandle = snd_play(explode_wav,50,0);
wait(-1);
snd_remove(wavsound);
}
if(mouse_right)
{
wavhandle = snd_play(shoot_wav,50,0);
wait(-0.1);
snd_remove(wavsound);
}
wait(1);
}
}

It still waits for one sound to finish to start second one. And i need two sounds playing at the same time.


Trust NoOne (only me =])
_________________________
Re: Sound in lite-c is the biggest problem !!! [Re: warkarma] #267661
05/25/09 18:25
05/25/09 18:25
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
try defining another handle and use that for second sound(or dont use handles at all.)

also you need to remove snd_remove(wavsound); lines.


3333333333
Re: Sound in lite-c is the biggest problem !!! [Re: Quad] #267662
05/25/09 18:31
05/25/09 18:31
Joined: Mar 2009
Posts: 17
warkarma Offline OP
Newbie
warkarma  Offline OP
Newbie

Joined: Mar 2009
Posts: 17
Originally Posted By: Quadraxas
try defining another handle and use that for second sound(or dont use handles at all.)

also you need to remove snd_remove(wavsound); lines.


I have tried it and it still doesnt work right frown
var wavhandle;
var wavhandle2;

function gunsound2();

function gunsound2()
{
while(1)
{
if(mouse_left)
{
wavhandle = snd_play(explode_wav,50,2);
wait(-1);
// snd_remove(wavsound);
}
if(mouse_right)
{
wavhandle2 = snd_play(shoot_wav,50,-2);
wait(-0.1);
// snd_remove(wavsound);
}
wait(1);
}
}


Trust NoOne (only me =])
_________________________
Re: Sound in lite-c is the biggest problem !!! [Re: warkarma] #267663
05/25/09 18:40
05/25/09 18:40
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
it should, when exactly it should play and it doesnt?


3333333333
Re: Sound in lite-c is the biggest problem !!! [Re: Quad] #267665
05/25/09 18:53
05/25/09 18:53
Joined: Mar 2009
Posts: 17
warkarma Offline OP
Newbie
warkarma  Offline OP
Newbie

Joined: Mar 2009
Posts: 17
if you press left mouse button the explosion sound starts and while it is playing i am pressing right mouse button and it doesn't start till explosion sound is over


Trust NoOne (only me =])
_________________________
Re: Sound in lite-c is the biggest problem !!! [Re: warkarma] #267669
05/25/09 19:09
05/25/09 19:09
Joined: Jul 2007
Posts: 959
nl
F
flits Offline
User
flits  Offline
User
F

Joined: Jul 2007
Posts: 959
nl
you need to put them in 2 diferent func because you wait(-1) in the same loop


"empty"
Re: Sound in lite-c is the biggest problem !!! [Re: flits] #267670
05/25/09 19:12
05/25/09 19:12
Joined: Mar 2009
Posts: 17
warkarma Offline OP
Newbie
warkarma  Offline OP
Newbie

Joined: Mar 2009
Posts: 17
Woooohoooo !!!! smile it WORKS
THANK YOU VERY MUCH FOR YOUR HELP ALL

THE FINAL CODE:


#include <acknex.h>;
#include <default.c>;
BMAP* sight_png = "sight.png";
SOUND* shoot_wav = "gun_1.wav";
SOUND* explode_wav = "explode.wav";

var wavhandle;
var wavhandle2;

function gunsound();
function gunsound2();

function gunsound()
{
while(1)
{
if(mouse_left)
{
wavhandle = snd_play(explode_wav,50,2);
wait(-1);
// snd_remove(wavsound);
}
wait(1);
}
}


function gunsound2()
{
while(1)
{
if(mouse_right)
{
wavhandle2 = snd_play(shoot_wav,50,-2);
wait(-0.1);
// snd_remove(wavsound);
}
wait(1);
}
}



function main()
{
screen_size.x = 800; // set the screen size
screen_size.y = 600;
video_screen = 2; // Window mode

mouse_spot.x = bmap_width(sight_png) /2; // sets the mouse spot
mouse_spot.y = bmap_height(sight_png)/2;
mouse_map = sight_png; // mouse bitmap
mouse_mode = 1; //mouse mode

gunsound();
gunsound2();
while(1)
{
vec_set(mouse_pos,mouse_cursor);
wait(1);
}
} // end main

Last edited by warkarma; 05/25/09 19:13.

Trust NoOne (only me =])
_________________________
Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1