Skip to content

Commit

Permalink
Merge pull request #60 from jsmolina/fix/glitch_broom
Browse files Browse the repository at this point in the history
remove two lines
  • Loading branch information
jsmolina authored Jan 27, 2019
2 parents 6e95808 + 782200b commit 5f23ef8
Show file tree
Hide file tree
Showing 5 changed files with 1,227 additions and 1,274 deletions.
49 changes: 35 additions & 14 deletions defines.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ uint8_t level = 1;
uint8_t lives = 5;
uint8_t last_success_level = 0;
uint8_t repaint_lives = 0;
uint16_t points = 0;
uint8_t points = 0;


// hearts holes
Expand Down Expand Up @@ -276,7 +276,6 @@ void loose_a_live() {
} else {
// reached zero on lives
lives = 5;
points = 0;
last_success_level = 0;
bit_beepfx_di_fastcall(BEEPFX_BOOM_1);

Expand All @@ -297,6 +296,7 @@ void reset_misifu_position() {
sp1_UpdateNow();
aux_object.offset = AUX_BROOM;
x_malo = 33;
points = 0;
}

void print_room_walls(uint8_t initial_window, uint8_t paper_color, uint8_t ink_color) {
Expand Down Expand Up @@ -395,10 +395,7 @@ void check_keys()
}

if (in_key_pressed(IN_KEY_SCANCODE_0)) {
++last_success_level;
if(last_success_level > 7) {
last_success_level = 0;
}
print_background_level_last();
}
}

Expand Down Expand Up @@ -636,12 +633,41 @@ void detect_fall_in_chair(uint8_t x_chair) {
void get_out_of_level_generic(uint8_t fall) {
// todo progress levels count, count how many time player stayed in level
sp1_Initialize( SP1_IFLAG_MAKE_ROTTBL | SP1_IFLAG_OVERWRITE_TILES | SP1_IFLAG_OVERWRITE_DFILE,
INK_WHITE | PAPER_BLACK,
INK_WHITE | PAPER_WHITE,
' ' );
// control wether if gets out of level by having eat all mouses
sp1_Invalidate(&full_screen);

if(fall == LEVELFINISHED) {
last_success_level = 0;
sp1_DeleteSpr_fastcall(dogr1sp);
dogr1sp = add_sprite_protar1();
sp1_PrintAt(10, 14, INK_BLACK | PAPER_WHITE, 'l');
sp1_PrintAt(10, 15, INK_BLACK | PAPER_WHITE, 'o');
sp1_PrintAt(10, 16, INK_BLACK | PAPER_WHITE, 'v');
sp1_PrintAt(10, 17, INK_BLACK | PAPER_WHITE, 'e');
for (idx = 0; idx != 12; ++idx) {

if((idx & 1) == 0) {
misifu.offset = RIGHTC1;
idx_j = LEFTC1;
} else {
misifu.offset = RIGHTC2;
idx_j = LEFTC2;
}
sp1_MoveSprAbs(misifu.sp, &full_screen,(void*) misifu.offset, FLOOR_Y, 2 + idx, 0, 0);

if(fall == WON_LEVEL) {
sp1_MoveSprAbs(dogr1sp, &full_screen,(void*) idx_j, FLOOR_Y, 30 - idx, 0, 0);
sp1_UpdateNow();
for(idx_j = 0; idx_j != 10; ++idx_j) {
wait();
}
}
sp1_DeleteSpr_fastcall(dogr1sp);
dogr1sp = add_sprite_dogr1();

} else if(fall == WON_LEVEL) {
last_success_level = level;
points = points + 10;
bit_beepfx_di_fastcall(BEEPFX_SELECT_5);
} else {
loose_a_live();
Expand All @@ -658,11 +684,6 @@ void get_out_of_level_generic(uint8_t fall) {
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
2 changes: 1 addition & 1 deletion defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ extern uint8_t level;
extern uint8_t lives;
extern uint8_t last_success_level; // to see user progress
extern uint8_t repaint_lives;
extern uint16_t points;
extern uint8_t points;

extern uint8_t floor_holes[][24];

Expand Down
139 changes: 39 additions & 100 deletions level_last.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,46 +39,6 @@ static void paint_cupid(uint8_t row, uint8_t col) {
sp1_PrintAt( row + 2, col + 2, INK_RED | PAPER_GREEN, 'K');
}

static void get_out_of_level_last(uint8_t fall) {

sp1_Initialize( SP1_IFLAG_MAKE_ROTTBL | SP1_IFLAG_OVERWRITE_TILES | SP1_IFLAG_OVERWRITE_DFILE,
INK_WHITE | PAPER_BLACK,
' ' );
if(fall == FALLING) {
//row1clothes[0].offset = MISIOFFSET;
zx_border(INK_RED);
} else {
// this will mean a level ending!
last_success_level = 0;
points = points + 100;
zx_border(INK_MAGENTA);
//row1clothes[0].offset = LOVEOFFSET;
}

sp1_Invalidate(&full_screen);
x = 14;
idx_j = 0;

for (idx = 0; idx != 40; ++idx) {
++idx_j;

if(idx_j > 20) {
if (fall == FALLING) {
//row1clothes[0].offset = OUCHOFFSET;
}
idx_j = 20;
}
//sp1_MoveSprAbs(row1clothes[0].sp, &full_screen,(void*) row1clothes[0].offset, y, x, 0, 0);
sp1_UpdateNow();
wait();
}
if(fall == FALLING) {
bit_beepfx_di_fastcall(BEEPFX_AWW);
} else {
bit_beepfx_di_fastcall(BEEPFX_SELECT_5);
}
print_background_lvl1();
}

void print_background_level_last() {
level = 10;
Expand Down Expand Up @@ -121,8 +81,7 @@ void print_background_level_last() {
// frame = floor
frame = 4;

for(idx=23; idx > 3; idx = idx - 4) {
x = idx_j - 4;
for(idx=23; idx != 3; idx = idx - 4) {

for (idx_j=4; idx_j != 28; ++idx_j ) {
random_value = rand();
Expand Down Expand Up @@ -150,17 +109,17 @@ void print_background_level_last() {
/**
hearts y are 23, 19, 15, 11, 7
**/
static inline uint8_t lvl3_y_to_idj(uint8_t offset) {
static inline uint8_t lvl3_y_to_idj(uint8_t y) {

if(misifu.y == 5 + offset) {
if(y == 5) {
return 0;
} else if(misifu.y == 9 + offset) {
} else if(y == 9) {
return 1;
} else if(misifu.y == 13 + offset) {
} else if(y == 13) {
return 2;
} else if(misifu.y == 17 + offset) {
} else if(y == 17) {
return 3;
} else if (misifu.y == FLOOR_Y + offset) {
} else if (y == FLOOR_Y) {
return 4;
} else {
return UNDEF;
Expand All @@ -169,36 +128,28 @@ static inline uint8_t lvl3_y_to_idj(uint8_t offset) {


void detect_fall_in_hearts() {
idx_j = lvl3_y_to_idj(0);

if (misifu.state == WALKING_LEFT || misifu.state == WALKING_RIGHT || misifu.state == CAT_ON_HIGH || misifu.state == NONE) {
// 0 - 24
if (idx_j < 5 && misifu.x > 1 && floor_holes[idx_j][misifu.x - 2] == 0) {
misifu.state = FALLING;
if (misifu.y >= FLOOR_Y) {
get_out_of_level_last(FALLING);
return;
}
idx_j = lvl3_y_to_idj(misifu.y);
if (idx_j == UNDEF) {
return;
}

idx = misifu.x - 2;
// todo this is not always working, maybe related to painting?
if (floor_holes[idx_j][idx] == 0) {
misifu.state = FALLING;
if (misifu.y >= FLOOR_Y) {
get_out_of_level_generic(FALLING);
return;
}
} else if (misifu.state == FALLING && idx_j < 5 && floor_holes[idx_j][misifu.x - 2] == 1) {
if(misifu.y == 17) {
misifu.state = CAT_ON_HIGH;
misifu.draw_additional = CAT_IN_ROPE;
misifu.offset = BORED;
} else if(misifu.y == 13) {
misifu.state = CAT_ON_HIGH;
misifu.draw_additional = CAT_IN_ROPE1;
misifu.offset = BORED;
} else if(misifu.y == 9) {
misifu.state = CAT_ON_HIGH;
misifu.draw_additional = CAT_IN_ROPE2;
misifu.offset = BORED;
} else if(misifu.y == 5) {
misifu.state = CAT_ON_HIGH;
misifu.draw_additional = CAT_IN_ROPE3;
misifu.offset = BORED;
get_out_of_level_last(LEVELFINISHED); // yayyy
} else if (floor_holes[idx_j][idx] == 1 && misifu.state == FALLING) {
if(idx_j == 0) {
get_out_of_level_generic(LEVELFINISHED); // yayyy
return;
}
zx_border(INK_BLACK);
misifu.state = CAT_ON_HIGH;
misifu.draw_additional = CAT_IN_ROPE;
misifu.offset = BORED;
}
}

Expand All @@ -224,36 +175,24 @@ inline void heavencat_on_move() {
print_heavencats(1);

if(frame == 3) {
if(random_value > 40 && random_value < 80) {
++udgxs[0];
} else if(random_value > 80 && random_value < 150) {
++udgxs[1];
} else if(random_value > 150 && random_value < 190) {
++udgxs[2];
} else if(random_value > 190 && random_value < 230) {
++udgxs[3];
}
// if going to right, return left
for(idx_j = 0; idx != 4; ++idx) {
if(udgxs[idx_j] > 25) {
udgxs[idx_j] = 5;
}
idx_j = random_value % 4;
++udgxs[idx_j];
if(udgxs[idx_j] > 25) {
// if reaching right, return left
udgxs[idx_j] = 5;
}
}

// repaint
print_heavencats(0);

// detect collision with misifu
if(misifu.y == 5 && abs(misifu.x - udgxs[0]) < 2 ) {
misifu.state = FALLING;
} else if(misifu.y == 9 && abs(misifu.x - udgxs[1]) < 2) {
misifu.state = FALLING;
} else if(misifu.y == 13 && abs(misifu.x - udgxs[2]) < 2) {
misifu.state = FALLING;
} else if(misifu.y == 17 && abs(misifu.x - udgxs[3]) < 2) {
idx_j = lvl3_y_to_idj(misifu.y);
if(idx_j != UNDEF && abs(misifu.x - udgxs[idx_j]) < 2) {
misifu.state = FALLING;
bit_beepfx_di_fastcall(BEEPFX_HIT_1);
}

// saves lot of memory to use udg in this animation
}

Expand Down Expand Up @@ -283,12 +222,12 @@ void throw_cupid_arrow() {
}

// hearts y are 23, 19, 15, 11, 7
idx_j = lvl3_y_to_idj(2);
idx_j = lvl3_y_to_idj(aux_object.y - 2);

if(idx_j < 5 && aux_object.x > 3 && aux_object.x < 27) {
// broke the heart :(
sp1_PrintAtInv( aux_object.y, aux_object.x, INK_BLUE | PAPER_GREEN, 'A');
floor_holes[idx_j][aux_object.x] = 0;
sp1_PrintAtInv( aux_object.y, aux_object.x + 1, INK_BLUE | PAPER_GREEN, 'A');
floor_holes[idx_j][aux_object.x - 3] = 0;
}
} else {
// out of screen
Expand Down
4 changes: 4 additions & 0 deletions misifu.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,12 @@ int main()
++frame;
if (frame >= 4) {
frame = 0;
if (points < 254) {
++points;
}
}


// paint 'prota here'
sp1_MoveSprAbs(misifu.sp, &full_screen, (void*) misifu.offset, misifu.y, misifu.x, 0, 0);

Expand Down
Loading

0 comments on commit 5f23ef8

Please sign in to comment.