# Difficulty Selection

**URL:** <https://forum.kirupa.com/t/difficulty-selection/185739>\
**Category:** programming\
**Created:** [April 16, 2006, 12:54am UTC](https://forum.kirupa.com/t/difficulty-selection/185739 "2006-04-16T00:54:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tyg3r](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/tyg3r/32/1341_2.png) [@Tyg3r](https://forum.kirupa.com/u/Tyg3r)\
**Post date:** [April 16, 2006, 12:54am UTC](https://forum.kirupa.com/t/difficulty-selection/185739/1 "2006-04-16T00:54:04Z")

</div>

Im trying to develop a way for my game to determin what difficulty settings were selected before making an action. So what I have tried to do is develop an IF/ELSE statment that says:

ActionScript Code:  
[FONT=Courier New][LEFT][COLOR=#808080]_//easy\</p\>_[/COLOR]  
\<p\>this.[COLOR=#0000ff]onEnterFrame[/COLOR] = [COLOR=#000000] **function** [/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]\</p\>  
\<p\>if COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]\</p\>  
\<p\> [COLOR=#000000] **var** [/COLOR] easy:[COLOR=#0000ff]Array[/COLOR] = [COLOR=#000000] **new** [/COLOR] [COLOR=#0000ff]Array[/COLOR]COLOR=#000000[/COLOR];\</p\>  
\<p\> [COLOR=#0000ff]this[/COLOR].[COLOR=#0000ff]gotoAndStop[/COLOR][COLOR=#000000]([/COLOR]easy[COLOR=#000000][[/COLOR][COLOR=#0000ff]Math[/COLOR].[COLOR=#0000ff]floor[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]Math[/COLOR].[COLOR=#0000ff]random[/COLOR]COLOR=#000000[/COLOR] \* easy.[COLOR=#0000ff]length[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]][/COLOR][COLOR=#000000])[/COLOR];\</p\>  
\<p\>[COLOR=#808080]_//normal\</p\>_[/COLOR]  
\<p\>[COLOR=#000000]}[/COLOR] [COLOR=#0000ff]else[/COLOR] [COLOR=#0000ff]if[/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]\</p\>  
\<p\> [COLOR=#000000] **var** [/COLOR] normal:[COLOR=#0000ff]Array[/COLOR] = [COLOR=#000000] **new** [/COLOR] [COLOR=#0000ff]Array[/COLOR]COLOR=#000000[/COLOR];\</p\>  
\<p\> [COLOR=#0000ff]this[/COLOR].[COLOR=#0000ff]gotoAndStop[/COLOR][COLOR=#000000]([/COLOR]normal[COLOR=#000000][[/COLOR][COLOR=#0000ff]Math[/COLOR].[COLOR=#0000ff]floor[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]Math[/COLOR].[COLOR=#0000ff]random[/COLOR]COLOR=#000000[/COLOR] \* normal.[COLOR=#0000ff]length[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]][/COLOR][COLOR=#000000])[/COLOR];\</p\>  
\<p\>[COLOR=#808080]_//hard\</p\>_[/COLOR]  
\<p\>[COLOR=#000000]}[/COLOR] [COLOR=#0000ff]else[/COLOR] [COLOR=#0000ff]if[/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]\</p\>  
\<p\> [COLOR=#000000] **var** [/COLOR] hard:[COLOR=#0000ff]Array[/COLOR] = [COLOR=#000000] **new** [/COLOR] [COLOR=#0000ff]Array[/COLOR]COLOR=#000000[/COLOR];\</p\>  
\<p\> [COLOR=#0000ff]this[/COLOR].[COLOR=#0000ff]gotoAndStop[/COLOR][COLOR=#000000]([/COLOR]hard[COLOR=#000000][[/COLOR][COLOR=#0000ff]Math[/COLOR].[COLOR=#0000ff]floor[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]Math[/COLOR].[COLOR=#0000ff]random[/COLOR]COLOR=#000000[/COLOR] \* hard.[COLOR=#0000ff]length[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]][/COLOR][COLOR=#000000])[/COLOR]; \</p\>  
\<p\> [COLOR=#000000]}[/COLOR]\</p\>  
\<p\>[COLOR=#000000]}[/COLOR]; \</p\>  
\<p\>  
[/LEFT]  
[/FONT]

Using various arrays to try and make it randomly select a certain frame just seems to be causeing issues. Its not actually selecting a frame and stoping… its just going nuts and I have no idea how to stop it.

Any ideas? Please take a look at the example I made.

Mark

---

<div class="post-metadata">

**Author:** ![nathan99](https://avatars.discourse-cdn.com/v4/letter/n/96bed5/32.png) [@nathan99](https://forum.kirupa.com/u/nathan99)\
**Post date:** [April 17, 2006, 7:30am UTC](https://forum.kirupa.com/t/difficulty-selection/185739/2 "2006-04-17T07:30:48Z")

</div>

I would do this;  
I would make all my buttons to change the difficulty, labelling them like setTo1, setTo2, setTo… etc up to 5.

After that I would place this on the frame;

```auto
for(var i:Number = 1; i<6; i++){
//scan through, 1-5
_root["setTo"+i].id = i;
//give each button an id, to set the speed
_root["setTo"+i].onRelease = function(){
//set the button's onRelease
setDiff(this.id);
//call the difficulty function, passing "id"
}
}
function setDiff(which){
//this function sets the difficulty
level = which;
//set level to "which" (the variable passed)
}

```

then whatever variables you want to be effected by the difficulty i would multiply is by level.

For example;

```auto

ball._y += speed*level

```

That is ONE basic method, plenty of others 😉
