#include #include #include "exception.h" #include "bullet.h" #include "parse.h" using namespace JFK; using std::string; bullet::bullet(int itype) : type(itype) { } string bullet::tostring() const { std::ostringstream oss; oss << "x=" << x << " y=" << y << " dx=" << dx << " dy=" << dy << " v=" << v << " type=" << type; return oss.str(); } void bullet::fromstring(const string& s) { int index=0; string arg = argument(0, s); while (arg.length() > 0) { string id = identifier(arg); if (id == "x") x = strtodbl(value(arg)); else if (id == "y") y = strtodbl(value(arg)); else if (id == "dx") dx = strtodbl(value(arg)); else if (id == "dy") dy = strtodbl(value(arg)); else if (id == "v") v = strtodbl(value(arg)); else if (id == "type") type = strtoint(value(arg)); // else throw exception("wrong string"); ignore better... index++; arg = argument(index, s); } } string bullet::classname() const { return "bullet"; }