Skip to content

Commit

Permalink
Merge pull request #32 from jsmolina/feature/bonus_items
Browse files Browse the repository at this point in the history
Feature/bonus items
  • Loading branch information
jsmolina authored Jun 9, 2019
2 parents a3c6f50 + 2efa655 commit 8dc038f
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 13 deletions.
Binary file modified .DS_Store
Binary file not shown.
20 changes: 10 additions & 10 deletions build/cerezas.asm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ PUBLIC _cerezas1
defb @00000000
defb @00000000
defb @00000000
defb @00000000
defb @00000001
defb @00000010
defb @00000100
Expand All @@ -36,7 +37,6 @@ PUBLIC _cerezas1
defb @00000000
defb @00000000
defb @00000000
defb @00000000

defb @00000000
defb @00000000
Expand All @@ -51,6 +51,7 @@ PUBLIC _cerezas1
defb @00000000
defb @00000000
defb @00000000
defb @00000000
defb @00000101
defb @00000011
defb @00000111
Expand All @@ -71,7 +72,6 @@ PUBLIC _cerezas1
defb @00000000
defb @00000000
defb @00000000
defb @00000000

defb @00000000
defb @00000000
Expand All @@ -86,6 +86,7 @@ PUBLIC _cerezas1
defb @00000000
defb @00000000
defb @00000000
defb @00000000
defb @00001110
defb @00011111
defb @00111110
Expand All @@ -106,7 +107,6 @@ PUBLIC _cerezas1
defb @00000000
defb @00000000
defb @00000000
defb @00000000

defb @00000000
defb @00000000
Expand All @@ -118,6 +118,7 @@ PUBLIC _cerezas1
defb @00000000

._cerezas1_f4
defb @00000000
defb @00000000
defb @00000110
defb @00000010
Expand All @@ -141,7 +142,6 @@ PUBLIC _cerezas1
defb @00000000
defb @00000000
defb @00000000
defb @00000000

defb @00000000
defb @00000000
Expand All @@ -153,6 +153,7 @@ PUBLIC _cerezas1
defb @00000000

._cerezas1_f5
defb @00000000
defb @00000000
defb @00000000
defb @00000001
Expand All @@ -176,7 +177,6 @@ PUBLIC _cerezas1
defb @00000000
defb @00000000
defb @00000000
defb @00000000

defb @00000000
defb @00000000
Expand All @@ -190,6 +190,7 @@ PUBLIC _cerezas1
PUBLIC _cerezas2
._cerezas2

defb @00000000
defb @00000000
defb @00000000
defb @00000110
Expand All @@ -213,7 +214,6 @@ PUBLIC _cerezas2
defb @00000000
defb @00000000
defb @00000000
defb @00000000

defb @00000000
defb @00000000
Expand All @@ -228,6 +228,7 @@ PUBLIC _cerezas2
defb @00000000
defb @00000000
defb @00000000
defb @00000000
defb @01000000
defb @10100000
defb @11000000
Expand All @@ -248,7 +249,6 @@ PUBLIC _cerezas2
defb @00000000
defb @00000000
defb @00000000
defb @00000000

defb @00000000
defb @00000000
Expand All @@ -260,6 +260,7 @@ PUBLIC _cerezas2
defb @00000000

._cerezas2_f3
defb @00000000
defb @00010000
defb @00100000
defb @01000000
Expand All @@ -283,7 +284,6 @@ PUBLIC _cerezas2
defb @00000000
defb @00000000
defb @00000000
defb @00000000

defb @00000000
defb @00000000
Expand All @@ -295,6 +295,7 @@ PUBLIC _cerezas2
defb @00000000

._cerezas2_f4
defb @00000000
defb @00000000
defb @01100000
defb @11000000
Expand All @@ -318,7 +319,6 @@ PUBLIC _cerezas2
defb @00000000
defb @00000000
defb @00000000
defb @00000000

defb @00000000
defb @00000000
Expand All @@ -330,6 +330,7 @@ PUBLIC _cerezas2
defb @00000000

._cerezas2_f5
defb @00000000
defb @00000000
defb @11000000
defb @00000000
Expand All @@ -353,7 +354,6 @@ PUBLIC _cerezas2
defb @00000000
defb @00000000
defb @00000000
defb @00000000

defb @00000000
defb @00000000
Expand Down
Binary file modified build/cerezas.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed build/cerezas.png.bak.png
Binary file not shown.
3 changes: 2 additions & 1 deletion globals.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ uint8_t map[25][32] = {
{E,A,A,A,A,T,I,0,X,A,A,A,T,I,0,E,F,I,0,S,A,A,A,W,I,0,S,A,A,A,A,F},
{0,0,0,0,0,0,I,0,B,0,0,0,0,I,0,0,0,I,0,0,0,0,0,B,I,0,0,0,0,0,0,0},
{0,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,0},
{C,A,A,A,A,T,I,0,B,I,0,C,A,A,A,Y,Y,A,A,A,D,I,0,B,I,0,S,A,A,A,A,D},
{C,A,A,A,A,T,I,0,B,I,0,C,A,A,T,Y,Y,S,A,A,D,I,0,B,I,0,S,A,A,A,A,D},
{B,0,0,0,0,0,I,0,B,I,0,B,0,0,0,0,0,0,0,0,B,I,0,B,I,0,0,0,0,0,0,B},
{B,I,I,I,I,I,I,0,B,I,0,B,0,0,0,0,0,0,0,0,B,I,0,B,I,I,I,I,I,I,0,B},
{B,I,0,C,A,D,I,0,V,I,0,E,A,A,A,A,A,A,A,A,F,I,0,V,I,0,C,A,D,I,0,B},
Expand Down Expand Up @@ -62,6 +62,7 @@ uint8_t remaining_points;
uint8_t frame = 0;

uint8_t lives = 0;
uint8_t level = 0;
uint8_t repaint_lives = 1;
uint8_t speed;
uint8_t idx;
Expand Down
7 changes: 7 additions & 0 deletions globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@
#define X 24
#define Y 25

#define CHERRY 1
#define STRAWBERRY 33
#define COCKTAIL 65
#define APPLE 97
#define PEAR 129

// screen rectangle
extern struct sp1_Rect full_screen;

Expand Down Expand Up @@ -172,6 +178,7 @@ extern uint8_t speed;
extern uint8_t frame;

extern uint8_t lives;
extern uint8_t level;
extern uint8_t repaint_lives;
extern uint8_t idx;
extern struct sprite * collided_sprite;
Expand Down
43 changes: 42 additions & 1 deletion logic.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "logic.h"
#include "int.h"
#include <sound.h>
#include <input.h>

uint8_t get_map_color(uint8_t current) {
if(current == I) {
Expand Down Expand Up @@ -58,6 +59,23 @@ void show_cherry() {
cherry.y = 21;
cherry.x = 14;
cherry.showing = 100;

if(level == 0) {
cherry.offset = CHERRY;
sp1_IterateSprChar(cherry.sp, initialiseColourGreenRed);
} else if(level == 1) {
cherry.offset = STRAWBERRY;
sp1_IterateSprChar(cherry.sp, initialiseColourGreenRed);
} else if(level == 2) {
cherry.offset = COCKTAIL;
sp1_IterateSprChar(cherry.sp, initialiseColourRedYellowWhiteCyan);
} else if(level == 3) {
cherry.offset = APPLE;
sp1_IterateSprChar(cherry.sp, initialiseColourGhostRed);
} else if (level == 4) {
cherry.offset = PEAR;
sp1_IterateSprChar(cherry.sp, initialiseColourGreen);
}
}

void hide_cherry() {
Expand Down Expand Up @@ -345,6 +363,11 @@ void next_level() {
if (speed > 1) {
--speed;
}

++level;
if(level == 5) {
level = 0;
}
}


Expand Down Expand Up @@ -375,7 +398,11 @@ void check_fsm() {
points += 20; // energizers - are worth 20 points each
pill_eaten = 125;
for(idx = 0; idx != 4; ++idx) {
if(ghosts[idx]->active == ACTIVE) {
if(ghosts[idx]->active == ACTIVE || ghosts[idx]->active == ELUDE) {
// stop so we could decide to "sacar pies en polvorosa"
ghosts[idx]->dx = 0;
ghosts[idx]->dy = 0;

ghosts[idx]->active = ELUDE;
ghosts[idx]->currentoffset = GHOST_FRIGHTENED;
sp1_IterateSprChar(ghosts[idx]->sp, initialiseColourBlue);
Expand Down Expand Up @@ -478,4 +505,18 @@ void check_fsm() {
// level finished!
next_level();
}

if(in_key_pressed(IN_KEY_SCANCODE_1)) {
level = 1;
show_cherry();
} else if(in_key_pressed(IN_KEY_SCANCODE_2)) {
level = 2;
show_cherry();
}else if(in_key_pressed(IN_KEY_SCANCODE_3)) {
level = 3;
show_cherry();
}else if(in_key_pressed(IN_KEY_SCANCODE_4)) {
level = 4;
show_cherry();
}
}
3 changes: 2 additions & 1 deletion msnampac.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ void all_lives_lost() {
sp1_Invalidate(&full_screen);
lives = 5;
points = 0;
level = 0;
speed = 6;
nampac_go_home();
repaint_lives = 1;
Expand Down Expand Up @@ -130,7 +131,7 @@ int main()
sp1_MoveSprAbs(ghosts[idx]->sp, &full_screen, (void*) ghosts[idx]->offset, ghosts[idx]->y, ghosts[idx]->x, 0, 0);
}
if(cherry.showing != 0) {
sp1_MoveSprAbs(cherry.sp, &full_screen, (void*) 0, cherry.y, cherry.x, 0, 0);
sp1_MoveSprAbs(cherry.sp, &full_screen, (void*) cherry.offset, cherry.y, cherry.x, 0, 0);
}

if(repaint_lives) {
Expand Down
22 changes: 22 additions & 0 deletions sprites.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,28 @@ void initialiseColourGreenRed(unsigned int count, struct sp1_cs *c)
}
}

void initialiseColourGreen(unsigned int count, struct sp1_cs *c)
{
(void)count;
c->attr_mask = SP1_AMASK_INK;
c->attr = INK_GREEN;

}

void initialiseColourRedYellowWhiteCyan(unsigned int count, struct sp1_cs *c)
{
c->attr_mask = SP1_AMASK_INK;
if(count == 0) {
c->attr = INK_RED;
} else if (count == 1){
c->attr = INK_YELLOW;
} else if(count == 3) {
c->attr = INK_WHITE;
} else {
c->attr = INK_CYAN;
}
}

struct sp1_ss * add_cherry_sprite() {
struct sp1_ss * sp;
sp = sp1_CreateSpr(SP1_DRAW_LOAD1LB, SP1_TYPE_1BYTE, 3, (int)cerezas1, 1);
Expand Down
3 changes: 3 additions & 0 deletions sprites.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@ extern void initialiseColourYellow(unsigned int count, struct sp1_cs *c);
extern void initialiseColourGhostCyan(unsigned int count, struct sp1_cs *c);
extern void initialiseColourGhostMagenta(unsigned int count, struct sp1_cs *c);
extern void initialiseColourGhostRed(unsigned int count, struct sp1_cs *c);
extern void initialiseColourGreenRed(unsigned int count, struct sp1_cs *c);
extern void initialiseColourRedYellowWhiteCyan(unsigned int count, struct sp1_cs *c);
extern void initialiseColourGreen(unsigned int count, struct sp1_cs *c);

#endif

0 comments on commit 8dc038f

Please sign in to comment.