diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game.c | 2 | ||||
-rw-r--r-- | src/main.c | 13 | ||||
-rw-r--r-- | src/physics.c | 7 | ||||
-rw-r--r-- | src/render.c | 22 | ||||
-rw-r--r-- | src/types.h | 3 |
5 files changed, 34 insertions, 13 deletions
@@ -245,6 +245,8 @@ Game *game_new(int width, int height) { g->frames = 0; g->t_fps = SDL_GetTicks(); g->fps = 0; + g->fuel = 1.0; + g->radiation = 0.0; /* Renderer setup */ g->render = render_setup(width, height); @@ -32,6 +32,8 @@ typedef enum { RES_640, RES_800, RES_1280, + RES_1330W, + RES_1440W, RES_1600W } ScreenResolution; @@ -58,6 +60,8 @@ int main(int argc, char *argv[]) { if ( strcasecmp(optarg, "640") == 0 ) res = RES_640; if ( strcasecmp(optarg, "800") == 0 ) res = RES_800; if ( strcasecmp(optarg, "1280") == 0 ) res = RES_1280; + if ( strcasecmp(optarg, "1330W") == 0 ) res = RES_1330W; + if ( strcasecmp(optarg, "1440W") == 0 ) res = RES_1440W; if ( strcasecmp(optarg, "1600W") == 0 ) res = RES_1600W; break; } @@ -77,6 +81,8 @@ int main(int argc, char *argv[]) { printf(" 640 - 640 x 480\n"); printf(" 800 - 800 x 600\n"); printf(" 1280 - 1280 x 1024\n"); + printf("1330W - 1330 x 900 (widescreen)\n"); + printf("1440W - 1440 x 900 (widescreen)\n"); printf("1600W - 1600 x 1050 (widescreen)\n"); return 0; } @@ -101,6 +107,8 @@ int main(int argc, char *argv[]) { case RES_640 : { width = 640; height = 480; break; } case RES_800 : { width = 800; height = 600; break; } case RES_1280 : { width = 1280; height = 1024; break; } + case RES_1330W : { width = 1330; height = 900; break; } + case RES_1440W : { width = 1440; height = 900; break; } case RES_1600W : { width = 1680; height = 1050; break; } default : { assert(this_point_not_reached); break; } } @@ -124,8 +132,9 @@ int main(int argc, char *argv[]) { while ( !finished ) { /* Timer advances only when game is not paused */ - if ( !game->paused ) { - t = SDL_GetTicks(); + t = SDL_GetTicks(); + if ( game->paused ) { + game->tlast = t; } SDL_PollEvent(&event); diff --git a/src/physics.c b/src/physics.c index 9fa77da..76ddf7d 100644 --- a/src/physics.c +++ b/src/physics.c @@ -97,7 +97,10 @@ void physics_step(Game *game, Uint32 t) { /* Handle things specific to the lander craft */ if ( game->thrusting ) { - game->lander->vz += THRUST * dt; + if ( game->fuel > 0.0 ) { + game->lander->vz += THRUST * dt; + game->fuel -= 0.0002; + } } if ( game->forward ) { game->lander->vx += sinf(game->lander->yaw) * FTHRUST * dt; @@ -134,8 +137,6 @@ void physics_step(Game *game, Uint32 t) { } - //game->view_angle = deg2rad(30.0 - 30.0 * game->lander->vz/0.015); - game->tlast = t; } diff --git a/src/render.c b/src/render.c index 105d206..c6e8079 100644 --- a/src/render.c +++ b/src/render.c @@ -143,6 +143,7 @@ static GLenum render_gltype(PrimitiveType type) { switch ( type ) { case PRIMITIVE_QUADS : return GL_QUADS; case PRIMITIVE_TRIANGLES : return GL_TRIANGLES; + default : break; } return GL_FALSE; @@ -285,9 +286,10 @@ static void render_setup_lighting(Game *game) { } -static void render_draw_2d(RenderContext *r) { +static void render_draw_2d(RenderContext *r, Game *game) { Texture *texture; + GLfloat cr, cg, cb; /* Set up transforms for 2D rendering */ glClear(GL_DEPTH_BUFFER_BIT); @@ -319,13 +321,14 @@ static void render_draw_2d(RenderContext *r) { glDisable(GL_TEXTURE_2D); /* Radiation meter */ + cg = 1.0 - game->radiation; glBegin(GL_QUADS); glColor4f(1.0, 1.0, 0.0, 0.5); glVertex2f(-1.0, -0.8); /* Bottom left */ glVertex2f(-0.9, -0.8); /* Bottom right */ - glColor4f(1.0, 0.0, 0.0, 0.5); - glVertex2f(-0.9, 1.0); /* Top right */ - glVertex2f(-1.0, 1.0); /* Top left */ + glColor4f(0.8, cg, 0.0, game->radiation); + glVertex2f(-0.9, -0.8+(1.8*game->radiation)); /* Top right */ + glVertex2f(-1.0, -0.8+(1.8*game->radiation)); /* Top left */ glEnd(); /* Fuel symbol */ @@ -349,13 +352,16 @@ static void render_draw_2d(RenderContext *r) { glDisable(GL_TEXTURE_2D); /* Fuel meter */ + cr = 1.0 - game->fuel; + cg = game->fuel; + cb = 0.2 + 0.1*game->fuel; glBegin(GL_QUADS); glColor4f(1.0, 0.0, 0.2, 0.5); glVertex2f(0.9, -0.8); /* Bottom left */ glVertex2f(1.0, -0.8); /* Bottom right */ - glColor4f(0.0, 1.0, 0.3, 0.5); - glVertex2f(1.0, 1.0); /* Top right */ - glVertex2f(0.9, 1.0); /* Top left */ + glColor4f(cr, cg, cb, 0.5); + glVertex2f(1.0, -0.8+(1.8*game->fuel)); /* Top right */ + glVertex2f(0.9, -0.8+(1.8*game->fuel)); /* Top left */ glEnd(); } @@ -413,7 +419,7 @@ void render_draw(Game *game, Uint32 t) { glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); - render_draw_2d(r); + render_draw_2d(r, game); SDL_GL_SwapBuffers(); diff --git a/src/types.h b/src/types.h index 75b6d30..fa8a524 100644 --- a/src/types.h +++ b/src/types.h @@ -189,6 +189,9 @@ typedef struct { int frames; Uint32 t_fps; int fps; + + GLfloat radiation; + GLfloat fuel; } Game; |