Giraffe verfolgt Spieler.
authorWintermute <wintermute@hannover.ccc.de>
Fri, 18 Oct 2013 16:02:21 +0000 (18:02 +0200)
committerWintermute <wintermute@hannover.ccc.de>
Fri, 18 Oct 2013 16:02:21 +0000 (18:02 +0200)
badge/jumpnrun/enemies.c
badge/jumpnrun/foo.lv
badge/jumpnrun/levels.txt
badge/jumpnrun/tiles.h
badge/util/rectangle.h
mock/tools/level-converter.cc

index 407f091..a38976d 100644 (file)
@@ -420,11 +420,10 @@ void enemy_tick_giraffe(jumpnrun_enemy            *self,
     if(was_on_ground) {
       enemy_animation_advance(self);
       if(self->base.anim_frame == 0) {
-        if(self->flags & JUMPNRUN_ENEMY_FACING_RIGHT) {
-          self->base.inertia.x = fixed_point_neg(self->type->spawn_inertia.x);
-          self->base.inertia.y = self->type->spawn_inertia.y;
-        } else {
-          self->base.inertia = self->type->spawn_inertia;
+        self->base.inertia = self->type->spawn_inertia;
+
+        if(fixed_point_gt(rectangle_mid_x(&state->player.current_box), rectangle_mid_x(enemy_box(self)))) {
+          self->base.inertia.x = fixed_point_neg(self->base.inertia.x);
         }
       }
     } else {
index b4cf314..477dd25 100644 (file)
@@ -1,4 +1,4 @@
-                                  #############                                                                                                                                                                                          
+                                  ##################################################################################################################################################################################################
                                 ##                                                                                                                                                                                                       
                               ##                                                                                                                                                                                                         
                             ##                                                                                                                                                                                                           
@@ -6,8 +6,8 @@
                         ##                                                                                                                                                                                                               
                       01                                                                                                                                                                                                                 
                       23                                                                                                                                                                                                                 
-                      23                                                                                                                                                                                                                 
-                      23                                                                                                                                                                                                                 
+              ##      23                                                                                                                                                                                                                 
+           ###        23                                                                                                                                                                                                                 
   P                 M 23                                                                                                                                                                                                           D     
                       23                                                                                                                                                                                                                 
 #########################################################################################################################################################################################################################################
index cc57bcc..035b5d7 100644 (file)
@@ -1,5 +1,5 @@
 smb
-wrongturn
 foo
+wrongturn
 gnobbel
 mean
index 8010e11..f0cde4b 100644 (file)
@@ -20,8 +20,8 @@ enum {
 };
 
 typedef struct jumpnrun_tile_position {
-  uint16_t x;
-  uint8_t  y;
+  int16_t x;
+  int8_t  y;
 } jumpnrun_tile_position;
 
 typedef struct jumpnrun_tile_type {
index 4e352f0..4fe5c0e 100644 (file)
@@ -40,12 +40,10 @@ static inline fixed_point rectangle_right (rectangle const *r) { return fixed_po
 static inline fixed_point rectangle_width (rectangle const *r) { return r->extent.x; }
 static inline fixed_point rectangle_height(rectangle const *r) { return r->extent.y; }
 
-static inline vec2d rectangle_mid(rectangle const *r) {
-  vec2d v = { fixed_point_add(r->pos.x, fixed_point_div(r->extent.x, FIXED_POINT(2, 0))),
-             fixed_point_add(r->pos.y, fixed_point_div(r->extent.y, FIXED_POINT(2, 0)))
-  };
-  return v;
-}
+static inline fixed_point rectangle_mid_x (rectangle const *r) { return fixed_point_add(r->pos.x, fixed_point_div(r->extent.x, FIXED_INT(2))); }
+static inline fixed_point rectangle_mid_y (rectangle const *r) { return fixed_point_add(r->pos.y, fixed_point_div(r->extent.y, FIXED_INT(2))); }
+
+static inline vec2d       rectangle_mid   (rectangle const *r) { vec2d v = { rectangle_mid_x(r), rectangle_mid_y(r) }; return v; }
 
 static inline void rectangle_move_to  (rectangle *r, vec2d       new_pos) { r->pos = new_pos; }
 static inline void rectangle_move_to_x(rectangle *r, fixed_point new_x  ) { r->pos.x = new_x; }
@@ -55,11 +53,11 @@ static inline void rectangle_move_rel (rectangle *r, vec2d       vec    ) { r->p
 static inline void rectangle_expand   (rectangle *r, vec2d       extent ) { r->extent = extent; }
 
 static inline bool rectangle_intersect(rectangle const *r1,
-                                      rectangle const *r2) {
+                                       rectangle const *r2) {
   return (fixed_point_lt(rectangle_top   (r1), rectangle_bottom(r2)) &&
-         fixed_point_gt(rectangle_bottom(r1), rectangle_top   (r2)) &&
-         fixed_point_lt(rectangle_left  (r1), rectangle_right (r2)) &&
-         fixed_point_gt(rectangle_right (r1), rectangle_left  (r2)));
+          fixed_point_gt(rectangle_bottom(r1), rectangle_top   (r2)) &&
+          fixed_point_lt(rectangle_left  (r1), rectangle_right (r2)) &&
+          fixed_point_gt(rectangle_right (r1), rectangle_left  (r2)));
 }
 
 #endif
index f54b589..7f67732 100644 (file)
@@ -18,7 +18,7 @@ extern "C" {
 #include <vector>
 
 enum {
-  LEVEL_LINE_COUNT = 13
+  LEVEL_LINE_COUNT = 14
 };
 
 #define PATH_PREFIX "../badge/jumpnrun/"
@@ -176,7 +176,7 @@ namespace jnrcpp {
 
           if(iter != objmap.end()) {
             unsigned char buf[3];
-            buf[0] = static_cast<uint8_t>(y + 1) << 4 | static_cast<uint8_t>(x >> 8);
+            buf[0] = static_cast<uint8_t>(y) << 4 | static_cast<uint8_t>(x >> 8);
             buf[1] = static_cast<uint8_t>(x);
             buf[2] = static_cast<uint8_t>(find_type(types, iter->second, error));
 
This page took 0.029183 seconds and 4 git commands to generate.