Powered by Invision Power Board

 
    Reply to this topicStart new topicStart Poll

> How do you program "with a chance" in GML?, SOLVED
United States
Ziso
  Posted: Sep 29 2007, 07:50 PM
Quote Post


Should I be concerned?
[*]

Group Icon
Group: Members
Posts: 992
Member No.: 3387
Joined: 2-March 07

Status: (0d) [--]


I'm making a Zelda game, and there are 4 different attacking sounds for Link, so i need with chance for GML.

This post has been edited by Zisomek on Sep 30 2007, 08:49 AM


--------------------
PMEmail PosterUsers WebsiteAOLMSN
Top
Brazil
VirtuMaster
Posted: Sep 29 2007, 08:11 PM
Quote Post


lurking member


Group Icon
Group: Members
Posts: 80
Member No.: 4109
Joined: 17-July 07

Status: (0d) [--]


There should be several ways of doing that.

I'm telling you one of them.

CODE

variable = 0 //Name this variable as you like.
variable = ceil(random(4)) //variable's value will get random, the max it can be is 4.
if variable = 1 sound_play(sound1) //name sound1 as the name of the Link attack sound.
if variable = 2 sound_play(sound2)
if variable = 3 sound_play(sound3)
if variable = 4 sound_play(sound4)


This doesn't include any really advanced coding. Don't forget to change the variable name and the sounds' names.

PS: I just wrote this from scratch, not sure if it'll work, but it should do so.


--------------------
V-Ware - WarioWare-styled minigame with 20 microgames, achievements, built in online highscore lists and more! Check it out.
PMEmail Poster
Top
Togo
Razz
Posted: Sep 29 2007, 08:20 PM
Quote Post



[*][*][*]

Group Icon
Group: Members
Posts: 6007
Member No.: 4259
Joined: 13-August 07

Status: (0d) [--]


Why not just use the "choose()" event like so:
CODE

choose(sound1,sound2,sound3,sound4)

It is basic but MUCH simpler.


--------------------
Allusion - [||--------] 25% complete
GridLocked - [||||------] 45% complete
my blog
PMEmail PosterAOL
Top
United States
Ziso
Posted: Sep 30 2007, 08:48 AM
Quote Post


Should I be concerned?
[*]

Group Icon
Group: Members
Posts: 992
Member No.: 3387
Joined: 2-March 07

Status: (0d) [--]


QUOTE (VirtuMaster @ Sep 29 2007, 09:11 PM)
There should be several ways of doing that.

I'm telling you one of them.

CODE

variable = 0 //Name this variable as you like.
variable = ceil(random(4)) //variable's value will get random, the max it can be is 4.
if variable = 1 sound_play(sound1) //name sound1 as the name of the Link attack sound.
if variable = 2 sound_play(sound2)
if variable = 3 sound_play(sound3)
if variable = 4 sound_play(sound4)


This doesn't include any really advanced coding. Don't forget to change the variable name and the sounds' names.

PS: I just wrote this from scratch, not sure if it'll work, but it should do so.

it worked.


--------------------
PMEmail PosterUsers WebsiteAOLMSN
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

  Topic Options Topic Options Reply to this topicStart new topicStart Poll

 




[ Script Execution time: 0.0387 ]   [ 14 queries used ]   [ GZIP Enabled ]   [ Server Load: 0.25 ]