IT

Slave Rift

di tueb2024 · Sparatutto
5,0 (1)
▶ Gioca 💬 Opinioni Sorgenti 🕘 Versioni Modifica GitHub
games/slave-rift / src / Gfx / EnemyAtlas.php · commit 9ea6094
<?phpnamespace App\Gfx;/** Pixel-verified Nmn frames. Each rectangle contains exactly one animation image. */final class EnemyAtlas{    public const SHEETS = [        'runner' => [            'texture' => 'enemy_mutant_grunt',            'path' => 'assets/sprites/enemies/nmn-cc0/mutant-grunt.png',            'width' => 814,            'height' => 1227,            'scale' => 0.98,            'clips' => array (  'idle' =>   array (    0 => 0,  ),  'walk' =>   array (    0 => 0,    1 => 1,    2 => 2,    3 => 3,  ),  'attack' =>   array (    0 => 5,    1 => 6,    2 => 7,  ),  'pain' =>   array (    0 => 10,  ),),            'frames' => [                [[26,11,53,77],[130,13,56,76],[230,16,59,73],[329,16,58,73],[430,16,53,73],[522,16,60,72],[611,15,57,74],[698,14,60,78]],                [[30,106,57,77],[128,104,63,76],[231,101,48,75],[333,101,52,73],[426,105,55,74],[523,106,60,76],[617,105,47,76],[701,103,53,78]],                [[29,198,52,76],[133,198,62,77],[232,197,62,74],[343,197,51,73],[429,197,54,73],[522,196,58,73],[604,197,66,74],[699,199,50,75]],                [[32,290,54,77],[138,290,54,78],[250,292,39,77],[335,291,57,75],[428,292,54,75],[522,292,51,74],[609,292,45,74],[700,290,58,77]],                [[31,389,58,80],[130,388,69,79],[236,388,56,77],[337,387,56,76],[427,388,55,74],[518,388,63,75],[605,388,60,77],[698,387,55,79]],                [[35,493,54,77],[125,496,70,77],[231,490,64,76],[340,488,52,75],[432,489,55,74],[517,487,67,74],[603,486,67,75],[697,485,50,76]],                [[33,595,58,76],[139,595,59,77],[245,598,51,76],[336,598,58,75],[428,598,56,74],[519,597,57,75],[604,596,53,75],[701,595,55,74]],                [[27,693,68,79],[127,694,79,79],[237,692,55,77],[338,695,58,75],[425,695,62,74],[514,695,74,75],[608,694,54,75],[701,690,57,77]],                [[31,788,58,77],[143,789,53,76],[236,787,61,76],[341,788,62,72],[437,786,54,72],[524,785,52,74],[603,786,65,76],[701,788,68,75]],                [[38,882,56,74],[150,878,56,74],[251,880,60,73],[351,883,59,71],[438,883,56,69],[522,882,50,72],[594,884,62,74],[697,883,61,73]],                [[36,973,68,78],[145,972,70,78],[252,970,49,78],[336,970,60,77],[432,970,62,76],[512,969,68,76],[606,968,52,75],[706,971,59,76]],                [[40,1080,67,72],[143,1090,62,61],[227,1091,67,63],[320,1096,65,57],[399,1098,66,49],[485,1121,74,24],[571,1122,74,26]],            ],            'death' => 11,        ],        'guardian' => [            'texture' => 'enemy_ratman',            'path' => 'assets/sprites/enemies/nmn-cc0/ratman.png',            'width' => 592,            'height' => 658,            'scale' => 0.98,            'clips' => array (  'idle' =>   array (    0 => 0,  ),  'walk' =>   array (    0 => 0,    1 => 1,    2 => 2,    3 => 3,  ),  'attack' =>   array (    0 => 4,    1 => 5,  ),  'pain' =>   array (    0 => 6,  ),),            'frames' => [                [[16,20,40,61],[89,20,40,61],[171,17,46,62],[247,15,49,62],[322,17,42,62],[391,19,40,61],[451,17,46,62],[515,20,48,61]],                [[19,89,40,63],[94,87,41,63],[176,88,47,63],[250,88,46,64],[324,91,40,63],[388,93,39,63],[449,91,46,63],[515,94,46,63]],                [[20,161,39,63],[97,161,46,61],[180,158,53,62],[253,157,46,63],[324,161,40,63],[380,162,45,61],[443,161,52,63],[511,165,47,61]],                [[23,233,39,63],[104,232,41,63],[182,233,49,64],[251,232,50,64],[323,235,40,64],[382,235,39,63],[441,235,48,63],[510,236,51,63]],                [[22,305,38,65],[97,306,49,64],[180,307,52,64],[266,309,39,65],[331,311,37,64],[380,312,48,64],[440,311,52,64],[508,312,39,65]],                [[23,381,37,64],[97,381,51,63],[176,384,60,63],[267,386,41,64],[330,389,37,62],[378,387,51,63],[439,387,59,63],[509,386,42,63]],                [[22,460,41,64],[107,462,41,63],[190,460,47,62],[265,461,45,63],[329,462,41,63],[381,462,40,63],[433,464,50,63],[506,461,46,63]],                [[22,548,45,66],[85,551,51,67],[151,553,48,66],[212,556,51,62],[279,562,59,54],[347,590,56,26]],            ],            'death' => 7,        ],        'brute' => [            'texture' => 'enemy_mutant_leader',            'path' => 'assets/sprites/enemies/nmn-cc0/mutant-leader.png',            'width' => 889,            'height' => 1493,            'scale' => 1.42,            'clips' => array (  'idle' =>   array (    0 => 0,  ),  'walk' =>   array (    0 => 0,    1 => 1,    2 => 2,    3 => 3,  ),  'attack' =>   array (    0 => 5,    1 => 6,    2 => 7,  ),  'pain' =>   array (    0 => 10,  ),),            'frames' => [                [[43,30,58,88],[140,27,65,87],[244,29,45,85],[334,27,48,83],[447,27,57,84],[561,27,64,85],[658,26,48,87],[748,27,50,88]],                [[44,148,57,86],[135,147,67,86],[238,145,64,85],[338,148,49,83],[447,146,57,84],[560,144,63,84],[650,142,68,85],[750,140,47,85]],                [[49,266,55,87],[144,267,61,87],[255,266,43,87],[338,266,54,85],[453,265,56,85],[563,264,59,84],[656,262,46,84],[739,261,55,86]],                [[45,384,64,85],[159,389,63,84],[263,388,55,83],[345,387,54,83],[452,385,61,83],[554,382,67,83],[644,381,56,85],[739,382,54,85]],                [[51,504,57,87],[147,506,69,85],[256,505,56,86],[349,503,43,84],[453,501,56,83],[556,503,64,84],[658,504,59,87],[743,503,46,87]],                [[54,621,60,85],[147,623,76,83],[246,620,66,84],[352,621,46,84],[453,619,58,83],[554,621,72,83],[649,620,72,85],[738,619,51,86]],                [[52,728,61,86],[148,730,73,83],[257,728,62,84],[356,727,45,83],[451,725,60,83],[552,726,70,84],[649,732,63,86],[739,731,46,86]],                [[45,839,70,86],[148,835,80,85],[261,833,56,85],[353,831,56,86],[445,831,68,85],[551,832,78,84],[647,834,56,86],[730,836,57,87]],                [[50,946,63,87],[159,947,61,84],[253,949,65,84],[347,949,70,84],[455,949,60,83],[559,947,63,83],[647,947,60,87],[728,947,76,88]],                [[54,1062,62,84],[168,1061,58,83],[265,1059,57,84],[362,1057,59,82],[453,1059,59,82],[549,1058,59,82],[641,1055,57,85],[722,1060,61,84]],                [[56,1185,63,85],[154,1186,77,83],[266,1187,56,85],[373,1184,45,86],[446,1186,60,85],[541,1182,76,83],[643,1179,59,86],[730,1176,48,86]],                [[58,1306,66,81],[158,1308,68,78],[251,1316,95,71],[363,1332,97,54],[484,1345,93,32],[600,1346,90,31]],            ],            'death' => 11,        ],        'enforcer' => [            'texture' => 'enemy_enforcer_guard',            'path' => 'assets/sprites/enemies/nmn-cc0/enforcer-guard.png',            'width' => 516,            'height' => 836,            'scale' => 1.08,            'clips' => array (  'idle' =>   array (    0 => 0,  ),  'walk' =>   array (    0 => 8,    1 => 9,    2 => 10,  ),  'attack' =>   array (    0 => 1,    1 => 2,    2 => 3,    3 => 4,    4 => 5,    5 => 6,  ),  'pain' =>   array (    0 => 0,  ),),            'frames' => [                [[25,14,35,63],[77,15,42,63],[129,15,56,62],[202,13,47,62],[269,14,35,63],[322,13,41,62],[372,13,55,62],[433,15,48,62]],                [[26,86,36,63],[79,86,37,63],[134,87,44,62],[205,87,39,62],[268,87,36,62],[326,89,35,62],[378,88,46,62],[434,89,43,62]],                [[28,162,36,64],[82,161,47,63],[137,162,56,62],[208,162,39,63],[266,163,36,64],[317,164,45,62],[371,165,55,63],[437,166,43,64]],                [[31,239,36,62],[89,238,39,62],[144,238,46,62],[212,237,40,62],[267,237,36,62],[322,238,36,62],[376,238,45,62],[434,237,43,62]],                [[32,315,34,64],[87,315,39,64],[149,317,46,63],[216,317,39,62],[268,319,34,63],[320,320,36,62],[368,317,47,62],[427,318,40,62]],                [[33,391,35,64],[87,392,41,64],[144,392,51,63],[217,393,39,62],[270,394,35,63],[318,394,38,62],[368,393,53,62],[428,393,43,62]],                [[36,463,35,62],[95,464,35,61],[151,463,44,60],[215,462,40,61],[268,463,35,61],[315,462,31,62],[369,462,44,61],[427,462,44,61]],                [[18,540,49,62],[82,541,47,59],[141,540,35,58],[199,547,44,51],[254,556,50,44],[330,572,56,25]],                [[32,610,40,59],[93,610,33,58],[142,610,50,58],[200,610,52,59],[269,612,39,59],[331,613,34,61],[377,613,49,61],[429,613,55,60]],                [[31,682,41,59],[95,683,42,61],[142,682,51,61],[200,682,42,61],[268,684,40,59],[321,685,44,60],[380,685,46,59],[439,685,45,58]],                [[30,756,42,51],[97,754,38,50],[149,753,45,50],[209,751,41,51],[272,753,41,49],[325,753,39,50],[372,754,43,50],[429,754,43,51]],            ],            'death' => 7,        ],    ];    public static function frame(string $type, string $state, int $tick, int $direction): ?array    {        $sheet = self::SHEETS[$type] ?? self::SHEETS['guardian'];        if ($state === 'death') {            $frames = $sheet['frames'][$sheet['death']];            return $frames[min(count($frames)-1, max(0, $tick))] ?? null;        }        $clip = $sheet['clips'][$state] ?? $sheet['clips']['walk'];        $row = $clip[$tick % count($clip)];        return $sheet['frames'][$row][$direction % 8] ?? null;    }    public static function valid(array $sheet, array $rect): bool    {        return $rect[0] >= 0 && $rect[1] >= 0 && $rect[2] > 0 && $rect[3] > 0            && $rect[0] + $rect[2] <= $sheet['width']            && $rect[1] + $rect[3] <= $sheet['height'];    }}