-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from justinorringer/scrolling_dog
Scrolling Dog
- Loading branch information
Showing
11 changed files
with
200 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include <gb/gb.h> | ||
#include <stdbool.h> | ||
|
||
// ~40% of the screen width | ||
UINT8 gameplay_x = 55; | ||
|
||
// pass in sprites to move them with the background | ||
bool scroll(UINT8 player_x, UINT8 x_mod, UINT8 y_mod, UINT8 *level_left, UINT8 *scrolled) { | ||
if (x_mod <= 0) { | ||
return false; | ||
} | ||
|
||
if (player_x < gameplay_x) { | ||
return false; | ||
} | ||
|
||
if (*level_left <= 0) { | ||
return false; | ||
} | ||
|
||
// decrement level_left by x_mod | ||
*level_left = *level_left - x_mod; | ||
*scrolled = *scrolled + x_mod; | ||
|
||
scroll_bkg(x_mod, y_mod); | ||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#include <gb/gb.h> | ||
#include <stdbool.h> | ||
|
||
bool scroll(UINT8 player_x, UINT8 x_mod, UINT8 y_mod, UINT8 *level_left, UINT8 *scrolled); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include <gb/gb.h> | ||
|
||
// This will be used for bosses and the character | ||
struct Large { | ||
UBYTE sprite_id[4]; | ||
UINT8 x; | ||
UINT8 y; | ||
UINT8 width; | ||
UINT8 height; | ||
}; | ||
|
||
typedef struct Large Large; | ||
|
||
void move_large(Large *large, UINT8 x, UINT8 y) { | ||
large->x = x; | ||
large->y = y; | ||
|
||
move_sprite(large->sprite_id[0], large->x, large->y); | ||
move_sprite(large->sprite_id[1], large->x, large->y + 8); | ||
move_sprite(large->sprite_id[2], large->x + 8, large->y); | ||
move_sprite(large->sprite_id[3], large->x + 8, large->y + 8); | ||
} | ||
|
||
void init_large(Large *large, UBYTE *sprite_ids, UINT8 x, UINT8 y, UINT8 width, UINT8 height) { | ||
large->sprite_id[0] = sprite_ids[0]; | ||
large->sprite_id[1] = sprite_ids[1]; | ||
large->sprite_id[2] = sprite_ids[2]; | ||
large->sprite_id[3] = sprite_ids[3]; | ||
large->x = x; | ||
large->y = y; | ||
large->width = width; | ||
large->height = height; | ||
|
||
set_sprite_tile(large->sprite_id[0], large->sprite_id[0]); | ||
set_sprite_tile(large->sprite_id[1], large->sprite_id[1]); | ||
set_sprite_tile(large->sprite_id[2], large->sprite_id[2]); | ||
set_sprite_tile(large->sprite_id[3], large->sprite_id[3]); | ||
|
||
move_large(large, large->x, large->y); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include <gb/gb.h> | ||
|
||
typedef struct { | ||
UBYTE sprite_id[4]; | ||
UINT8 x; | ||
UINT8 y; | ||
UINT8 width; | ||
UINT8 height; | ||
} Large; | ||
|
||
void init_large(Large *large, UBYTE *sprite_ids, UINT8 x, UINT8 y, UINT8 width, UINT8 height); | ||
void move_large(Large *large, UINT8 x, UINT8 y); |
Oops, something went wrong.