News:

MFG's Character of the Month: September 2026 Voting

Main Menu

Code optimization

Started by Black_Dahlia_Isis, May 16, 2005, 12:09:10 PM

Previous topic - Next topic

Black_Dahlia_Isis

Piece of code with PosAdd, which is a controller that move your char from a specified amount of pixel when triggered :


[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:)


[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.

Messatsu

Check my reply on RS for corrections and expansion.

Quote from: Bastard Wolf on May 12, 2008, 05:02:05 PM
Many people risk their lives everyday by having Mugen.

Black_Dahlia_Isis

I fixed the copy/paste typos I've forgotten here and there.
For expansion, people still need to check RS.