texture_type img_money_left[2];
texture_type img_money_right[2];
+BadGuyKind badguykind_from_string(const std::string& str)
+{
+ if (str == "money")
+ return BAD_MONEY;
+ else if (str == "laptop")
+ return BAD_LAPTOP;
+ else if (str == "bsod")
+ return BAD_BSOD;
+ else
+ {
+ printf("Couldn't convert badguy: %s\n", str.c_str());
+ return BAD_BSOD;
+ }
+}
+
+std::string badguykind_to_string(BadGuyKind kind)
+{
+ switch(kind)
+ {
+ case BAD_MONEY:
+ return "money";
+ break;
+ case BAD_LAPTOP:
+ return "laptop";
+ break;
+ case BAD_BSOD:
+ return "bsod";
+ break;
+ default:
+ return "bsod";
+ }
+}
+
void
BadGuy::init(float x, float y, BadGuyKind kind_)
{
BAD_MONEY
};
+BadGuyKind badguykind_from_string(const std::string& str);
+std::string badguykind_to_string(BadGuyKind kind);
+
+struct BadGuyData
+{
+ BadGuyKind kind;
+ int x;
+ int y;
+
+ BadGuyData(BadGuyKind kind_, int x_, int y_)
+ : kind(kind_), x(x_), y(y_) {}
+
+ BadGuyData()
+ : kind(BAD_BSOD), x(0), y(0) {}
+};
+
/* Badguy type: */
class BadGuy
{
void activate_bad_guys(void)
{
- int x,y;
+ // Activate badguys the new style
+ for (std::vector<BadGuyData>::iterator i = current_level.badguy_data.begin();
+ i != current_level.badguy_data.end();
+ ++i)
+ {
+ add_bad_guy(i->x, i->y, i->kind);
+ }
- /* Activate bad guys: */
- for (y = 0; y < 15; y++)
+ // FIXME: should be removed;
+ // Activate bad guys the old style
+ for (int y = 0; y < 15; y++)
{
- for (x = 0; x < current_level.width; x++)
+ for (int x = 0; x < current_level.width; x++)
{
if (current_level.ia_tiles[y][x] >= 1000 && current_level.ia_tiles[y][x] <= 1010)
{
reader.read_int_vector("dynamic-tm", &dn_tm);
reader.read_int_vector("foreground-tm", &fg_tm);
+ {
+ lisp_object_t* cur = 0;
+ if (reader.read_lisp("objects", &cur))
+ {
+ while (!lisp_nil_p(cur))
+ {
+ lisp_object_t* data = lisp_car(cur);
+
+ BadGuyData bg_data;
+ bg_data.kind = badguykind_from_string(lisp_symbol(lisp_car(data)));
+ LispReader reader(lisp_cdr(data));
+ reader.read_int("x", &bg_data.x);
+ reader.read_int("y", &bg_data.y);
+
+ plevel->badguy_data.push_back(bg_data);
+
+ cur = lisp_cdr(cur);
+ }
+ }
+ }
+
// Convert old levels to the new tile numbers
if (version == 0)
{
#include <string>
#include "texture.h"
+#include "badguy.h"
#include "lispreader.h"
/* This type holds meta-information about a level-subset. */
#define LEVEL_NAME_MAX 20
-struct st_level
+
+enum {
+ TM_BG,
+ TM_IA,
+ TM_DN,
+ TM_FG
+ };
+
+extern texture_type img_bkgd;
+extern texture_type img_bkgd_tile[2][4];
+extern texture_type img_solid[4];
+extern texture_type img_brick[2];
+
+class st_level
{
+ public:
std::string name;
std::string theme;
std::string song_title;
int bkgd_blue;
int width;
float gravity;
-};
-enum {
- TM_BG,
- TM_IA,
- TM_DN,
- TM_FG
- };
-
-extern texture_type img_bkgd, img_bkgd_tile[2][4], img_solid[4], img_brick[2];
+ std::vector<BadGuyData> badguy_data;
+ public:
+};
void level_default (st_level* plevel);
int level_load (st_level* plevel, const char * subset, int level);
void apply_level_settings_menu()
{
- int i,y,j;
+ int i;
i = false;
le_current_level->name = level_settings_menu->item[2].input;
}
bool
+LispReader::read_lisp(const char* name, lisp_object_t** b)
+{
+ lisp_object_t* obj = search_for (name);
+ if (obj)
+ {
+ *b = obj;
+ return true;
+ }
+ else
+ return false;
+}
+
+bool
LispReader::read_float (const char* name, float* f)
{
lisp_object_t* obj = search_for (name);
bool read_int (const char* name, int* i);
bool read_float (const char* name, float* f);
bool read_bool (const char* name, bool* b);
+ bool read_lisp (const char* name, lisp_object_t** b);
};
/** */