Skip to content

Commit

Permalink
Merge pull request #57 from jsmolina/feature/dogs_room
Browse files Browse the repository at this point in the history
Feature/dogs room
  • Loading branch information
jsmolina authored Jan 18, 2019
2 parents d7aa412 + 2fb8d71 commit 49acfbf
Show file tree
Hide file tree
Showing 25 changed files with 1,232 additions and 1,078 deletions.
14 changes: 12 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ bincat:
png2sp1sprite ./sprites/bincat_sprites.png --bit -i sprite_bincat -f 24 > ./build/bincat.asm

clothes:
png2sp1sprite ./sprites/clothes_sprites.png --bit -i sprite_clothes -f 64 > ./build/clothes.asm
png2sp1sprite ./sprites/clothes_sprites2.png --bit -i sprite_clothes2 -f 40 > ./build/clothes2.asm
@png2udg ./background/udg_clothes11.png
@png2udg ./background/udg_clothes12.png
@png2udg ./background/udg_clothes21.png
@png2udg ./background/udg_clothes22.png
@png2udg ./background/udg_boot.png
@png2udg ./background/udg_boot2.png

auxiliar:
png2sp1sprite ./sprites/auxiliar.png --bit -i auxiliar -f 32 > ./build/auxiliar.asm
Expand Down Expand Up @@ -147,3 +151,9 @@ spider:
bird:
@png2udg ./background/udg_birdcage1.png
@png2udg ./background/udg_birdcage2.png

dog:
@png2udg ./background/udg_dog1.png
@png2udg ./background/udg_dog1m.png
@png2udg ./background/udg_dog2.png
@png2udg ./background/udg_dogmilk.png
Binary file added background/udg_boot.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 background/udg_boot2.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 background/udg_clothes11.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 background/udg_clothes12.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 background/udg_clothes21.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 background/udg_clothes22.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 background/udg_dog.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 background/udg_dog1.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 background/udg_dog1m.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 background/udg_dog2.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 background/udg_dogmilk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion build/sprites.lst
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ protar
dogr
bincat
protaswim
clothes2
auxiliar
122 changes: 65 additions & 57 deletions defines.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "level4.h"
#include "level5.h"
#include "level6.h"
#include "level7.h"
#include "level_last.h"
#include "ay/ay_music.h"
#include <intrinsic.h> // for intrinsic_di()
Expand All @@ -29,8 +30,6 @@ struct freesprite aux_object;
struct sp1_ss *dogr1sp;
struct sp1_ss *bincatsp = NULL;

struct row_clothes row1clothes[2];
struct row_clothes row2clothes[2];
unsigned char udg_win2[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0};


Expand All @@ -49,11 +48,6 @@ extern uint8_t sprite_bincat2[];
extern uint8_t sprite_bincat3[];


extern uint8_t sprite_clothes21[];
extern uint8_t sprite_clothes22[];
extern uint8_t sprite_clothes23[];
extern uint8_t sprite_clothes24[];
extern uint8_t sprite_clothes25[];

extern uint8_t auxiliar1[];
extern uint8_t auxiliar2[];
Expand All @@ -70,6 +64,7 @@ uint8_t x, y;


// game required vars
uint8_t paws = 0;
uint8_t eaten_items;
uint8_t frame;
uint8_t x_malo;
Expand Down Expand Up @@ -246,21 +241,6 @@ static struct sp1_ss * add_sprite_bincat() {
}


static struct sp1_ss * add_sprite_clothes2() {
struct sp1_ss * sp;
sp = sp1_CreateSpr(SP1_DRAW_XOR1LB, SP1_TYPE_1BYTE, 3, (int)sprite_clothes21, 2);
sp1_AddColSpr(sp, SP1_DRAW_XOR1, SP1_TYPE_1BYTE, (int)sprite_clothes22, 2);
sp1_AddColSpr(sp, SP1_DRAW_XOR1, SP1_TYPE_1BYTE, (int)sprite_clothes23, 2);
sp1_AddColSpr(sp, SP1_DRAW_XOR1, SP1_TYPE_1BYTE, (int)sprite_clothes24, 2);
sp1_AddColSpr(sp, SP1_DRAW_XOR1, SP1_TYPE_1BYTE, (int)sprite_clothes25, 2);

sp1_AddColSpr(sp, SP1_DRAW_XOR1RB, SP1_TYPE_1BYTE, 0, 2);

sp1_IterateSprChar(sp, initialiseClothesColour);

return sp;
}

static struct sp1_ss * add_sprite_auxiliar() {
struct sp1_ss * sp;
sp = sp1_CreateSpr(SP1_DRAW_XOR1LB, SP1_TYPE_1BYTE, 3, (int)auxiliar1, 0);
Expand All @@ -285,20 +265,6 @@ void add_sprites_for_all_levels() {
aux_object.x = 0;
aux_object.y = 0;
aux_object.offset = RIGHTC1;


// row 1 clothes
row1clothes[0].col = 1;
row1clothes[0].sp = add_sprite_clothes2();
row1clothes[1].col = 18;
row1clothes[1].sp = add_sprite_clothes2();

// row 2 clothes
row2clothes[0].col = 1;
row2clothes[0].sp = add_sprite_clothes2();
row2clothes[1].col = 18;
row2clothes[1].sp = add_sprite_clothes2();

}

void loose_a_live() {
Expand Down Expand Up @@ -326,10 +292,11 @@ void reset_misifu_position() {
misifu.initial_jump_y = 0;
misifu.draw_additional = NONE;
misifu.offset = RIGHTC1;
misifu.state = NONE;
misifu.state = FALLING_FLOOR;
zx_border(INK_BLACK);
sp1_UpdateNow();
aux_object.offset = AUX_BROOM;
x_malo = 33;
}

void print_room_walls(uint8_t initial_window, uint8_t paper_color, uint8_t ink_color) {
Expand Down Expand Up @@ -382,6 +349,22 @@ void print_room_walls(uint8_t initial_window, uint8_t paper_color, uint8_t ink_c

}

void check_level7_keys() {
if (in_key_pressed(IN_KEY_SCANCODE_q) && misifu.y > 17) {
--misifu.y;
misifu.state = misifu.draw_additional;
} else if (in_key_pressed(IN_KEY_SCANCODE_p) && misifu.x < level_x_max) {
++misifu.x;
misifu.state = misifu.draw_additional = WALKING_RIGHT;
} else if (in_key_pressed(IN_KEY_SCANCODE_o) && misifu.x > level_x_min) {
--misifu.x;
misifu.state = misifu.draw_additional = WALKING_LEFT;
} else if(in_key_pressed(IN_KEY_SCANCODE_a) && misifu.y < 22) {
++misifu.y;
misifu.state = misifu.draw_additional;

}
}

void check_keys()
{
Expand Down Expand Up @@ -411,17 +394,18 @@ void check_keys()
}

if (in_key_pressed(IN_KEY_SCANCODE_0)) {
print_background_level_last();
} else if (in_key_pressed(IN_KEY_SCANCODE_1)) {
print_background_lvl1();
} else if (in_key_pressed(IN_KEY_SCANCODE_2)) {
print_background_level2();
} else if (in_key_pressed(IN_KEY_SCANCODE_3)) {
print_background_level3();
} else if (in_key_pressed(IN_KEY_SCANCODE_5)) {
print_background_level5();
} else if (in_key_pressed(IN_KEY_SCANCODE_6)) {
print_background_level6();
++last_success_level;
if(last_success_level > 7) {
last_success_level = 0;
}
}

if (in_key_pressed(IN_KEY_SCANCODE_f)) {
if(paws == 0) {
paws = 1;
} else {
paws = 0;
}
}
}

Expand Down Expand Up @@ -463,13 +447,12 @@ void check_swim() {
}
}

uint8_t dog_checks() {
void dog_checks() {
// time for doggy checks
if (misifu.state != FIGHTING && enemy_apears == YES) {

--x_malo;


if (frame < 2) {
dog_offset = DOG1;
} else if (frame < 4) {
Expand Down Expand Up @@ -509,7 +492,6 @@ uint8_t dog_checks() {
return;
}
enemy_apears = NONE;
x_malo = 33;
idx = 1;
}
sp1_MoveSprAbs(dogr1sp, &full_screen, (void*) dog_offset, FLOOR_Y, x_malo, 0, 0);
Expand All @@ -518,7 +500,7 @@ uint8_t dog_checks() {
if (enemy_apears != YES && first_keypress != NONE) {
enemy_apears = random_value % 100;
}
return idx;
return;
}

static void stop_jump_if_needed(uint8_t max_jump) {
Expand All @@ -530,7 +512,7 @@ static void stop_jump_if_needed(uint8_t max_jump) {

void check_fsm() {
// decide new FSM draw status
if (misifu.state == NONE && frame == 3) {
if (misifu.state == NONE && frame == 3 && level != 7) {
misifu.offset = BORED;
} else if (misifu.state == WALKING_RIGHT) {
if (frame < 2) {
Expand Down Expand Up @@ -593,6 +575,13 @@ void check_fsm() {
misifu.state = NONE;
misifu.offset = BORED;
}
} else if (misifu.state == FALLING_FLOOR) {
++misifu.y;
misifu.draw_additional = NONE;
if(misifu.y >= FLOOR_Y) {
misifu.y = FLOOR_Y;
misifu.state = NONE;
}
} else if(misifu.state == CAT_IN_ROPE) {
if(misifu.x >= 28 || misifu.x == 0) {
misifu.state = FALLING;
Expand Down Expand Up @@ -651,17 +640,29 @@ void get_out_of_level_generic(uint8_t fall) {
INK_WHITE | PAPER_BLACK,
' ' );

if(fall != WON_LEVEL) {
bit_beepfx_di_fastcall(BEEPFX_GULP);
} else {
// keep progress of levels
if(fall == WON_LEVEL) {
last_success_level = level;
points = points + 10;
bit_beepfx_di_fastcall(BEEPFX_SELECT_5);
} else {
loose_a_live();
}

if (fall == ELECTRIFIED) {
for (idx = 0; idx != 5; ++idx) {
bit_beepfx_di_fastcall(BEEPFX_HIT_4);
zx_border(INK_WHITE);
wait();
zx_border(INK_BLUE);
}
} else {
bit_beepfx_di_fastcall(BEEPFX_GULP);
}

// control wether if gets out of level by having eat all mouses
sp1_Invalidate(&full_screen);
level = 1;
x_malo = 33;
sp1_UpdateNow();
print_background_lvl1();
}
Expand Down Expand Up @@ -757,5 +758,12 @@ void check_chair_and_table() {
detect_fall_in_chair(21);
}

void assign_window_pos(uint8_t y, uint8_t x) {
windows[idx].has_item = NONE;
windows[idx].x = x;
windows[idx].y = y;
++idx;
}


// reference: https://github.com/z88dk/z88dk/blob/master/include/_DEVELOPMENT/sdcc/arch/zx/sp1.h#L83
17 changes: 8 additions & 9 deletions defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#define UNDEF 250
#define NONE 0
#define WON_LEVEL 10
#define DOG_AWAKEN 30
#define ELECTRIFIED 40
#define YES 1
#define CLEAN 1
#define BIN_Y1 15
Expand All @@ -16,6 +18,7 @@
#define WALKING_RIGHT 2
#define JUMPING 3
#define FALLING 4
#define FALLING_FLOOR 69
#define BITE 55
#define OXYGEN 99
#define FIGHTING 5
Expand Down Expand Up @@ -102,9 +105,9 @@ extern uint8_t level_x_max;
extern uint8_t level_x_min;

// shared vars
extern uint8_t x, y;

extern uint8_t x;

extern uint8_t paws;
// game required vars
// useful for controlling amount of things to eat (mouses, fishes, ...)
extern char left;
Expand Down Expand Up @@ -162,12 +165,6 @@ extern uint8_t horizontal_direction;

extern void add_sprites_for_all_levels();

struct row_clothes {
struct sp1_ss* sp;
uint8_t col;
uint8_t offset;
};

struct prota {
struct sp1_ss* sp;
uint8_t x;
Expand Down Expand Up @@ -202,8 +199,9 @@ extern void reset_misifu_position();
// extern void page(uint8_t bank);

extern void check_keys();
extern void check_level7_keys();

extern uint8_t dog_checks();
extern void dog_checks();

extern void check_swim();

Expand Down Expand Up @@ -231,5 +229,6 @@ extern struct sp1_ss * add_sprite_protar1();
extern void check_chair_and_table();

extern void move_right_and_left();
extern void assign_window_pos(uint8_t y, uint8_t x);

#endif
Loading

0 comments on commit 49acfbf

Please sign in to comment.