Skip to content

Commit 11f6381

Browse files
committed
input: use joystick for moving, pointer for rotation
Implement a control style a la "The Conduit", where the pointer is used to rotate the camera, and the joystick is used for moving. This still needs some work (we probably want to show a small pointer on the Wii screen, because currently it's hard to know where exactly you are pointing at), but should give an idea. Having playing "The COnduit" for a while, this feels much more natural to me. This depends on xtreme8000#17 in order to be tested on the PC. Addresses issue xtreme8000#1.
1 parent 998a727 commit 11f6381

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

source/game/camera.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,25 @@ void camera_ray_pick(struct world* w, float gx0, float gy0, float gz0,
104104
void camera_physics(struct camera* c, float dt) {
105105
assert(c);
106106

107-
float jdx, jdy;
108-
if(input_joystick(dt, &jdx, &jdy)) {
109-
c->rx -= jdx * 2.0F;
110-
c->ry -= jdy * 2.0F;
107+
float px, py, pangle;
108+
const float rotation_c = 20.0F;
109+
if(input_pointer(&px, &py, &pangle)) {
110+
c->rx -= (px - gfx_width() / 2) / (gfx_width() * rotation_c);
111+
c->ry += (py - gfx_height() / 2) / (gfx_height() * rotation_c);
112+
// pangle could be used for rz, but that would be veeery weird :-)
111113
}
112114

113115
float acc_x = 0, acc_y = 0, acc_z = 0;
114116
float speed_c = 40.0F;
117+
118+
float jdx, jdy;
119+
if(input_joystick(dt, &jdx, &jdy)) {
120+
float joy_speed_c = 40.0F * speed_c;
121+
acc_x += (cos(c->rx) * -jdx + sin(c->rx) * sin(c->ry) * jdy) * joy_speed_c;
122+
acc_y += cos(c->ry) * jdy * speed_c;
123+
acc_z += (sin(c->rx) * jdx + cos(c->rx) * sin(c->ry) * jdy) * joy_speed_c;
124+
}
125+
115126
float air_friction = 0.05F;
116127

117128
if(input_held(IB_LEFT)) {

source/game/gui/screen_ingame.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include <malloc.h>
3131

3232
static void screen_ingame_reset(struct screen* s, int width, int height) {
33-
input_pointer_enable(false);
33+
input_pointer_enable(true);
3434
}
3535

3636
void screen_ingame_render3D(struct screen* s, mat4 view) {

0 commit comments

Comments
 (0)