From 29df1d22e0057ae181a51d4aab971963fbda1dbf Mon Sep 17 00:00:00 2001 From: Ingo Ruhnke Date: Wed, 24 Mar 2004 15:24:07 +0000 Subject: [PATCH] - created a named enum for badguys SVN-Revision: 335 --- src/badguy.cpp | 22 +++++++++++----------- src/badguy.h | 21 +++++++++------------ src/gameloop.cpp | 2 +- src/leveleditor.cpp | 2 +- src/scene.cpp | 2 +- src/scene.h | 2 +- 6 files changed, 24 insertions(+), 27 deletions(-) diff --git a/src/badguy.cpp b/src/badguy.cpp index 5d15884da..ad9de9772 100644 --- a/src/badguy.cpp +++ b/src/badguy.cpp @@ -38,20 +38,20 @@ void badguy_create_bitmasks() /*bm_bsod = img_bsod_left[0];*/ } -void badguy_init(bad_guy_type* pbad, float x, float y, int kind) +void badguy_init(bad_guy_type* pbad, float x, float y, BadGuyKind kind) { - pbad->base.width = 32; + pbad->base.width = 32; pbad->base.height = 32; - pbad->mode = NORMAL; - pbad->dying = DYING_NOT; - pbad->kind = kind; - pbad->base.x = x; - pbad->base.y = y; - pbad->base.xm = 1.3; - pbad->base.ym = 4.8; + pbad->mode = NORMAL; + pbad->dying = DYING_NOT; + pbad->kind = kind; + pbad->base.x = x; + pbad->base.y = y; + pbad->base.xm = 1.3; + pbad->base.ym = 4.8; pbad->old_base = pbad->base; - pbad->dir = LEFT; - pbad->seen = false; + pbad->dir = LEFT; + pbad->seen = false; timer_init(&pbad->timer, true); physic_init(&pbad->physic); } diff --git a/src/badguy.h b/src/badguy.h index 678d21522..07034c3c5 100644 --- a/src/badguy.h +++ b/src/badguy.h @@ -22,19 +22,24 @@ #include "collision.h" /* Enemy modes: */ - #define NORMAL 0 #define FLAT 1 #define KICK 2 #define HELD 3 -/* Badguy type: */ +/* Bad guy kinds: */ +enum BadGuyKind { + BAD_BSOD, + BAD_LAPTOP, + BAD_MONEY +}; +/* Badguy type: */ struct bad_guy_type { int mode; DyingType dying; - int kind; + BadGuyKind kind; bool seen; int dir; int frame; @@ -44,14 +49,6 @@ struct bad_guy_type physic_type physic; }; -/* Bad guy kinds: */ - -enum { - BAD_BSOD, - BAD_LAPTOP, - BAD_MONEY -}; - extern texture_type img_bsod_squished_left; extern texture_type img_bsod_squished_right; extern texture_type img_bsod_falling_left; @@ -71,7 +68,7 @@ extern bitmask *bm_bsod; void badguy_create_bitmasks(); -void badguy_init(bad_guy_type* pbad, float x, float y, int kind); +void badguy_init(bad_guy_type* pbad, float x, float y, BadGuyKind kind); void badguy_action(bad_guy_type* pbad); void badguy_draw(bad_guy_type* pbad); diff --git a/src/gameloop.cpp b/src/gameloop.cpp index 357b1ff89..6df7eb75d 100644 --- a/src/gameloop.cpp +++ b/src/gameloop.cpp @@ -108,7 +108,7 @@ void activate_bad_guys(void) { if (current_level.tiles[y][x] >= '0' && current_level.tiles[y][x] <= '9') { - add_bad_guy(x * 32, y * 32, current_level.tiles[y][x] - '0'); + add_bad_guy(x * 32, y * 32, static_cast(current_level.tiles[y][x] - '0')); current_level.tiles[y][x] = '.'; } } diff --git a/src/leveleditor.cpp b/src/leveleditor.cpp index 6bfaa37ac..d69edd330 100644 --- a/src/leveleditor.cpp +++ b/src/leveleditor.cpp @@ -130,7 +130,7 @@ void le_activate_bad_guys(void) for (y = 0; y < 15; ++y) for (x = 0; x < le_current_level->width; ++x) if (le_current_level->tiles[y][x] >= '0' && le_current_level->tiles[y][x] <= '9') - add_bad_guy(x * 32, y * 32, le_current_level->tiles[y][x] - '0'); + add_bad_guy(x * 32, y * 32, static_cast(le_current_level->tiles[y][x] - '0')); } void le_set_defaults() diff --git a/src/scene.cpp b/src/scene.cpp index cceb7ecbd..dcdc038af 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -131,7 +131,7 @@ void add_bouncy_brick(float x, float y) /* Add a bad guy: */ -void add_bad_guy(float x, float y, int kind) +void add_bad_guy(float x, float y, BadGuyKind kind) { bad_guy_type new_bad_guy; badguy_init(&new_bad_guy,x,y,kind); diff --git a/src/scene.h b/src/scene.h index 1dd7b3f8b..e12d48df7 100644 --- a/src/scene.h +++ b/src/scene.h @@ -57,7 +57,7 @@ void add_bouncy_distro(float x, float y); void add_broken_brick(float x, float y); void add_broken_brick_piece(float x, float y, float xm, float ym); void add_bouncy_brick(float x, float y); -void add_bad_guy(float x, float y, int kind); +void add_bad_guy(float x, float y, BadGuyKind kind); void add_upgrade(float x, float y, int dir, int kind); void add_bullet(float x, float y, float xm, int dir); -- 2.11.0