X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=vrtris;a=blobdiff_plain;f=src%2Fgamescr.c;h=9d156593c4febf73c47fb198e9e6fd2010431c29;hp=d2e021937f00912792e989e92c082678b740c716;hb=96757b3e8d4c7ad71ebcae67c40c5fed14c471ce;hpb=325391b617a3f5a1f17e03598baa66d00715422d diff --git a/src/gamescr.c b/src/gamescr.c index d2e0219..9d15659 100644 --- a/src/gamescr.c +++ b/src/gamescr.c @@ -2,7 +2,9 @@ #include #include #include +#ifdef BUILD_VR #include +#endif #include "opengl.h" #include "game.h" #include "screen.h" @@ -10,6 +12,7 @@ #include "blocks.h" #include "logger.h" #include "gameinp.h" +#include "color.h" int init_starfield(void); void draw_starfield(void); @@ -20,7 +23,7 @@ static void start(void); static void stop(void); static void update(float dt); static void draw(void); -static void draw_block(int block, const int *pos, int rot); +static void draw_block(int block, const int *pos, int rot, float sat, float alpha); static void drawpf(void); static void reshape(int x, int y); static void keyboard(int key, int pressed); @@ -163,6 +166,7 @@ static void stop(void) static void update_input(float dtsec) { +#ifdef BUILD_VR int num_vr_sticks; if((num_vr_sticks = goatvr_num_sticks()) > 0) { @@ -177,6 +181,7 @@ static void update_input(float dtsec) joy_axis[GPAD_LSTICK_Y] = p[1]; } } +#endif /* BUILD_VR */ ginp_bnstate = 0; @@ -302,7 +307,9 @@ static void update(float dtsec) static void draw(void) { - const float lpos[] = {-1, 1, 6, 1}; + static const int nextblk_pos[] = {0, 0}; + static const float lpos[] = {-1, 1, 6, 1}; + float t; glTranslatef(0, 0, -cam_dist); glRotatef(cam_phi, 1, 0, 0); @@ -326,20 +333,41 @@ static void draw(void) drawpf(); if(cur_block >= 0) { - draw_block(cur_block, pos, cur_rot); + draw_block(cur_block, pos, cur_rot, 1.0f, 1.0f); } + glPopMatrix(); + + glPushAttrib(GL_ENABLE_BIT); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glPushMatrix(); + t = (float)time_msec / 1000.0f; + glTranslatef(-PF_COLS / 2 + 0.5 + PF_COLS + 3, PF_ROWS / 2 - 0.5, 0); + glTranslatef(1.5, -1, 0); + glRotatef(cos(t) * 8.0f, 1, 0, 0); + glRotatef(sin(t * 1.2f) * 10.0f, 0, 1, 0); + glTranslatef(-1.5, 1, 0); + draw_block(next_block, nextblk_pos, 0, 0.25f, 0.75f); glPopMatrix(); + + glPopAttrib(); } static const float blkspec[] = {0.85, 0.85, 0.85, 1}; -static void draw_block(int block, const int *pos, int rot) +static void draw_block(int block, const int *pos, int rot, float sat, float alpha) { int i; unsigned char *p = blocks[block][rot]; + float col[4], hsv[3]; + + rgb_to_hsv(blkcolor[block][0], blkcolor[block][1], blkcolor[block][2], + hsv, hsv + 1, hsv + 2); + hsv_to_rgb(hsv[0], hsv[1] * sat, hsv[2], col, col + 1, col + 2); + col[3] = alpha; - glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, blkcolor[block]); + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, col); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, blkspec); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 50.0f);