-
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.
- Loading branch information
Showing
8 changed files
with
174 additions
and
33 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
snake_OBJECTS := $(call objs,*) $(call objs,**/*) \ | ||
segment24x32_2 snake_2 sqr8x8_2 | ||
segment24x32_2 snake_2 sqr8x8_2 levels_1 |
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,25 @@ | ||
#include "blob.h" | ||
#include "grid.h" | ||
#include "levels.h" | ||
|
||
#define LEVEL_BYTES (32*32 / 8) | ||
#define OBSTACLE_COLOR (0x7475) | ||
|
||
USEBLOB(levels_1); | ||
|
||
void load_level(uint8_t level) { | ||
clear_grid(); | ||
if(level == 0) return; | ||
|
||
const uint8_t * level_data = BLOB(levels_1) + LEVEL_BYTES * (level - 1); | ||
|
||
for(uint8_t y = 0; y < 32; y++) { | ||
for(uint8_t x = 0; x < 32; x += 8) { | ||
uint8_t b = pgm_read_byte(level_data++); | ||
|
||
for(uint8_t i = 0; i < 8; i++) { | ||
write_cell((point_t){x + i, y}, b >> (7 - i) & 1 ? OBSTACLE_COLOR : 0); | ||
} | ||
} | ||
} | ||
} |
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,11 @@ | ||
#ifndef LEVELS_H_ | ||
#define LEVELS_H_ | ||
|
||
#include <stdint.h> | ||
|
||
/** | ||
* Loads the given level into the grid. | ||
*/ | ||
void load_level(uint8_t level); | ||
|
||
#endif |
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