Need help, NOW!!

Talk about making games.

Need help, NOW!!

Postby Game A Gogo » Wed Sep 28, 2005 12:46 am

When I press the space bar, I want to play a sound, but variating to 3 sound, I dont want to make the player always to do the same sound when hes jumping.
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby willg101 » Wed Sep 28, 2005 1:09 am

Use this code on key down:
Code: Select all
myvar=rand(3)
if (myvar=1)PlaySound("my_sound_1", 1.000000, 1, 0.000000);
if (myvar=2)PlaySound("my_sound_2", 1.000000, 1, 0.000000);
if (myvar=3)PlaySound("my_sound_3", 1.000000, 1, 0.000000);

If you want a random noise, that is. Otherwise, use this, which will play three sounds in "order":
Code: Select all
if (myvar=1)PlaySound("my_sound_1", 1.000000, 1, 0.000000);
if (myvar=2)PlaySound("my_sound_2", 1.000000, 1, 0.000000);
if (myvar=3)PlaySound("my_sound_3", 1.000000, 1, 0.000000);
myvar++;
if (myvar=4) myvar=1;


HTHs

[Edit: Feel free to correct my code if it's incorrect, anyone]
http://www.wish-games.com
Old betas now available!!
User avatar
willg101
 
Posts: 473
Joined: Thu Dec 16, 2004 12:08 am
Location: West Michigan
Score: 5 Give a positive score

Postby makslane » Wed Sep 28, 2005 2:07 am

Don't use if(myvar=1) .... //put the 1 in myvar
Use: if(myvar == 1) ... //Compares myvar to 1
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby Game A Gogo » Wed Sep 28, 2005 8:10 pm

I alredy knew that Makslane, but tanx anyway...
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby willg101 » Wed Sep 28, 2005 10:21 pm

makslane wrote:Don't use if(myvar=1) .... //put the 1 in myvar
Use: if(myvar == 1) ... //Compares myvar to 1


Huh? What's this do differently? I didn't have any problems when I tested it...
Thanks for helping, I am really trying to learn better script!
http://www.wish-games.com
Old betas now available!!
User avatar
willg101
 
Posts: 473
Joined: Thu Dec 16, 2004 12:08 am
Location: West Michigan
Score: 5 Give a positive score

Postby Fuzzy » Wed Sep 28, 2005 11:57 pm

When you use if (var == 1) you are telling GE to check if var is equal to one. When you do (var = 1) you are telling GE to make var equal to one. It might work, but it might leave you with a nasty bug...
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Postby Game A Gogo » Wed Sep 28, 2005 11:57 pm

its because when you use '=' it normaly does nothing, its like its going to set something to a number, but ant because of "if(" and ")"

so I greatly recemend to use ' =='.
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby Joshua Worth » Thu Sep 29, 2005 12:12 am

I know a bit about it, I read a C++ manual(but I couldn't be bothered finishing it :oops: )
Stay sweet
User avatar
Joshua Worth
 
Posts: 515
Joined: Tue Jul 19, 2005 12:00 am
Location: Stralia
Score: 5 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest