1+ // TODO: make it so this can work on any song cuz rn this only works on VSlicey Charts
2+ // holy shit this code is messy:sob:
3+
4+ var epicChart : Dynamic ;
5+ var randomGuys : Array = [];
6+
7+ function postCreate () {
8+ epicChart = Paths .json (' data/songs/' + PlayState .instance .SONG .song .toLowerCase () + ' /chart' ).notes .picospeaker ;
9+ playAnim (" shoot0-loop" , true );
10+
11+ for (i => note in epicChart ) {
12+ if (FlxG .random .bool (16 ) && FlxG .save .data .distractions ) {
13+ var tankmanGuy = new FlxAnimate (500 , 200 + FlxG .random .int (50 , 100 ));
14+ tankmanGuy .frames = Paths .getAnimateAtlas (" stages/tankmanBattlefield/tankman_stress" );
15+ tankmanGuy .anim .addBySymbol (" walk" , " tankman running" , 24 , true );
16+ tankmanGuy .anim .addBySymbol (" shot" , " John Shot " + FlxG .random .int (1 , 2 ), 24 , false );
17+ tankmanGuy .anim .play (" walk" , true );
18+ tankmanGuy .flipX = note .d < 2 ;
19+ tankmanGuy .visible = false ;
20+ FlxG .state .insert (11 , tankmanGuy );
21+
22+ randomGuys .push ([note .t , {
23+ " guy" : tankmanGuy ,
24+ " endOffset" : FlxG .random .float (50 , 200 ),
25+ " speed" : FlxG .random .float (0.6 , 1 )
26+ }]);
27+ }
28+ }
29+ }
30+
31+ function update (elapsed ) {
32+ for (meow in randomGuys ) {
33+ if (meow [1 ].guy .anim .curAnim .name == " walk" ) {
34+ if (meow [1 ].guy .x >= FlxG .width * 1.2 || meow [1 ].guy .x <= FlxG .width * - 0.5 )
35+ meow [1 ].guy .visible = false ;
36+ else
37+ meow [1 ].guy .visible = true ;
38+
39+ var endDirection : Float = (FlxG .width * 0.74 ) + meow [1 ].endOffset ;
40+
41+ if (meow [1 ].guy .flipX )
42+ {
43+ endDirection = (FlxG .width * 0.02 ) - meow [1 ].endOffset ;
44+
45+ meow [1 ].guy .x = (endDirection + (Conductor .songPosition - meow [0 ]) * meow [1 ].speed );
46+ }
47+ else
48+ {
49+ meow [1 ].guy .x = (endDirection - (Conductor .songPosition - meow [0 ]) * meow [1 ].speed );
50+ }
51+ } else {
52+ if (meow [1 ].guy .anim .curAnim .finished )
53+ meow [1 ].guy .kill ();
54+ }
55+ }
56+
57+ for (note in epicChart ) {
58+ if (Conductor .songPosition > note .t ) {
59+ epicChart .remove (note );
60+
61+ for (meow in randomGuys ) {
62+ if (meow [0 ] == note .t ) {
63+ meow [1 ].guy .anim .play (" shot" , true );
64+ if (meow [1 ].guy .flipX )
65+ {
66+ meow [1 ].guy .offset .y = 200 ;
67+ meow [1 ].guy .offset .x = 300 ;
68+ }
69+
70+ randomGuys .remove (moew );
71+ }
72+ }
73+
74+ playAnim (" shoot" + note .d , true );
75+ animation .finishCallback = (n ) -> {
76+ playAnim (animation .curAnim .name + " -loop" , true );
77+ animation .finishCallback = (n ) -> {};
78+ };
79+ }
80+ }
81+ }
0 commit comments