porting back some changes from the GBA version
[voxscape] / src / main.c
index daa03bf..bbe64fd 100644 (file)
@@ -37,7 +37,8 @@ int mouse_x, mouse_y, mwarp, mbstate[3];
 int hfilt = VOX_LINEAR, cfilt = VOX_LINEAR;
 
 unsigned int input;
-int32_t pos[2], angle;
+int32_t pos[2], theta, phi;
+int horizon;
 
 struct voxscape *vox;
 
@@ -80,8 +81,8 @@ int init(void)
        if(!(vox = vox_open("data/height.png", "data/color.png"))) {
                return -1;
        }
-       vox_framebuf(vox, FB_W, FB_H, fb, -1);
-       vox_proj(vox, 45, 1, 300);
+       vox_framebuf(vox, FB_W, FB_H, fb);
+       vox_proj(vox, 140, 45, 1, 300);
        vox_fog(vox, 260, COLOR_HORIZON);
        vox_filter(vox, hfilt, cfilt);
 
@@ -101,11 +102,11 @@ void update(void)
 {
        int32_t fwd[2], right[2];
 
-       if(input & INP_LTURN) angle += TURN_SPEED;
-       if(input & INP_RTURN) angle -= TURN_SPEED;
+       if(input & INP_LTURN) theta += TURN_SPEED;
+       if(input & INP_RTURN) theta -= TURN_SPEED;
 
-       fwd[0] = -SIN(angle);
-       fwd[1] = COS(angle);
+       fwd[0] = -SIN(theta);
+       fwd[1] = COS(theta);
        right[0] = fwd[1];
        right[1] = -fwd[0];
 
@@ -126,7 +127,7 @@ void update(void)
                pos[1] -= right[1];
        }
 
-       vox_view(vox, pos[0], pos[1], -30, angle);
+       vox_view(vox, pos[0], pos[1], -30, theta, phi);
 }
 
 void display(void)
@@ -263,6 +264,9 @@ void motion(int x, int y)
        if(!(dx | dy)) return;
 
        if(mbstate[0]) {
-               angle -= dx << 6;
+               theta -= dx << 6;
+               phi += dy << 8;
+               if(phi < -0x18000) phi = -0x18000;
+               if(phi > 0x18000) phi = 0x18000;
        }
 }