# henki133

Member Since 24 Jan 2012
Offline Last Active Apr 19 2012 05:55 PM

### In Topic: Help with my first trigger event

17 April 2012 - 07:14 PM

why go that way when you can just add this code in a step event:
```if hp <= 0 {
//Things happen
}```

### In Topic: calculating great circle distance....

17 April 2012 - 07:08 PM

`collision_circle`
would be a good solution for you.

### In Topic: 2 variables: the bigger, the smaller. how?

14 March 2012 - 09:52 PM

You subtract.
a = 0
b = max-a

Now let's say max is 100,
if a is 100, b is zero.
If a is zero, b is 100.
So to solve your problem: 255-var

Thank you. Gah. I feel stupid.

### In Topic: Rotate About Center?

05 February 2012 - 03:36 PM

image_angle, I purpose?

### In Topic: Assigning 25+ attacks to 6 attack slots

02 February 2012 - 03:59 PM

SWITCH statements is much faster than IF statements:

Switch: (Should go in step event)

```switch (PARENT_VALUE) {
case 0: break;  //all attacks off - This means if PARENT_VALUE=0
case 1: ATTACK CODE HERE; break;     //the particular attack for the value 1. - This means if PARENT_VALUE=1
case 2: ATTACK CODE HERE; break;     //the particular attack for the value 2. - This means if PARENT_VALUE=2
//and so on..
}```
So, if you want to use this example, you just have to set the PARENT_VALUE to the particular number for the particular button. Like:
If you press Q:
then PARENT_VALUE=2;
Then it will do what the switch say is case 2.
ALWAYS put break; after you are done with the actions. If you don't, it might failiure.

Thanks a million! The way I'll be doing it is that I'll be spawning the object, that when clicked, will then initiate the attack (i.e. creates the attack object over the numbered slot)
To check if I understand the code, would this be correct? :

In the Attack Button's step event:
```action_create_object(attack_basic,64,570)      //Basic attack always in slot 1
switch (global.attackslot2) {
case 0: break;  //Do nothing
case 2: action_create_object(attack_ghostchilli,85,570); break;    //case 1 is basic attack, so is ignored. Draws "Ghost Chilli" attack object
//and so on..
}
switch (global.attackslot3) {
case 0: break;  //Do nothing
case 2: action_create_object(attack_ghostchilli,106,570); break;    //case 1 is basic attack, so is ignored. Draws "Ghost Chilli" attack object
//and so on..
//and then the same for the other 3 attack slots.
}```

No, what i meant was to put the switch statement in the step event and in the button events you define the PARENT_VALUE e.g. PARENT_VALUE=1,2,3,4 and so on depending on what button you press.
You could just remove all of the attack variables and use one single global.PARENT_VALUE for it to work. Then you put what to do when attacking in the cases. Voila!

If there is nothing to do in a case for the switch statement...simply don't put that case in there.

And no that is not what he meant. What you did was basically create a bunch of ifs using switch instead of one switch that replaces a bunch of ifs.

I think what he means is more like this:

```//attack array
slot[0] = 1 // 1 equals basic attack ; 2 is heavy attack etc
slot[1] = 0 // 0 equals empty
slot[2] = 0
etc...

// when you go to select a slot
attack = slot[x] //whatever slot is being selected
switch (attack)
{
case 1: // basic
case 2: // heavy
case 3: //special
etc...
}

```

No, that was not what I meant. And that is not necessary imo.
Also, the case 0: break; I just put there for show, because he may need to make it switch back to the regular player object using case 0.