Skip to content

Commit

Permalink
Add float_blind() and float_pickup()
Browse files Browse the repository at this point in the history
  • Loading branch information
binji committed Aug 30, 2022
1 parent 7512725 commit 852a039
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 35 deletions.
39 changes: 39 additions & 0 deletions src/float.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,21 @@
#include "float.h"

#include "inventory.h"
#include "mob.h"
#include "pickup.h"
#include "sprite.h"

#pragma bank 1

#define MAX_FLOATS 8 /* For now; we'll probably want more */

#define FLOAT_BLIND_X_OFFSET 0xfb
#define TILE_BLIND 0x37

extern const u8 float_pick_type_tiles[];
extern const u8 float_pick_type_start[];
extern const u8 float_pick_type_x_offset[];

extern const u8 float_diff_y[];

OAM_item_t float_sprites[MAX_FLOATS];
Expand All @@ -27,6 +36,36 @@ void float_add(u8 pos, u8 tile) {
}
}

void float_blind(void) {
u8 i, x, y;
x = POS_TO_X(mob_pos[PLAYER_MOB]) + FLOAT_BLIND_X_OFFSET;
y = POS_TO_Y(mob_pos[PLAYER_MOB]);
for (i = 0; i < 3; ++i) {
*next_float++ = y;
*next_float++ = x;
*next_float++ = TILE_BLIND + i;
*next_float++ = FLOAT_FRAMES; // hijack prop for float timer
x += 8;
}
}

void float_pickup(PickupType ptype) {
u8 i;
u8 pos = mob_pos[PLAYER_MOB];
u8 flt_start = float_pick_type_start[ptype];
u8 flt_end = float_pick_type_start[ptype + 1];
u8 x = POS_TO_X(pos) + float_pick_type_x_offset[ptype];
u8 y = POS_TO_Y(pos);

for (i = flt_start; i < flt_end; ++i) {
*next_float++ = y;
*next_float++ = x;
*next_float++ = float_pick_type_tiles[i];
*next_float++ = FLOAT_FRAMES; // hijack prop for float timer
x += 8;
}
}

void float_update(void) {
// Draw float sprites and remove them if timed out
u8 *spr = (u8 *)float_sprites;
Expand Down
5 changes: 3 additions & 2 deletions src/float.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
#define FLOAT_H_

#include "common.h"
#include "pickup.h"

#define FLOAT_FOUND 0xe
#define FLOAT_LOST 0xf

void float_hide(void);
void float_add(u8 pos, u8 tile);
void float_blind(void);
void float_pickup(PickupType);
void float_update(void);

extern u8* next_float;

#endif // FLOAT_H_
36 changes: 3 additions & 33 deletions src/gameplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@
#define MSG_REAPER 0
#define MSG_LEN 18

#define FLOAT_BLIND_X_OFFSET 0xfb

#define TILE_BLIND 0x37
#define TILE_BOOM 0x05

#define TILE_PLAYER_HIT_DMG_DIFF 0x5f
Expand Down Expand Up @@ -79,10 +76,6 @@ static void unfog_neighbors(u8 pos);
static void sight_blind(void);
static void nop_saw_anim(u8 pos);

extern const u8 float_pick_type_tiles[];
extern const u8 float_pick_type_start[];
extern const u8 float_pick_type_x_offset[];

extern const u8 boom_spr_speed[];
extern const u8 boom_spr_anim_speed[];
extern const u16 boom_spr_x[];
Expand Down Expand Up @@ -246,19 +239,7 @@ u8 pass_turn(void) {
if (doblind) {
// Update floor to display recover count instead
inv_display_blind();

// Display float
u8 i, x, y;
x = POS_TO_X(mob_pos[PLAYER_MOB]) + FLOAT_BLIND_X_OFFSET;
y = POS_TO_Y(mob_pos[PLAYER_MOB]);
for (i = 0; i < 3; ++i) {
*next_float++ = y;
*next_float++ = x;
*next_float++ = TILE_BLIND + i;
*next_float++ = FLOAT_FRAMES; // hijack prop for float timer
x += 8;
}

float_blind();
doblind = 0;
} else if (recover) {
if (--recover == 0) {
Expand Down Expand Up @@ -595,7 +576,7 @@ u8 rope(u8 from, u8 to) {
}

void trigger_step(u8 mob) {
u8 pos, tile, ptype, pindex, i, flt_start, flt_end, x, y, teleported;
u8 pos, tile, ptype, pindex, teleported;

teleported = 0;
redo:
Expand Down Expand Up @@ -639,18 +620,7 @@ void trigger_step(u8 mob) {

done:
sfx(sound);
flt_start = float_pick_type_start[ptype];
flt_end = float_pick_type_start[ptype + 1];
x = POS_TO_X(pos) + float_pick_type_x_offset[ptype];
y = POS_TO_Y(pos);

for (i = flt_start; i < flt_end; ++i) {
*next_float++ = y;
*next_float++ = x;
*next_float++ = float_pick_type_tiles[i];
*next_float++ = FLOAT_FRAMES; // hijack prop for float timer
x += 8;
}
float_pickup(ptype);
}

// Expose the exit button for this void region.
Expand Down

0 comments on commit 852a039

Please sign in to comment.