X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fmain.c;h=f690a0e3e763e4f2866de02f9a873bddcac8b8c4;hb=365156a5f69ea9a4dd54a2a86e5dbc20d05621d7;hp=c2192ee2e54ac7bc0db4ed72ecac7d21bdb1ee71;hpb=2c28fb640747244df7009a86df557d22a07ad5b1;p=voxscape diff --git a/src/main.c b/src/main.c index c2192ee..f690a0e 100644 --- a/src/main.c +++ b/src/main.c @@ -6,12 +6,15 @@ #include #include "glfb.h" #include "voxscape.h" +#include "lut.h" enum { - INP_FWD = 1, - INP_BACK = 2, - INP_LEFT = 4, - INP_RIGHT = 8 + INP_FWD = 0x01, + INP_BACK = 0x02, + INP_LEFT = 0x04, + INP_RIGHT = 0x08, + INP_LTURN = 0x10, + INP_RTURN = 0x20 }; int init(void); @@ -29,7 +32,7 @@ int win_width, win_height; unsigned int fb[FB_W * FB_H]; unsigned int input; -int32_t pos[2]; +int32_t pos[2], angle;// = 0x4000; struct voxscape *vox; @@ -59,6 +62,8 @@ int main(int argc, char **argv) int init(void) { + init_lut(); + pos[0] = 512 << 16; pos[1] = 512 << 16; @@ -67,7 +72,7 @@ int init(void) } vox_framebuf(vox, FB_W, FB_H, fb); vox_proj(vox, 45, 1, 200); - vox_view(vox, pos[0], pos[1], 0); + vox_view(vox, pos[0], pos[1], angle); glfb_setup(FB_W, FB_H, GLFB_RGBA32, FB_W * 4); return 0; @@ -79,6 +84,8 @@ void cleanup(void) } #define WALK_SPEED 0x40000 +#define TURN_SPEED 0x100 + void update(void) { if(input & INP_FWD) pos[1] += WALK_SPEED; @@ -86,7 +93,10 @@ void update(void) if(input & INP_LEFT) pos[0] -= WALK_SPEED; if(input & INP_RIGHT) pos[0] += WALK_SPEED; - vox_view(vox, pos[0], pos[1], 0); + if(input & INP_LTURN) angle += TURN_SPEED; + if(input & INP_RTURN) angle -= TURN_SPEED; + + vox_view(vox, pos[0], pos[1], angle); } void display(void) @@ -136,6 +146,12 @@ void keyb(unsigned char key, int x, int y) case 'd': input |= INP_RIGHT; break; + case 'q': + input |= INP_LTURN; + break; + case 'e': + input |= INP_RTURN; + break; default: break; @@ -157,6 +173,12 @@ void keyb_up(unsigned char key, int x, int y) case 'd': input &= ~INP_RIGHT; break; + case 'q': + input &= ~INP_LTURN; + break; + case 'e': + input &= ~INP_RTURN; + break; default: break;