Skip to content

Commit

Permalink
Enemy variety and background.
Browse files Browse the repository at this point in the history
Merge pull request #4 from haroldo-ok/enemy-variety
  • Loading branch information
haroldo-ok authored Dec 10, 2021
2 parents 15fc253 + 7ef52e4 commit 79e2785
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 11 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ OBJS := data.rel actor.rel chicken_crossing.rel

all: $(PRJNAME).sms

data.c: data/* data/sprites_tiles.psgcompr
data.c: data/* data/sprites_tiles.psgcompr data/background_tiles.psgcompr
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/background_tiles.psgcompr: data/img/background.png
BMP2Tile.exe data/img/background.png -palsms -fullpalette -savetiles data/background_tiles.psgcompr -savetilemap data/background_tilemap.bin -savepalette data/background_palette.bin

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

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ An 8-bit game for the Sega Master System where up to four players can play again
* Chicken sprites: https://opengameart.org/content/solarus-chicken
* Car sprites: https://opengameart.org/content/isometric-vehicles
* Bike sprites: https://opengameart.org/content/2d-bike-sprite-2

* Background: https://opengameart.org/content/street-tiles-cartoonish
41 changes: 32 additions & 9 deletions chicken_crossing.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,8 @@ void interrupt_handler() {
}

void load_standard_palettes() {
SMS_loadBGPalette(sprites_palette_bin);
SMS_loadBGPalette(background_palette_bin);
SMS_loadSpritePalette(sprites_palette_bin);
SMS_setBGPaletteColor(0, 0x2A);
SMS_setSpritePaletteColor(0, 0);
}

Expand Down Expand Up @@ -218,10 +217,9 @@ void handle_spawners() {
for (i = 0, y = PLAYER_TOP + 10; i != MAX_SPAWNERS; i++, act += 2, y += 24) {
act2 = act + 1;
if (!act->active && !act2->active) {
if (rand() & 3 > 1) {
// Always spawn from the left
facing_left = 0;
thing_to_spawn = (rand() >> 4) & 1;
if (!(rand() & 0x1F)) {
facing_left = (rand() >> 4) & 1;
thing_to_spawn = (rand() >> 4) % 4;
boost = (rand() >> 4) % level.boost_chance ? 0 : 1;

switch (thing_to_spawn) {
Expand All @@ -242,6 +240,20 @@ void handle_spawners() {
act2->spd_x = act->spd_x;
act2->group = act->group;
break;

case 2:
// Spawn a sports car
init_actor(act, 0, y, 3, 1, 78, 1);
act->spd_x = level.submarine_speed + boost;
act->group = GROUP_RED_CAR;
break;

case 3:
// Spawn a pickup truck
init_actor(act, 0, y, 3, 1, 90, 1);
act->spd_x = level.submarine_speed + boost;
act->group = GROUP_RED_CAR;
break;
}

adjust_facing(act, facing_left);
Expand All @@ -252,6 +264,16 @@ void handle_spawners() {
}

void draw_background() {
unsigned int *ch = background_tilemap_bin;

SMS_setNextTileatXY(0, 0);
for (char y = 0; y != 24; y++) {
for (char x = 0; x != 32; x++) {
unsigned int tile_number = *ch + 256;
SMS_setTile(tile_number);
ch++;
}
}
}

char is_touching(actor *act1, actor *act2) {
Expand Down Expand Up @@ -392,7 +414,7 @@ void initialize_level() {

clear_actors();

level.fish_speed = 1 + level.number / 3;
level.fish_speed = 2 + level.number / 3;
level.submarine_speed = 1 + level.number / 5;
level.diver_speed = 1 + level.number / 6;

Expand All @@ -403,7 +425,7 @@ void initialize_level() {
level.enemy_can_fire = 1;
level.show_diver_indicator = level.number < 2;

level.boost_chance = 14 - level.number * 2 / 3;
level.boost_chance = 8 - level.number * 2 / 3;
if (level.boost_chance < 2) level.boost_chance = 2;
}

Expand Down Expand Up @@ -450,6 +472,7 @@ char gameplay_loop() {
SMS_disableLineInterrupt();

SMS_loadPSGaidencompressedTiles(sprites_tiles_psgcompr, 0);
SMS_loadPSGaidencompressedTiles(background_tiles_psgcompr, 256);

draw_background();

Expand Down Expand Up @@ -572,6 +595,6 @@ void main() {
}

SMS_EMBED_SEGA_ROM_HEADER(9999,0); // code 9999 hopefully free, here this means 'homebrew'
SMS_EMBED_SDSC_HEADER(0,1, 2021,12,8, "Haroldo-OK\\2021", "Chicken Crossing",
SMS_EMBED_SDSC_HEADER(0,2, 2021,12,10, "Haroldo-OK\\2021", "Chicken Crossing",
"Made for The Honest Jam III - https://itch.io/jam/honest-jam-3.\n"
"Built using devkitSMS & SMSlib - https://github.com/sverx/devkitSMS");
Binary file added data/background_palette.bin
Binary file not shown.
Binary file added data/background_tilemap.bin
Binary file not shown.
Binary file added data/background_tiles.psgcompr
Binary file not shown.
Binary file added data/img/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/img/background.xcf
Binary file not shown.
Binary file modified data/img/sprites.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/img/sprites.xcf
Binary file not shown.
Binary file modified data/sprites_tiles.psgcompr
Binary file not shown.

0 comments on commit 79e2785

Please sign in to comment.