Skip to content

Commit

Permalink
Add more enemy types.
Browse files Browse the repository at this point in the history
Merge pull request #2 from haroldo-ok/more-enemies
  • Loading branch information
haroldo-ok authored Nov 28, 2021
2 parents b8bd8bd + fa9848b commit 4bf983b
Show file tree
Hide file tree
Showing 8 changed files with 2,689 additions and 10 deletions.
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ OBJS := data.rel actor.rel shot.rel shots.rel map.rel score.rel astro_hunter.rel
all: $(PRJNAME).sms

data.c: data/* data/sprites_tiles.psgcompr data/tileset_tiles.psgcompr \
data/path1.path data/level1.bin
data/path1.path data/path2.path data/path3.path data/path4.path data/level1.bin
folder2c data data

data/sprites_tiles.psgcompr: data/img/sprites.png
BMP2Tile.exe data/img/sprites.png -noremovedupes -8x16 -palsms -fullpalette -savetiles data/sprites_tiles.psgcompr -savepalette data/sprites_palette.bin

data/tileset_tiles.psgcompr: data/img/tileset.png
BMP2Tile.exe data/img/tileset.png -noremovedupes -8x16 -palsms -fullpalette -savetiles data/tileset_tiles.psgcompr -savepalette data/tileset_palette.bin

data/path1.path: data/path/path1.spline.json
node tool/convert_splines.js data/path/path1.spline.json data/path1.path

data/level1.bin: data/map/level1.tmx
node tool/convert_map.js data/map/level1.tmx data/level1.bin

data/%.path: data/path/%.spline.json
node tool/convert_splines.js $< $@

data/%.bin: data/map/%.tmx
node tool/convert_map.js $< $@

%.vgm: %.wav
psgtalk -r 512 -u 1 -m vgm $<

Expand Down
30 changes: 27 additions & 3 deletions astro_hunter.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#define ENEMY_MAX (3)
#define FOR_EACH_ENEMY(enm) enm = enemies; for (int i = ENEMY_MAX; i; i--, enm++)
#define ENEMY_TYPE_COUNT (3)
#define ENEMY_PATH_COUNT (4)

#define POWERUP_BASE_TILE (100)
#define POWERUP_LIGHTINING_TILE (POWERUP_BASE_TILE)
Expand All @@ -32,6 +34,10 @@ actor enemies[ENEMY_MAX];
actor icons[2];
actor powerup;

typedef struct enemy_type {
char base_tile, frame_count;
} enemy_type;

struct ply_ctl {
char shot_delay;
char shot_type;
Expand All @@ -49,10 +55,24 @@ struct enemy_spawner {
char flags;
char delay;
char next;
enemy_type *enm_type;
path_step *path;
char all_dead;
} enemy_spawner;

const enemy_type enemy_types[ENEMY_TYPE_COUNT] = {
{66, 5},
{130, 6},
{154, 6}
};

path_step *enemy_paths[ENEMY_PATH_COUNT] = {
(path_step *) path1_path,
(path_step *) path2_path,
(path_step *) path3_path,
(path_step *) path4_path
};

void load_standard_palettes() {
SMS_loadBGPalette(tileset_palette_bin);
SMS_loadSpritePalette(sprites_palette_bin);
Expand Down Expand Up @@ -187,7 +207,8 @@ void handle_enemies() {
enemy_spawner.type = rand() & 1;
enemy_spawner.x = 8 + rand() % 124;
enemy_spawner.flags = 0;
enemy_spawner.path = (path_step *) path1_path;
enemy_spawner.enm_type = enemy_types + rand() % ENEMY_TYPE_COUNT;
enemy_spawner.path = enemy_paths[rand() % ENEMY_PATH_COUNT];
if (rand() & 1) {
enemy_spawner.x += 124;
enemy_spawner.flags |= PATH_FLIP_X;
Expand All @@ -196,7 +217,10 @@ void handle_enemies() {

enm = enemies + enemy_spawner.next;

init_actor(enm, enemy_spawner.x, 0, 2, 1, 66, 5);
init_actor(enm, enemy_spawner.x, 0, 2, 1,
enemy_spawner.enm_type->base_tile,
enemy_spawner.enm_type->frame_count);

enm->path_flags = enemy_spawner.flags;
enm->path = enemy_spawner.path;
enm->state = enemy_spawner.type;
Expand Down Expand Up @@ -371,7 +395,7 @@ void main() {
}

SMS_EMBED_SEGA_ROM_HEADER(9999,0); // code 9999 hopefully free, here this means 'homebrew'
SMS_EMBED_SDSC_HEADER(0,1, 2021,11,27, "Haroldo-OK\\2021", "Astro Hunter",
SMS_EMBED_SDSC_HEADER(0,2, 2021,11,28, "Haroldo-OK\\2021", "Astro Hunter",
"A space shoot-em-up.\n"
"Originally made for the Lost Cartridge Jam 2021 - https://itch.io/jam/lostcartridgejam3\n"
"Built using devkitSMS & SMSlib - https://github.com/sverx/devkitSMS");
Loading

0 comments on commit 4bf983b

Please sign in to comment.