YesNoOk
avatar

Code optimization (Read 2757 times)

Started by Black_Dahlia_Isis, May 16, 2005, 12:09:10 pm
Share this topic:
Code optimization
#1  May 16, 2005, 12:09:10 pm
  • ****
  • ~ Esprit guerrier ~
    • madahine.net/bdi/
Piece of code with PosAdd, which is a controller that move your char from a specified amount of pixel when triggered :

Code:
[State 2450, 3]
type = PosAdd
trigger1 = AnimElem = 1
x = -17

[State 2450, 4]
type = PosAdd
trigger1 = AnimElem = 2
x = -8

[State 2450, 5]
type = PosAdd
trigger1 = AnimElem = 3
x = 23

[State 2450, 6]
type = PosAdd
trigger1 = AnimElem = 4
x = 7

[State 2450, 7]
type = PosAdd
trigger1 = AnimElem = 5
x = 10


If you remember that a true trigger = "1", you can merge all these controllers in one :
(which is far shorter isn't it ? :sugoi:)

Code:
[State 2450, 3]
type = PosAdd
trigger1 = AnimElem = 1
trigger2 = AnimElem = 2
trigger3 = AnimElem = 3
trigger4 = AnimElem = 4
trigger5 = AnimElem = 5
x = ((AnimElem = 1) * (-17)) + ((AnimElem = 2) * (-8)) + ((AnimElem = 3) * 23) + ((AnimElem = 4) * 7) + ((AnimElem = 5) * (-10))

where "x" for trigger1 true = (1 * (-17)) + (0 * (-8)) + (0 * 23) + (0 * 7) + (0 * -10)
                                           = -17 + 0 + 0 + 0 + 0
                                           = -17 of course, which is the x value for trigger1 true.
                                              ... same for other triggers.
Last Edit: May 16, 2005, 04:19:45 pm by Isis, Dahlia Noir
Re: Code optimization
#2  May 16, 2005, 03:59:10 pm
  • ******
  • In after lock
    • mugenguild.com/~messatsu/index.html
Check my reply on RS for corrections and expansion.


Many people risk their lives everyday by having Mugen.
Re: Code optimization
#3  May 16, 2005, 04:21:13 pm
  • ****
  • ~ Esprit guerrier ~
    • madahine.net/bdi/
I fixed the copy/paste typos I've forgotten here and there.
For expansion, people still need to check RS.