Skip to content

Commit

Permalink
Merge pull request #47 from jsmolina/feature/3rdlaberynth
Browse files Browse the repository at this point in the history
3rd laberynth
  • Loading branch information
jsmolina authored Aug 5, 2019
2 parents 0ff27a6 + 22921a0 commit a77a54b
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 13 deletions.
27 changes: 27 additions & 0 deletions globals.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,33 @@ uint8_t map2[25][32] = {
{E,A,A,A,A,A,A,A,A,A,A,A,A,A,A,J,J,A,A,A,A,A,A,A,A,A,A,A,A,A,A,F}
};

uint8_t map3[25][32] = {
{C,A,A,A,A,A,A,A,A,A,A,M,M,A,A,A,A,A,A,M,M,A,A,A,A,A,A,A,A,A,A,D},
{B,0,0,0,0,0,0,0,0,0,0,B,B,0,0,0,0,0,0,B,B,0,0,0,0,0,0,0,0,0,0,B},
{B,I,I,I,I,I,I,I,I,I,0,B,B,I,I,I,I,I,0,B,B,I,I,I,I,I,I,I,I,I,0,B},
{B,I,0,U,I,0,C,A,D,I,0,B,B,I,0,S,T,I,0,B,B,I,0,C,A,D,I,0,U,I,0,B},
{B,K,0,B,I,0,B,0,B,I,0,B,B,I,0,0,0,I,0,B,B,I,0,B,0,B,I,0,B,K,0,B},
{B,I,0,V,I,0,E,A,F,I,0,E,F,I,I,I,I,I,0,E,F,I,0,E,A,F,I,0,V,I,0,B},
{B,I,0,0,I,0,0,0,0,I,0,0,0,I,0,C,D,I,0,0,0,I,0,0,0,0,0,0,0,I,0,B},
{B,I,I,I,I,I,I,I,I,I,I,I,I,I,0,B,B,I,I,I,I,I,I,I,I,I,I,I,I,I,0,B},
{B,I,0,S,A,T,I,0,C,A,T,I,0,S,A,J,J,A,T,I,0,S,A,D,I,0,S,A,T,I,0,B},
{B,I,0,0,0,0,I,0,B,0,0,I,0,0,0,0,0,0,0,I,0,0,0,B,I,0,0,0,0,I,0,B},
{B,I,I,I,I,I,I,0,B,I,I,I,I,I,I,I,I,I,I,I,I,I,0,B,I,I,I,I,I,I,0,B},
{E,A,A,T,I,0,S,A,F,I,0,C,A,A,T,Y,Y,S,A,A,D,I,0,E,A,T,I,0,S,A,A,F},
{0,0,0,0,I,0,0,0,0,I,0,B,0,0,0,0,0,0,0,0,B,I,0,0,0,0,I,0,0,0,0,0},
{0,I,I,I,I,I,I,I,I,I,0,B,0,0,0,0,0,0,0,0,B,I,I,I,I,I,I,I,I,I,I,0},
{C,A,A,T,I,0,S,A,D,I,0,E,A,A,A,A,A,A,A,A,F,I,0,C,A,T,I,0,S,A,A,D},
{B,0,0,0,I,0,0,0,B,I,0,0,0,0,0,0,0,0,0,0,0,I,0,B,0,0,I,0,0,0,0,B},
{B,I,I,I,I,I,I,0,B,I,I,I,I,I,I,I,I,I,I,I,I,I,0,B,I,I,I,I,I,I,0,B},
{B,I,0,C,A,T,I,0,E,A,T,I,0,S,T,I,0,S,T,I,0,S,A,F,I,0,S,A,D,I,0,B},
{B,I,0,B,0,0,I,0,0,0,0,I,0,0,0,I,0,0,0,I,0,0,0,0,I,0,0,0,B,I,0,B},
{B,I,0,B,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,0,B,I,0,B},
{B,K,0,V,I,0,C,D,I,0,S,A,T,I,0,S,T,I,0,S,A,T,I,0,C,D,I,0,V,K,0,B},
{B,I,0,0,I,0,B,B,I,0,0,0,0,I,0,0,0,I,0,0,0,0,I,0,B,B,I,0,0,I,0,B},
{B,I,I,I,I,0,B,B,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,0,B,B,I,I,I,I,0,B},
{E,A,A,A,A,A,J,J,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,J,J,A,A,A,A,A,F}
};

uint8_t * currentmap;
// todo puntero al mapa actual, posiciones diferentes para el mapa

Expand Down
4 changes: 4 additions & 0 deletions globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#define MAP1_Y_SIDE_CHG 12
#define MAP2_Y_SIDE_CHG 10
#define MAP3_Y_SIDE_CHG 12
#define RIGHTC1 1
#define RIGHTC2 33
#define RIGHTC3 65
Expand Down Expand Up @@ -39,6 +40,7 @@
#define GHOST_EYES 321
#define MAP1_TOTAL_POINTS 238
#define MAP2_TOTAL_POINTS 251
#define MAP3_TOTAL_POINTS 254

#define DIR_UP 1
#define DIR_DOWN 2
Expand All @@ -56,6 +58,7 @@

#define Y_GHOSTS_HOME_MAP1 15;
#define Y_GHOSTS_HOME_MAP2 10;
#define Y_GHOSTS_HOME_MAP3 12;

// map integer correspondence
#define A 1
Expand Down Expand Up @@ -166,6 +169,7 @@ extern uint8_t cartoon0[];

extern uint8_t map[25][32];
extern uint8_t map2[25][32];
extern uint8_t map3[25][32];
extern uint8_t random_value;

extern uint8_t pill_eaten;
Expand Down
42 changes: 29 additions & 13 deletions logic.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ uint8_t get_map_color(uint8_t current) {
return INK_WHITE;
}
// INK_BLUE for level 1, INK_CYAN level2
if(map_num == 2) {
if(map_num == 3) {
return INK_MAGENTA | BRIGHT;
} else if(map_num == 2) {
return INK_CYAN | BRIGHT;
} else {
return INK_BLUE;
}
return INK_BLUE;
}

uint8_t get_map_char(uint8_t current) {
Expand Down Expand Up @@ -77,10 +78,12 @@ void set_ghosts_default_coords() {
ghosts[idx]->default_x = current;
current = current + 2;

if((level & 1) == 0) {
if(map_num == 1) {
ghosts[idx]->default_y = Y_GHOSTS_HOME_MAP1;
} else {
} else if(map_num == 2) {
ghosts[idx]->default_y = Y_GHOSTS_HOME_MAP2;
} else if(map_num == 3) {
ghosts[idx]->default_y = Y_GHOSTS_HOME_MAP3;
}
}
}
Expand Down Expand Up @@ -461,19 +464,30 @@ void next_level() {
zx_border(INK_BLACK);
++level;

if((level & 1) == 0) {
currentmap = &map[0][0];
if(map_num == 1) {
remaining_points = MAP1_TOTAL_POINTS;
// only when returning to first map again, increase speed
if (speed > 1) {
if (speed > 1 && map_num > 3) {
--speed;
}
} else if(map_num == 2){
remaining_points = MAP2_TOTAL_POINTS;
} else if(map_num == 3){
remaining_points = MAP3_TOTAL_POINTS;
}
++map_num;
if(map_num > 3) {
map_num = 1;
} else {
}

if(map_num == 1) {
currentmap = &map[0][0];
} else if(map_num == 2) {
currentmap = &map2[0][0];
remaining_points = MAP2_TOTAL_POINTS;
map_num = 2;
} else {
currentmap = &map3[0][0];
}

reset_map();
set_ghosts_default_coords();

Expand Down Expand Up @@ -529,7 +543,8 @@ void check_fsm() {

// side change
if((map_num == 1 && pacman.y == MAP1_Y_SIDE_CHG) ||
(map_num == 2 && pacman.y == MAP2_Y_SIDE_CHG)) {
(map_num == 2 && pacman.y == MAP2_Y_SIDE_CHG) ||
(map_num == 3 && pacman.y == MAP3_Y_SIDE_CHG)) {
if(pacman.x < 2 && pacman.direction == DIR_LEFT) {
pacman.x = 30;
} else if(pacman.x >= 29 && pacman.direction == DIR_RIGHT) {
Expand Down Expand Up @@ -569,7 +584,8 @@ void check_fsm() {
}
// side change
if((map_num == 1 && ghosts[idx]->y == MAP1_Y_SIDE_CHG) ||
(map_num == 2 && ghosts[idx]->y == MAP2_Y_SIDE_CHG)) {
(map_num == 2 && ghosts[idx]->y == MAP2_Y_SIDE_CHG)||
(map_num == 3 && ghosts[idx]->y == MAP3_Y_SIDE_CHG)) {
if(ghosts[idx]->x < 2 && ghosts[idx]->direction == DIR_LEFT) {
ghosts[idx]->x = 29;
} else if(ghosts[idx]->x > 28 && ghosts[idx]->direction == DIR_RIGHT) {
Expand Down

0 comments on commit a77a54b

Please sign in to comment.