projects
/
hackover2013-badge-firmware.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
jumprun_tile als packed struct für mehr Speicher.
[hackover2013-badge-firmware.git]
/
badge
/
jumpnrun
/
level_load.c
diff --git
a/badge/jumpnrun/level_load.c
b/badge/jumpnrun/level_load.c
index
4b1e499
..
a386ecf
100644
(file)
--- a/
badge/jumpnrun/level_load.c
+++ b/
badge/jumpnrun/level_load.c
@@
-11,8
+11,8
@@
#include <stdio.h>
typedef struct {
#include <stdio.h>
typedef struct {
- uint
8_t
x;
- uint
16_t
y;
+ uint
16_t
x;
+ uint
8_t
y;
uint8_t type;
} level_thing;
uint8_t type;
} level_thing;
@@
-20,7
+20,7
@@
static level_thing jumpnrun_level_parse_blob(unsigned char blob[3]) {
level_thing result;
result.y = blob[0] >> 4;
level_thing result;
result.y = blob[0] >> 4;
- result.x = ((blob[0] & 0xf) << 8) | blob[1];
+ result.x = ((blob[0] & 0x
0
f) << 8) | blob[1];
result.type = blob[2];
return result;
result.type = blob[2];
return result;
@@
-51,8
+51,8
@@
static void jumpnrun_level_make_enemy(jumpnrun_enemy *dest, level_thing thing) {
dest->type = &jumpnrun_enemy_type_data[thing.type];
dest->type = &jumpnrun_enemy_type_data[thing.type];
- dest->spawn_pos.x = FIXED_
POINT( thing.x * JUMPNRUN_TILE_PIXEL_WIDTH , 0
);
- dest->spawn_pos.y = FIXED_
POINT((thing.y + 1) * JUMPNRUN_TILE_PIXEL_HEIGHT - dest->type->animation_frames[0].height, 0
);
+ dest->spawn_pos.x = FIXED_
INT( thing.x * JUMPNRUN_TILE_PIXEL_WIDTH + fixed_point_cast_int(dest->type->hitbox.pos.x)
);
+ dest->spawn_pos.y = FIXED_
INT((thing.y + 1) * JUMPNRUN_TILE_PIXEL_HEIGHT - fixed_point_cast_int(dest->type->hitbox.extent.y)
);
jumpnrun_enemy_despawn(dest);
}
jumpnrun_enemy_despawn(dest);
}
@@
-100,6
+100,14
@@
int jumpnrun_load_level_from_file(jumpnrun_level *dest, FIL *fd) {
dest->start_pos.y = FIXED_INT( spos[1] * JUMPNRUN_TILE_PIXEL_HEIGHT);
}
dest->start_pos.y = FIXED_INT( spos[1] * JUMPNRUN_TILE_PIXEL_HEIGHT);
}
+#ifdef __linux__
+ if(1 != fread(&dest->start_lives, 1, 1, fd)) {
+#else
+ if(FR_OK != f_read(fd, &dest->start_lives, sizeof(dest->start_lives), &count) || count != sizeof(dest->start_lives)) {
+#endif
+ return JUMPNRUN_LEVEL_LOAD_ERROR;
+ }
+
for(i = 0; i < dest->header.tile_count; ++i) {
#ifdef __linux__
if(1 != fread(buf, 3, 1, fd)) {
for(i = 0; i < dest->header.tile_count; ++i) {
#ifdef __linux__
if(1 != fread(buf, 3, 1, fd)) {
This page took
0.040603 seconds
and
4
git commands to generate.