projects
/
hackover2013-badge-firmware.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
2fb9f70
)
Bugfix: Kollisionsprüfung am oberen Bildschirmrand, bzw. allgemein Koordinaten-
author
Wintermute
<wintermute@hannover.ccc.de>
Thu, 17 Oct 2013 17:44:15 +0000
(19:44 +0200)
committer
Wintermute
<wintermute@hannover.ccc.de>
Thu, 17 Oct 2013 17:44:15 +0000
(19:44 +0200)
umwandlung bei y < 0.
badge/jumpnrun/collision.c
patch
|
blob
|
history
badge/jumpnrun/jumpnrun.h
patch
|
blob
|
history
badge/jumpnrun/levels.txt
patch
|
blob
|
history
badge/jumpnrun/moveable.h
patch
|
blob
|
history
badge/util/fixed_point.h
patch
|
blob
|
history
diff --git
a/badge/jumpnrun/collision.c
b/badge/jumpnrun/collision.c
index
34ab099
..
2b946f2
100644
(file)
--- a/
badge/jumpnrun/collision.c
+++ b/
badge/jumpnrun/collision.c
@@
-1,9
+1,9
@@
#include "collision.h"
void collision_displace(vec2d *desired_pos,
#include "collision.h"
void collision_displace(vec2d *desired_pos,
- jumpnrun_moveable *current,
- rectangle const *obstacle,
- vec2d *inertia_mod) {
+
jumpnrun_moveable *current,
+
rectangle const *obstacle,
+
vec2d *inertia_mod) {
rectangle desired = current->current_box;
rectangle_move_to(&desired, *desired_pos);
rectangle desired = current->current_box;
rectangle_move_to(&desired, *desired_pos);
@@
-23,8
+23,8
@@
void collision_displace(vec2d *desired_pos,
dy = rectangle_bottom(obstacle);
} else if(fixed_point_gt(rectangle_bottom( obstacle), rectangle_bottom(&desired)) &&
dy = rectangle_bottom(obstacle);
} else if(fixed_point_gt(rectangle_bottom( obstacle), rectangle_bottom(&desired)) &&
- fixed_point_le(rectangle_top ( obstacle), rectangle_bottom(&desired)) &&
- fixed_point_gt(rectangle_top (&desired ), rectangle_top (¤t->current_box))) {
+
fixed_point_le(rectangle_top ( obstacle), rectangle_bottom(&desired)) &&
+
fixed_point_gt(rectangle_top (&desired ), rectangle_top (¤t->current_box))) {
y = fixed_point_sub(rectangle_bottom(&desired ), rectangle_top ( obstacle));
dy = fixed_point_sub(rectangle_top ( obstacle), rectangle_height(&desired ));
y = fixed_point_sub(rectangle_bottom(&desired ), rectangle_top ( obstacle));
dy = fixed_point_sub(rectangle_top ( obstacle), rectangle_height(&desired ));
@@
-32,7
+32,6
@@
void collision_displace(vec2d *desired_pos,
}
}
-
if(fixed_point_le(rectangle_left ( obstacle), rectangle_left(&desired)) &&
fixed_point_gt(rectangle_right( obstacle), rectangle_left(&desired)) &&
fixed_point_lt(rectangle_left (&desired ), rectangle_left(¤t->current_box))) {
if(fixed_point_le(rectangle_left ( obstacle), rectangle_left(&desired)) &&
fixed_point_gt(rectangle_right( obstacle), rectangle_left(&desired)) &&
fixed_point_lt(rectangle_left (&desired ), rectangle_left(¤t->current_box))) {
@@
-41,8
+40,8
@@
void collision_displace(vec2d *desired_pos,
dx = rectangle_right(obstacle);
} else if(fixed_point_gt(rectangle_right( obstacle), rectangle_right(&desired)) &&
dx = rectangle_right(obstacle);
} else if(fixed_point_gt(rectangle_right( obstacle), rectangle_right(&desired)) &&
- fixed_point_le(rectangle_left ( obstacle), rectangle_right(&desired)) &&
- fixed_point_gt(rectangle_left (&desired ), rectangle_left (¤t->current_box))) {
+
fixed_point_le(rectangle_left ( obstacle), rectangle_right(&desired)) &&
+
fixed_point_gt(rectangle_left (&desired ), rectangle_left (¤t->current_box))) {
x = fixed_point_sub(rectangle_right(&desired ), rectangle_left ( obstacle));
dx = fixed_point_sub(rectangle_left ( obstacle), rectangle_width(&desired ));
x = fixed_point_sub(rectangle_right(&desired ), rectangle_left ( obstacle));
dx = fixed_point_sub(rectangle_left ( obstacle), rectangle_width(&desired ));
@@
-66,14
+65,14
@@
void collision_displace(vec2d *desired_pos,
}
void collisions_tiles_displace(vec2d *desired_position,
}
void collisions_tiles_displace(vec2d *desired_position,
- jumpnrun_moveable *thing,
- jumpnrun_level const *lv,
- jumpnrun_tile_range const *visible_tiles,
- vec2d *inertia_mod)
+
jumpnrun_moveable *thing,
+
jumpnrun_level const *lv,
+
jumpnrun_tile_range const *visible_tiles,
+
vec2d *inertia_mod)
{
int collision_tile[] = { -1, -1, -1,
{
int collision_tile[] = { -1, -1, -1,
- -1, -1, -1,
- -1, -1, -1
+
-1, -1, -1,
+
-1, -1, -1
};
static int const collision_order[] = { 7, 1, 3, 5, 6, 8, 0, 2 };
};
static int const collision_order[] = { 7, 1, 3, 5, 6, 8, 0, 2 };
@@
-94,32
+93,32
@@
void collisions_tiles_displace(vec2d *desired_position,
switch(xdiff) {
case -1:
switch(xdiff) {
case -1:
- {
- switch(ydiff) {
- case -1: collision_tile[0] = tile; break;
- case 0: collision_tile[1] = tile; break;
- case 1: collision_tile[2] = tile; break;
- }
- break;
+ {
+ switch(ydiff) {
+ case -1: collision_tile[0] = tile; break;
+ case 0: collision_tile[1] = tile; break;
+ case 1: collision_tile[2] = tile; break;
}
}
+ break;
+ }
case 0:
case 0:
- {
- switch(ydiff) {
- case -1: collision_tile[3] = tile; break;
- case 0: collision_tile[4] = tile; break;
- case 1: collision_tile[5] = tile; break;
- }
- break;
+ {
+ switch(ydiff) {
+ case -1: collision_tile[3] = tile; break;
+ case 0: collision_tile[4] = tile; break;
+ case 1: collision_tile[5] = tile; break;
}
}
+ break;
+ }
case 1:
case 1:
- {
- switch(ydiff) {
- case -1: collision_tile[6] = tile; break;
- case 0: collision_tile[7] = tile; break;
- case 1: collision_tile[8] = tile; break;
- }
- break;
+ {
+ switch(ydiff) {
+ case -1: collision_tile[6] = tile; break;
+ case 0: collision_tile[7] = tile; break;
+ case 1: collision_tile[8] = tile; break;
}
}
+ break;
+ }
}
}
}
}
@@
-130,7
+129,7
@@
void collisions_tiles_displace(vec2d *desired_position,
if(collision_tile[collision_order[collision_index]] == -1) {
continue;
}
if(collision_tile[collision_order[collision_index]] == -1) {
continue;
}
-
+
rectangle tile_rect = rect_from_tile(&lv->tiles[collision_tile[collision_order[collision_index]]]);
collision_displace(desired_position, thing, &tile_rect, inertia_mod);
rectangle tile_rect = rect_from_tile(&lv->tiles[collision_tile[collision_order[collision_index]]]);
collision_displace(desired_position, thing, &tile_rect, inertia_mod);
diff --git
a/badge/jumpnrun/jumpnrun.h
b/badge/jumpnrun/jumpnrun.h
index
2437c36
..
0ce9ad6
100644
(file)
--- a/
badge/jumpnrun/jumpnrun.h
+++ b/
badge/jumpnrun/jumpnrun.h
@@
-29,7
+29,6
@@
typedef struct jumpnrun_game_state {
uint8_t status;
int left;
uint8_t status;
int left;
- uint8_t anim_direction;
size_t spawned_enemies_counter;
size_t spawned_enemies[JUMPNRUN_MAX_SPAWNED_ENEMIES];
size_t spawned_enemies_counter;
size_t spawned_enemies[JUMPNRUN_MAX_SPAWNED_ENEMIES];
diff --git
a/badge/jumpnrun/levels.txt
b/badge/jumpnrun/levels.txt
index
c6bfbe0
..
6db22ac
100644
(file)
--- a/
badge/jumpnrun/levels.txt
+++ b/
badge/jumpnrun/levels.txt
@@
-1,4
+1,4
@@
-smb
foo
foo
+smb
gnobbel
mean
gnobbel
mean
diff --git
a/badge/jumpnrun/moveable.h
b/badge/jumpnrun/moveable.h
index
284d2bb
..
5e7514b
100644
(file)
--- a/
badge/jumpnrun/moveable.h
+++ b/
badge/jumpnrun/moveable.h
@@
-7,7
+7,7
@@
typedef struct jumpnrun_moveable {
rectangle current_box;
vec2d inertia;
rectangle current_box;
vec2d inertia;
- uint8_t tick_minor;
+ uint8_t
tick_minor;
uint8_t anim_frame;
uint8_t anim_direction;
uint8_t anim_frame;
uint8_t anim_direction;
diff --git
a/badge/util/fixed_point.h
b/badge/util/fixed_point.h
index
49bfa7c
..
43c7bf0
100644
(file)
--- a/
badge/util/fixed_point.h
+++ b/
badge/util/fixed_point.h
@@
-26,13
+26,16
@@
static inline bool fixed_point_ne(fixed_point x, fixed_point y) { return x.data
#define FIXED_INT_I(x) FIXED_POINT_I(x, 0)
static inline fixed_point FIXED_POINT(int32_t x, int32_t y) {
#define FIXED_INT_I(x) FIXED_POINT_I(x, 0)
static inline fixed_point FIXED_POINT(int32_t x, int32_t y) {
- fixed_point r =
{ (x * 256) + (y * 256 / 1000) }
;
+ fixed_point r =
FIXED_POINT_I(x, y)
;
return r;
}
static inline fixed_point FIXED_INT(int32_t x) { return FIXED_POINT(x, 0); }
return r;
}
static inline fixed_point FIXED_INT(int32_t x) { return FIXED_POINT(x, 0); }
-static inline int fixed_point_cast_int(fixed_point x) { return x.data / 256; }
+// sign bit is shifted in if x.data < 0, so this is x.data / 256 - (x.data < 0).
+// This means 0.123 is cast to 1, which is what we want when we cast a model coordinate
+// to a screen coordinate.
+static inline int fixed_point_cast_int(fixed_point x) { return x.data >> 8; }
static inline fixed_point fixed_point_min(fixed_point x, fixed_point y) { return fixed_point_lt(x, y) ? x : y; }
static inline fixed_point fixed_point_max(fixed_point x, fixed_point y) { return fixed_point_gt(x, y) ? x : y; }
static inline fixed_point fixed_point_min(fixed_point x, fixed_point y) { return fixed_point_lt(x, y) ? x : y; }
static inline fixed_point fixed_point_max(fixed_point x, fixed_point y) { return fixed_point_gt(x, y) ? x : y; }
This page took
0.038845 seconds
and
4
git commands to generate.