From 63bb84a8fdd8c9822773e4933c3a6504d2ed0a09 Mon Sep 17 00:00:00 2001 From: Haroldo de Oliveira Pinheiro Date: Wed, 10 Nov 2021 21:01:20 -0300 Subject: [PATCH] Allow enemies to follow different paths. --- Makefile | 5 +- binary_gunner.c | 9 +- data/path/path2.spline.json | 885 ++++++++++++++++++++++++++++++++++++ data/path2.path | Bin 0 -> 424 bytes 4 files changed, 897 insertions(+), 2 deletions(-) create mode 100644 data/path/path2.spline.json create mode 100644 data/path2.path diff --git a/Makefile b/Makefile index 20ef1ce..96ffbc0 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ OBJS := data.rel actor.rel map.rel shot.rel binary_gunner.rel all: $(PRJNAME).sms -data.c: data/* data/sprites_tiles.psgcompr data/path1.path +data.c: data/* data/sprites_tiles.psgcompr data/path1.path data/path2.path folder2c data data data/sprites_tiles.psgcompr: data/img/sprites.png @@ -11,6 +11,9 @@ data/sprites_tiles.psgcompr: data/img/sprites.png data/path1.path: data/path/path1.spline.json node tool/convert_splines.js data/path/path1.spline.json data/path1.path + +data/path2.path: data/path/path2.spline.json + node tool/convert_splines.js data/path/path2.spline.json data/path2.path %.vgm: %.wav psgtalk -r 512 -u 1 -m vgm $< diff --git a/binary_gunner.c b/binary_gunner.c index 675fd2b..25d0c76 100644 --- a/binary_gunner.c +++ b/binary_gunner.c @@ -20,6 +20,7 @@ #define ENEMY_MAX (3) #define FOR_EACH_ENEMY(enm) enm = enemies; for (char enemy_index = ENEMY_MAX; enemy_index; enemy_index--, enm++) +#define ENEMY_PATH_MAX (2) actor player; actor player_shots[PLAYER_SHOT_MAX]; @@ -36,9 +37,14 @@ struct enemy_spawner { char flags; char delay; char next; + path_step *path; char all_dead; } enemy_spawner; +const path_step *enemy_paths[ENEMY_PATH_MAX] = { + (path_step *) path1_path, (path_step *) path2_path +}; + void load_standard_palettes() { SMS_loadBGPalette(sprites_palette_bin); SMS_loadSpritePalette(sprites_palette_bin); @@ -196,6 +202,7 @@ void handle_enemies() { enemy_spawner.type = rand() & 1; enemy_spawner.x = 8 + rand() % 124; enemy_spawner.flags = 0; + enemy_spawner.path = enemy_paths[rand() % ENEMY_PATH_MAX]; if (rand() & 1) { enemy_spawner.x += 124; enemy_spawner.flags |= PATH_FLIP_X; @@ -206,7 +213,7 @@ void handle_enemies() { init_actor(enm, enemy_spawner.x, 0, 2, 1, enemy_spawner.type ? 132 : 128, 1); enm->path_flags = enemy_spawner.flags; - enm->path = (path_step *) path1_path; + enm->path = enemy_spawner.path; enemy_spawner.delay = 10; enemy_spawner.next++; diff --git a/data/path/path2.spline.json b/data/path/path2.spline.json new file mode 100644 index 0000000..2918b1f --- /dev/null +++ b/data/path/path2.spline.json @@ -0,0 +1,885 @@ +{ + "application": "Cardinal spline editor", + "version": 0.1, + "isClosed": false, + "isFilled": true, + "arePointsVisible": true, + "numberOfSegments": 35, + "tension": 0.5, + "originalPoints": [ + { + "x": 56, + "y": 1 + }, + { + "x": 69, + "y": 318 + }, + { + "x": 125, + "y": 227 + }, + { + "x": 151, + "y": 90 + }, + { + "x": 214, + "y": 28 + }, + { + "x": 242, + "y": 202 + }, + { + "x": 220, + "y": 378 + } + ], + "calculatedPoints": [ + { + "x": 56, + "y": 1 + }, + { + "x": 56.17912673950195, + "y": 5.945422649383545 + }, + { + "x": 56.346473693847656, + "y": 11.690729141235352 + }, + { + "x": 56.5041389465332, + "y": 18.185190200805664 + }, + { + "x": 56.65422821044922, + "y": 25.378074645996094 + }, + { + "x": 56.79883575439453, + "y": 33.218658447265625 + }, + { + "x": 56.940059661865234, + "y": 41.656211853027344 + }, + { + "x": 57.08000183105469, + "y": 50.6400032043457 + }, + { + "x": 57.220760345458984, + "y": 60.119300842285156 + }, + { + "x": 57.36442947387695, + "y": 70.04338073730469 + }, + { + "x": 57.513118743896484, + "y": 80.36151123046875 + }, + { + "x": 57.668922424316406, + "y": 91.0229721069336 + }, + { + "x": 57.83393859863281, + "y": 101.9770278930664 + }, + { + "x": 58.0102653503418, + "y": 113.17294311523438 + }, + { + "x": 58.20000076293945, + "y": 124.55999755859375 + }, + { + "x": 58.405250549316406, + "y": 136.08746337890625 + }, + { + "x": 58.62810516357422, + "y": 147.70460510253906 + }, + { + "x": 58.870670318603516, + "y": 159.36070251464844 + }, + { + "x": 59.13504409790039, + "y": 171.00502014160156 + }, + { + "x": 59.42332458496094, + "y": 182.58682250976562 + }, + { + "x": 59.73760986328125, + "y": 194.05540466308594 + }, + { + "x": 60.08000183105469, + "y": 205.36000061035156 + }, + { + "x": 60.45259475708008, + "y": 216.44992065429688 + }, + { + "x": 60.85749435424805, + "y": 227.2744140625 + }, + { + "x": 61.29679489135742, + "y": 237.78274536132812 + }, + { + "x": 61.7725944519043, + "y": 247.92420959472656 + }, + { + "x": 62.28699493408203, + "y": 257.6480407714844 + }, + { + "x": 62.842098236083984, + "y": 266.903564453125 + }, + { + "x": 63.44000244140625, + "y": 275.6400146484375 + }, + { + "x": 64.08280181884766, + "y": 283.806640625 + }, + { + "x": 64.77259826660156, + "y": 291.352783203125 + }, + { + "x": 65.51148986816406, + "y": 298.2276306152344 + }, + { + "x": 66.30157470703125, + "y": 304.3805236816406 + }, + { + "x": 67.14495849609375, + "y": 309.7607116699219 + }, + { + "x": 68.04373168945312, + "y": 314.31744384765625 + }, + { + "x": 69, + "y": 318 + }, + { + "x": 70.03221130371094, + "y": 320.91851806640625 + }, + { + "x": 71.15400695800781, + "y": 323.2337646484375 + }, + { + "x": 72.36028289794922, + "y": 324.97113037109375 + }, + { + "x": 73.64591979980469, + "y": 326.1558837890625 + }, + { + "x": 75.00582885742188, + "y": 326.81341552734375 + }, + { + "x": 76.43489074707031, + "y": 326.968994140625 + }, + { + "x": 77.9280014038086, + "y": 326.64801025390625 + }, + { + "x": 79.48004913330078, + "y": 325.875732421875 + }, + { + "x": 81.08592224121094, + "y": 324.6775207519531 + }, + { + "x": 82.74052429199219, + "y": 323.0787353515625 + }, + { + "x": 84.4387435913086, + "y": 321.1046447753906 + }, + { + "x": 86.17546844482422, + "y": 318.7806091308594 + }, + { + "x": 87.94558715820312, + "y": 316.1319580078125 + }, + { + "x": 89.74400329589844, + "y": 313.1839904785156 + }, + { + "x": 91.56559753417969, + "y": 309.96209716796875 + }, + { + "x": 93.4052734375, + "y": 306.4915771484375 + }, + { + "x": 95.2579116821289, + "y": 302.7977294921875 + }, + { + "x": 97.11841583251953, + "y": 298.90594482421875 + }, + { + "x": 98.9816665649414, + "y": 294.84149169921875 + }, + { + "x": 100.84256744384766, + "y": 290.6297302246094 + }, + { + "x": 102.69599914550781, + "y": 286.2959899902344 + }, + { + "x": 104.536865234375, + "y": 281.8656311035156 + }, + { + "x": 106.36004638671875, + "y": 277.3638916015625 + }, + { + "x": 108.16044616699219, + "y": 272.8161926269531 + }, + { + "x": 109.93294525146484, + "y": 268.247802734375 + }, + { + "x": 111.67243957519531, + "y": 263.6841125488281 + }, + { + "x": 113.37383270263672, + "y": 259.150390625 + }, + { + "x": 115.0320053100586, + "y": 254.67201232910156 + }, + { + "x": 116.641845703125, + "y": 250.27426147460938 + }, + { + "x": 118.19824981689453, + "y": 245.98251342773438 + }, + { + "x": 119.69611358642578, + "y": 241.8220672607422 + }, + { + "x": 121.13033294677734, + "y": 237.81826782226562 + }, + { + "x": 122.49579620361328, + "y": 233.99642944335938 + }, + { + "x": 123.78738403320312, + "y": 230.3819122314453 + }, + { + "x": 125, + "y": 227 + }, + { + "x": 126.13262176513672, + "y": 223.67611694335938 + }, + { + "x": 127.19074249267578, + "y": 220.22434997558594 + }, + { + "x": 128.17906188964844, + "y": 216.6531982421875 + }, + { + "x": 129.1022491455078, + "y": 212.97113037109375 + }, + { + "x": 129.9650115966797, + "y": 209.18658447265625 + }, + { + "x": 130.77203369140625, + "y": 205.3080596923828 + }, + { + "x": 131.5279998779297, + "y": 201.34400939941406 + }, + { + "x": 132.2375946044922, + "y": 197.30288696289062 + }, + { + "x": 132.905517578125, + "y": 193.1931610107422 + }, + { + "x": 133.53643798828125, + "y": 189.02333068847656 + }, + { + "x": 134.13507080078125, + "y": 184.80181884765625 + }, + { + "x": 134.70608520507812, + "y": 180.53712463378906 + }, + { + "x": 135.25416564941406, + "y": 176.23770141601562 + }, + { + "x": 135.78399658203125, + "y": 171.91200256347656 + }, + { + "x": 136.30029296875, + "y": 167.56851196289062 + }, + { + "x": 136.80772399902344, + "y": 163.2156982421875 + }, + { + "x": 137.31097412109375, + "y": 158.8620147705078 + }, + { + "x": 137.8147430419922, + "y": 154.5159454345703 + }, + { + "x": 138.32371520996094, + "y": 150.18592834472656 + }, + { + "x": 138.8425750732422, + "y": 145.88046264648438 + }, + { + "x": 139.37600708007812, + "y": 141.60800170898438 + }, + { + "x": 139.9287109375, + "y": 137.3769989013672 + }, + { + "x": 140.50535583496094, + "y": 133.19593811035156 + }, + { + "x": 141.11065673828125, + "y": 129.0732879638672 + }, + { + "x": 141.749267578125, + "y": 125.01749420166016 + }, + { + "x": 142.4259033203125, + "y": 121.03703308105469 + }, + { + "x": 143.145263671875, + "y": 117.14038848876953 + }, + { + "x": 143.91200256347656, + "y": 113.33600616455078 + }, + { + "x": 144.73081970214844, + "y": 109.63235473632812 + }, + { + "x": 145.60641479492188, + "y": 106.03790283203125 + }, + { + "x": 146.54345703125, + "y": 102.56111907958984 + }, + { + "x": 147.54666137695312, + "y": 99.2104721069336 + }, + { + "x": 148.62069702148438, + "y": 95.99443054199219 + }, + { + "x": 149.77024841308594, + "y": 92.92144775390625 + }, + { + "x": 151, + "y": 90 + }, + { + "x": 152.31507873535156, + "y": 87.1239242553711 + }, + { + "x": 153.71409606933594, + "y": 84.18889617919922 + }, + { + "x": 155.1920166015625, + "y": 81.20620727539062 + }, + { + "x": 156.74380493164062, + "y": 78.18710327148438 + }, + { + "x": 158.36444091796875, + "y": 75.14286041259766 + }, + { + "x": 160.04884338378906, + "y": 72.08473205566406 + }, + { + "x": 161.79200744628906, + "y": 69.02400207519531 + }, + { + "x": 163.58888244628906, + "y": 65.97191619873047 + }, + { + "x": 165.43441772460938, + "y": 62.939754486083984 + }, + { + "x": 167.32362365722656, + "y": 59.938777923583984 + }, + { + "x": 169.25140380859375, + "y": 56.980247497558594 + }, + { + "x": 171.2127685546875, + "y": 54.07543182373047 + }, + { + "x": 173.20263671875, + "y": 51.235591888427734 + }, + { + "x": 175.21600341796875, + "y": 48.47200012207031 + }, + { + "x": 177.24781799316406, + "y": 45.795921325683594 + }, + { + "x": 179.2930450439453, + "y": 43.21861267089844 + }, + { + "x": 181.3466339111328, + "y": 40.751346588134766 + }, + { + "x": 183.403564453125, + "y": 38.40538787841797 + }, + { + "x": 185.45880126953125, + "y": 36.19200134277344 + }, + { + "x": 187.50729370117188, + "y": 34.12245178222656 + }, + { + "x": 189.54400634765625, + "y": 32.20800018310547 + }, + { + "x": 191.56390380859375, + "y": 30.459918975830078 + }, + { + "x": 193.5619354248047, + "y": 28.88947105407715 + }, + { + "x": 195.53309631347656, + "y": 27.507919311523438 + }, + { + "x": 197.47230529785156, + "y": 26.32653045654297 + }, + { + "x": 199.3745574951172, + "y": 25.356571197509766 + }, + { + "x": 201.23480224609375, + "y": 24.60930633544922 + }, + { + "x": 203.04800415039062, + "y": 24.09600067138672 + }, + { + "x": 204.8091278076172, + "y": 23.827919006347656 + }, + { + "x": 206.51312255859375, + "y": 23.816326141357422 + }, + { + "x": 208.15496826171875, + "y": 24.072490692138672 + }, + { + "x": 209.7296142578125, + "y": 24.60767364501953 + }, + { + "x": 211.23202514648438, + "y": 25.433143615722656 + }, + { + "x": 212.65716552734375, + "y": 26.560163497924805 + }, + { + "x": 214, + "y": 28 + }, + { + "x": 215.2916717529297, + "y": 29.789108276367188 + }, + { + "x": 216.56594848632812, + "y": 31.94551658630371 + }, + { + "x": 217.82180786132812, + "y": 34.452850341796875 + }, + { + "x": 219.05819702148438, + "y": 37.29473876953125 + }, + { + "x": 220.2740478515625, + "y": 40.454811096191406 + }, + { + "x": 221.4683380126953, + "y": 43.91668701171875 + }, + { + "x": 222.63999938964844, + "y": 47.66400146484375 + }, + { + "x": 223.78799438476562, + "y": 51.68037414550781 + }, + { + "x": 224.9112548828125, + "y": 55.94943618774414 + }, + { + "x": 226.0087432861328, + "y": 60.454811096191406 + }, + { + "x": 227.0794219970703, + "y": 65.18013000488281 + }, + { + "x": 228.12222290039062, + "y": 70.10901641845703 + }, + { + "x": 229.13609313964844, + "y": 75.22509765625 + }, + { + "x": 230.1199951171875, + "y": 80.51200103759766 + }, + { + "x": 231.07289123535156, + "y": 85.95335388183594 + }, + { + "x": 231.9936981201172, + "y": 91.53278350830078 + }, + { + "x": 232.8813934326172, + "y": 97.2339096069336 + }, + { + "x": 233.73492431640625, + "y": 103.04037475585938 + }, + { + "x": 234.55323791503906, + "y": 108.935791015625 + }, + { + "x": 235.3352813720703, + "y": 114.90379333496094 + }, + { + "x": 236.0800018310547, + "y": 120.9280014038086 + }, + { + "x": 236.78636169433594, + "y": 126.99205017089844 + }, + { + "x": 237.45330810546875, + "y": 133.07955932617188 + }, + { + "x": 238.07977294921875, + "y": 139.17416381835938 + }, + { + "x": 238.66473388671875, + "y": 145.2594757080078 + }, + { + "x": 239.2071075439453, + "y": 151.3191375732422 + }, + { + "x": 239.7058868408203, + "y": 157.33677673339844 + }, + { + "x": 240.16000366210938, + "y": 163.29600524902344 + }, + { + "x": 240.5684051513672, + "y": 169.18045043945312 + }, + { + "x": 240.93003845214844, + "y": 174.97377014160156 + }, + { + "x": 241.2438507080078, + "y": 180.6595458984375 + }, + { + "x": 241.50880432128906, + "y": 186.221435546875 + }, + { + "x": 241.72384643554688, + "y": 191.64306640625 + }, + { + "x": 241.887939453125, + "y": 196.9080352783203 + }, + { + "x": 242, + "y": 202 + }, + { + "x": 242.03675842285156, + "y": 207.07139587402344 + }, + { + "x": 241.97897338867188, + "y": 212.27728271484375 + }, + { + "x": 241.83164978027344, + "y": 217.6051788330078 + }, + { + "x": 241.599853515625, + "y": 223.04266357421875 + }, + { + "x": 241.28863525390625, + "y": 228.57725524902344 + }, + { + "x": 240.9029998779297, + "y": 234.196533203125 + }, + { + "x": 240.44801330566406, + "y": 239.88800048828125 + }, + { + "x": 239.92868041992188, + "y": 245.6392364501953 + }, + { + "x": 239.35006713867188, + "y": 251.43775939941406 + }, + { + "x": 238.7172088623047, + "y": 257.2711486816406 + }, + { + "x": 238.03512573242188, + "y": 263.1269226074219 + }, + { + "x": 237.3088836669922, + "y": 268.99261474609375 + }, + { + "x": 236.54348754882812, + "y": 274.8558044433594 + }, + { + "x": 235.74400329589844, + "y": 280.7040100097656 + }, + { + "x": 234.91546630859375, + "y": 286.5247802734375 + }, + { + "x": 234.06288146972656, + "y": 292.3056640625 + }, + { + "x": 233.1913299560547, + "y": 298.03424072265625 + }, + { + "x": 232.30581665039062, + "y": 303.697998046875 + }, + { + "x": 231.41140747070312, + "y": 309.2845153808594 + }, + { + "x": 230.51312255859375, + "y": 314.7813415527344 + }, + { + "x": 229.61599731445312, + "y": 320.1759948730469 + }, + { + "x": 228.72509765625, + "y": 325.4560546875 + }, + { + "x": 227.8454132080078, + "y": 330.6090393066406 + }, + { + "x": 226.98202514648438, + "y": 335.62249755859375 + }, + { + "x": 226.1399383544922, + "y": 340.4839782714844 + }, + { + "x": 225.32421875, + "y": 345.1809997558594 + }, + { + "x": 224.53990173339844, + "y": 349.701171875 + }, + { + "x": 223.79200744628906, + "y": 354.0320129394531 + }, + { + "x": 223.0855712890625, + "y": 358.1610412597656 + }, + { + "x": 222.4256591796875, + "y": 362.0758056640625 + }, + { + "x": 221.81727600097656, + "y": 365.76385498046875 + }, + { + "x": 221.26548767089844, + "y": 369.2127685546875 + }, + { + "x": 220.77532958984375, + "y": 372.41009521484375 + }, + { + "x": 220.35182189941406, + "y": 375.34332275390625 + }, + { + "x": 220, + "y": 378 + } + ] +} \ No newline at end of file diff --git a/data/path2.path b/data/path2.path new file mode 100644 index 0000000000000000000000000000000000000000..79e1c0b196176ad1c1b28ca6acde0914925c58cf GIT binary patch literal 424 zcmcJL+X?_72t-G#{qDZJGIEG6FT1cFaG=sj0VskIodojWgm=kb_sU=$R2Yy!l}V8o fpnSz$=(~FI^sf9hmD6<9jWP3I*><^M3(dI!jN(}z literal 0 HcmV?d00001