static bool keystate[256];
static bool gpad_bnstate[64];
static Vec2 joy_move, joy_look;
-static float joy_deadzone = 0.01;
+static float joy_deadzone = 0.1;
static float framerate;
jlook_lensq -= jdeadsq;
float mag = len * len;
- avatar.body_rot += mag * joy_look.x / len * 200.0 * dt;
+
+ if(opt.min_turn > 0.0f) {
+ static long last_turn;
+ if(len > 0.5 && time_msec - last_turn > 350) {
+ float sign = joy_look.x > 0.0f ? 1.0f : -1.0f;
+ avatar.body_rot += opt.min_turn * sign;
+ last_turn = time_msec;
+ }
+ } else {
+ avatar.body_rot += mag * joy_look.x / len * 200.0 * dt;
+ }
+
avatar.head_alt += mag * joy_look.y / len * 100.0 * dt;
if(avatar.head_alt < -90.0f) avatar.head_alt = -90.0f;
if(avatar.head_alt > 90.0f) avatar.head_alt = 90.0f;
0, // scene file
true, // music
true, // reflections
- 0 // data url
+ 0, // data url
+ 0.0f // minimum turn angle
};
enum {
OPT_MUSIC,
OPT_REFLECT,
OPT_DATAURL,
+ OPT_MIN_TURN,
OPT_HELP
};
{'m', "music", OPT_MUSIC, "play background audio"},
{'r', "reflect", OPT_REFLECT, "render reflections"},
{0, "url", OPT_DATAURL, "data URL"},
+ {0, "minturn", OPT_MIN_TURN, "minimum turn angle"},
{'h', "help", OPT_HELP, "print usage and exit"},
OPTCFG_OPTIONS_END
};
opt.data_url = strdup(optcfg_next_value(oc));
break;
+ case OPT_MIN_TURN:
+ {
+ int deg;
+ char *valstr = optcfg_next_value(oc);
+
+ if(!valstr || sscanf(valstr, "%d", °) != 1) {
+ fprintf(stderr, "minimum turn must be a number >= 0 in degrees\n");
+ return -1;
+ }
+ opt.min_turn = deg;
+ }
+ break;
+
case OPT_HELP:
printf("Usage: demo [options]\nOptions:\n");
optcfg_print_options(oc);