+/* this is the fractional distance toward the peek
+ position to move each frame; lower is slower,
+ 0 is never get there, 1 is instant */
+static const float PEEK_ARRIVE_RATIO = 0.1;
+
+class CameraConfig
+{
+public:
+ // 0 = No, 1 = Fix, 2 = Mario/Yoshi, 3 = Kirby
+ int ymode;
+ // as above, 4 = super metroid like
+ int xmode;
+ float kirby_rectsize_x;
+ float kirby_rectsize_y;
+ // where to fix the player (used for Yoshi and Fix camera)
+ float target_y;
+ float target_x;
+ // maximum scrolling speed in Y direction
+ float max_speed_y;
+ float max_speed_x;
+ // factor to dynamically increase max_speed_x based on player speed
+ float dynamic_max_speed_x;
+
+ // time the player has to face into the other direction before we assume a
+ // changed direction
+ float dirchange_time;
+ // edge_x
+ float edge_x;
+ // when too change from noscroll mode back to lookahead left/right mode
+ // set to <= 0 to disable noscroll mode
+ float sensitive_x;
+
+ float clamp_y;
+ float clamp_x;
+
+ float dynamic_speed_sm;
+
+ CameraConfig() {
+ xmode = 4;
+ ymode = 3;
+ target_x = .5f;
+ target_y = .5f;
+ max_speed_y = 100;
+ max_speed_x = 100;
+ clamp_x = 0.1666f;
+ clamp_y = 0.3f;
+ kirby_rectsize_x = 0.2f;
+ kirby_rectsize_y = 0.34f;
+ edge_x = 0.4f;
+ sensitive_x = -1;
+ dynamic_max_speed_x = 1.0;
+ dirchange_time = 0.2f;
+ dynamic_speed_sm = 0.8f;
+ }
+
+ void load(const std::string& filename)
+ {
+ lisp::Parser parser;
+ const lisp::Lisp* root = parser.parse(filename);
+ const lisp::Lisp* camconfig = root->get_lisp("camera-config");
+ if(camconfig == NULL)
+ throw std::runtime_error("file is not a camera config file.");
+
+ camconfig->get("xmode", xmode);
+ camconfig->get("ymode", ymode);
+ camconfig->get("target-x", target_x);
+ camconfig->get("target-y", target_y);
+ camconfig->get("max-speed-x", max_speed_x);
+ camconfig->get("max-speed-y", max_speed_y);
+ camconfig->get("dynamic-max-speed-x", dynamic_max_speed_x);
+ camconfig->get("dirchange-time", dirchange_time);
+ camconfig->get("clamp-x", clamp_x);
+ camconfig->get("clamp-y", clamp_y);
+ camconfig->get("kirby-rectsize-x", kirby_rectsize_x);
+ camconfig->get("kirby-rectsize-y", kirby_rectsize_y);
+ camconfig->get("edge-x", edge_x);
+ camconfig->get("sensitive-x", sensitive_x);
+ camconfig->get("dynamic-speed-sm", dynamic_speed_sm);
+ }
+};