diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2007-07-15 10:47:50 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2007-07-15 10:47:50 +0000 |
| commit | 8a4cd7627e78d87b44c52bf53786c6891ded6866 (patch) | |
| tree | d9b3e038554bf10dc4f83c1dcc9e656e6f3f101f /src/game/client | |
| parent | 60b252c584adc35f02ce2e00ea4556cc2a81958d (diff) | |
| download | zcatch-8a4cd7627e78d87b44c52bf53786c6891ded6866.tar.gz zcatch-8a4cd7627e78d87b44c52bf53786c6891ded6866.zip | |
added score and time limit. cleaned up the code aswell abit
Diffstat (limited to 'src/game/client')
| -rw-r--r-- | src/game/client/game_client.cpp | 60 |
1 files changed, 54 insertions, 6 deletions
diff --git a/src/game/client/game_client.cpp b/src/game/client/game_client.cpp index bdd03624..67354bec 100644 --- a/src/game/client/game_client.cpp +++ b/src/game/client/game_client.cpp @@ -922,6 +922,7 @@ void modc_render() } // setup world view + obj_game *gameobj = 0; { // 1. fetch local player // 2. set him to the center @@ -942,9 +943,10 @@ void modc_render() void *p = snap_find_item(SNAP_PREV, item.type, item.id); if(p) local_player_pos = mix(vec2(((obj_player *)p)->x, ((obj_player *)p)->y), local_player_pos, client_intratick()); - break; } } + else if(item.type == OBJTYPE_GAME) + gameobj = (obj_game *)data; } } @@ -981,6 +983,7 @@ void modc_render() // render map tilemap_render(32.0f, 0); + // render items int num = snap_num_items(SNAP_CURRENT); for(int i = 0; i < num; i++) @@ -1141,8 +1144,42 @@ void modc_render() } } + // render goals + if(gameobj) + { + gfx_mapscreen(0,0,400,300); + if(!gameobj->sudden_death) + { + char buf[32]; + int time = 0; + if(gameobj->time_limit) + { + time = gameobj->time_limit*60 - ((client_tick()-gameobj->round_start_tick)/client_tickspeed()); + + if(gameobj->game_over) + time = 0; + } + else + time = (client_tick()-gameobj->round_start_tick)/client_tickspeed(); + + sprintf(buf, "%d:%02d", time /60, time %60); + float w = gfx_pretty_text_width(16, buf); + gfx_pretty_text(200-w/2, 2, 16, buf); + } + + if(gameobj->sudden_death) + { + const char *text = "Sudden Death"; + float w = gfx_pretty_text_width(16, text); + gfx_pretty_text(200-w/2, 2, 16, text); + } + } + // render score board - if(inp_key_pressed(baselib::input::tab) || (local_player && local_player->health == -1)) + if(inp_key_pressed(baselib::input::tab) || // user requested + (local_player && local_player->health == -1) || // player dead + (gameobj && gameobj->game_over) // game over + ) { gfx_mapscreen(0, 0, width, height); @@ -1157,12 +1194,23 @@ void modc_render() gfx_quads_drawTL(x-10.f, y-10.f, 400.0f, 600.0f); gfx_quads_end(); - //gfx_texture_set(current_font->font_texture); gfx_pretty_text(x, y, 64, "Score Board"); - y += 100.0f; + y += 64.0f; + if(gameobj && gameobj->time_limit) + { + char buf[64]; + sprintf(buf, "Time Limit: %d min", gameobj->time_limit); + gfx_pretty_text(x, y, 32, buf); + y += 32.0f; + } + if(gameobj && gameobj->score_limit) + { + char buf[64]; + sprintf(buf, "Score Limit: %d", gameobj->score_limit); + gfx_pretty_text(x, y, 32, buf); + y += 32.0f; + } - //gfx_texture_set(-1); - //gfx_quads_text(10, 50, 8, "Score Board"); int num = snap_num_items(SNAP_CURRENT); for(int i = 0; i < num; i++) { |