void TB_SaveSelect::DrawProfile(int x, int y, int index) { Profile *p = &fProfiles[index]; const int w = fCoords.w - 33; int sidewd = sprites[SPR_SAVESELECTOR_SIDES].w; int repeatwd = w - (sidewd * 2); int frame = (index == fCurSel) ? 0 : 1; draw_sprite(x, y, SPR_SAVESELECTOR_SIDES, frame, LEFT); draw_sprite_repeating_x(x+sidewd, y, SPR_SAVESELECTOR_MIDDLE, frame, repeatwd); draw_sprite(x+sidewd+repeatwd, y, SPR_SAVESELECTOR_SIDES, frame, RIGHT); y += 4; const int FONT_SPACING = 5; if (fHaveProfile[index]) { const char *stage = map_get_stage_name(p->stage); font_draw(x+8, y-1, stage, FONT_SPACING); // draw health. DrawHealth(x+w, y, p); } else if (fCurSel == index) { const char *str = "available"; int fx = (w / 2) - (GetFontWidth(str, FONT_SPACING) / 2); font_draw(x+fx, y-1, str, FONT_SPACING); } }
void game_render( void ) { wchar_t buffer[32]; SDL_RenderClear( render ); SDL_RenderCopy( render, background, NULL, NULL ); for ( size_t i = 0; i < blood.size(); i++ ) { set_color( t_blood, blood[i].color ); SDL_SetTextureAlphaMod( t_blood, blood[i].alpha ); tile_draw( render, t_blood, blood[i].type, blood_size, blood[i].x, blood[i].y ); } set_color( unit, 0xFFFFFF ); tile_draw( render, unit, 0, unit_size, player.x, player.y ); for ( size_t i = 0; i < bullet.size(); i++ ) { tile_draw( render, t_bullet, 0, bullet_size, bullet[i].x, bullet[i].y ); } for ( size_t i = 0; i < enemy.size(); i++ ) { set_color( unit, 0x00FF00 ); tile_draw( render, unit, 0, unit_size, enemy[i].x, enemy[i].y ); } for ( size_t i = 0; i < ammo.size(); i++ ) { tile_draw( render, t_ammo, 0, unit_size, ammo[i].x, ammo[i].y ); } swprintf( buffer, 32, L" жизнь: %02d", player.life ); font_draw( render, ft, buffer, 8, 440 ); swprintf( buffer, 32, L"патроны: %02d", player.ammo ); font_draw( render, ft, buffer, 8, 450 ); swprintf( buffer, 32, L" очки: %u", game_score ); font_draw( render, ft, buffer, 8, 460 ); SDL_RenderPresent( render ); }
void game_render( void ) { SDL_Texture *select = NULL; wchar_t buffer[32]; SDL_RenderClear( render ); for ( int i = 0; i < 3; i++ ) { for ( int j = -1; j < 2; j++ ) { tile_draw( render, t_background, 0, background_size, background_size, background_size * i, background_size * j + y_shift ); } } for ( int i = 0; i < star_count; i++ ) { tile_draw( render, t_star, star[i].id, star_size, star_size, star[i].x, star[i].y ); } for ( size_t i = 0; i < laser.size(); i++ ) { if ( laser[i].player_flag ) { select = t_laser_player; } else { select = t_laser_enemy; } tile_draw( render, select, 0, laser_size_x, laser_size_y, laser[i].x, laser[i].y ); } for ( size_t i = 0; i < enemy.size(); i++ ) { tile_angle_draw( render, t_enemy, enemy[i].angle, 0, enemy_size, enemy_size, enemy[i].x, enemy[i].y ); } for ( size_t i = 0; i < meteor.size(); i++ ) { meteor_draw( render, t_meteor, meteor[i] ); } for ( size_t i = 0; i < medkit.size(); i++ ) { tile_angle_draw( render, t_medkit, medkit[i].angle, 0, medkit_size, medkit_size, medkit[i].x, medkit[i].y ); } tile_draw( render, t_player, 0, player_size_x, player_size_y, player_x, player_y ); swprintf( buffer, 32, L" жизнь: %02d", player_life ); font_draw( render, ft, buffer, 8, 440 ); swprintf( buffer, 32, L" очки: %u", game_score ); font_draw( render, ft, buffer, 8, 450 ); SDL_RenderPresent( render ); }
int mlua_draw_font(lua_State* L) { assert(L); Font* font = pop_font(L, 1); const char* text = luaL_checkstring(L, 2); lua_Number x = luaL_checknumber(L, 3); lua_Number y = luaL_checknumber(L, 4); Alignment alignment = (Alignment) luaL_optinteger(L, 5, ALIGN_LEFT); font_draw(font, text, x, y, alignment); return 0; }
void org_test_miniloop(void) { uint32_t start = 0, curtime; uint32_t counter; stat("Starting org test"); font_draw(5, 5, "ORG test in progress...", 0, &greenfont); font_draw(5, 15, "Logging statistics to nx.log", 0, &greenfont); font_draw(5, 25, "Press any button to quit", 0, &greenfont); screen->Flip(); music_set_enabled(1); music(32); last_sdl_key = -1; for(;;) { org_run(); if (++counter > 1024) { counter = 0; curtime = SDL_GetTicks(); if ((curtime - start) >= 100) { start = curtime; input_poll(); if (last_sdl_key != -1) return; } } } }
static void draw_title() { // background is dk grey, not pure black ClearScreen(0x20, 0x20, 0x20); // top logo int tx = (SCREEN_WIDTH / 2) - (sprites[SPR_TITLE].w / 2) - 2; draw_sprite(tx, 40, SPR_TITLE); // draw menu int cx = (SCREEN_WIDTH / 2) - (sprites[SPR_MENU].w / 2) - 8; int cy = (SCREEN_HEIGHT / 2) + 8; for(int i=0;i<sprites[SPR_MENU].nframes;i++) { draw_sprite(cx, cy, SPR_MENU, i); if (i == title.cursel) { draw_sprite(cx - 16, cy - 1, title.sprite, title.selframe); } cy += (sprites[SPR_MENU].h + 4); } // animate character if (++title.seltimer > 8) { title.seltimer = 0; if (++title.selframe >= sprites[title.sprite].nframes) title.selframe = 0; } // accreditation cx = (SCREEN_WIDTH / 2) - (sprites[SPR_PIXEL_FOREVER].w / 2); int acc_y = SCREEN_HEIGHT - 48; draw_sprite(cx, acc_y, SPR_PIXEL_FOREVER); // version static const char *VERSION = "NXEngine v. 1.0.0.4"; static const int SPACING = 5; int wd = GetFontWidth(VERSION, SPACING); cx = (SCREEN_WIDTH / 2) - (wd / 2); font_draw(cx, acc_y + sprites[SPR_PIXEL_FOREVER].h + 4, VERSION, SPACING); // draw Nikumaru display if (title.besttime != 0xffffffff) niku_draw(title.besttime, true); }
int dgreed_main(int argc, const char** argv) { params_init(argc, argv); rand_init(time(NULL)); layouts_init(); layouts_set("dvorak"); bool fullscreen = true; if(params_find("-windowed") != ~0) fullscreen = false; video_init_ex(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT, "KeyMingler", fullscreen); font = font_load(FONT_FILE); float text_width = font_width(font, LOADING_TEXT); float text_height = font_height(font); Vector2 pos = vec2((SCREEN_WIDTH - text_width) / 2.0f, (SCREEN_HEIGHT - text_height) / 2.0f); font_draw(font, LOADING_TEXT, 0, &pos, COLOR_WHITE); video_present(); system_update(); game_init(); sounds_init(); music = sound_load_stream(MUSIC_FILE); sound_play(music); while(system_update()) { game_update(); game_render(); video_present(); sound_update(); if(key_up(KEY_QUIT)) break; } font_free(font); sound_free(music); sounds_close(); game_close(); video_close(); layouts_close(); return 0; }
bool Credits::DrawLine(CredLine *line) { int x = line->x; int y = SCREEN_Y(line->y); if (y < -MARGIN) return true; // line can be deleted now if (line->image) { draw_sprite(x - 24, y - 8, SPR_CASTS, line->image); //DrawBox(x, y, x+GetFontWidth(line->text, TEXT_SPACING), y+8, 56, 0, 0); } //int font_draw(int x, int y, const char *string, int font_spacing) //DrawRect(x, y, x+63, y+8, 128, 0, 0); font_draw(x, y, line->text, TEXT_SPACING); return false; }
void game_render( void ) { SDL_RenderClear( render ); for ( short i = 0; i < two_pole_size; i++ ) { if ( color[i] == 1 ) { SDL_SetTextureColorMod( tiles, 0, 100, 255 ); } else { SDL_SetTextureColorMod( tiles, 255, 255, 255 ); } tile_draw( render, tiles, pole[i%pole_size][i/pole_size], i ); } if (draw_game_info) { SDL_Rect rectangle = { screen_width / 3, screen_height / 2 - 50, 230, 50 }; SDL_SetRenderDrawColor( render, 0, 0, 255, 0 ); SDL_RenderFillRect( render, &rectangle ); SDL_SetRenderDrawColor( render, 0, 0, 0, 0 ); font_draw(render, ft, game_info_text, screen_width / 3, screen_height / 2 - 45 ); } SDL_RenderPresent( render ); }
int main(int argc, char* argv[]) { int rc; rc = glfwInit(); if(!rc) sys_err("glfwInit() failed"); int w = 640; int h = 480; int r = 0; int g = 0; int b = 0; int a = 0; int d = 0; int s = 0; rc = glfwOpenWindow(w, h, r, g, b, a, d, s, GLFW_WINDOW); if(!rc) { int errn = errno; glfwTerminate(); sys_errno(errn, "glfwOpenWindow() failed"); } font_set_color(1, 1, 1, 0); glClearColor(0.3f, 0.3f, 0.3f, 1.0f); while(1) { glClear(GL_COLOR_BUFFER_BIT); int x = 50; int y = 50; const char* txt = "howdy"; font_draw(x, y, txt); glfwSwapBuffers(); if(!glfwGetWindowParam(GLFW_OPENED)) break; } glfwTerminate(); return 0; }
/* this is needed to draw the whole uppdate of everything */ void draw_netupdatestate (char st) { char text[255]; unsigned char b; int y = 0, b1, z, zx = 200, i, j, s = map.size.y + MAX_PLAYERS + GAME_MAX_TUNNELS; SDL_Rect src, dest; z = gfx.res.x - zx - 30 - 8; for (i = 0; i < MAX_PLAYERS; i++) if (PS_IS_used (players[i].state)) { y += 50; if (st) { redraw_logo (0, y, gfx.res.x, y + 50); if (players[i].gfx_nr != -1) { dest.w = src.w = players[i].gfx->small_image->w; dest.h = src.h = players[i].gfx->small_image->h; src.x = players[i].gfx->small_image->w * down; src.y = 0; dest.x = 50; dest.y = y; SDL_BlitSurface (players[i].gfx->small_image, &src, gfx.screen, &dest); gfx_blitupdaterectadd (&dest); } dest.x = zx; dest.y = y; dest.w = menulistimages[1][0]->w; dest.h = menulistimages[1][0]->h; gfx_blit (menulistimages[1][0], NULL, gfx.screen, &dest, 10000); dest.x = z + zx + 4; gfx_blit (menulistimages[1][2], NULL, gfx.screen, &dest, 10000); // draw the bottom left and right of the list dest.y = y + 29; gfx_blit (menulistimages[1][8], NULL, gfx.screen, &dest, 10000); dest.x = zx; gfx_blit (menulistimages[1][6], NULL, gfx.screen, &dest, 10000); //top & bottom for (j = 4; j < z + 4; j += 4) { dest.x = j + zx; dest.y = y; gfx_blit (menulistimages[1][1], NULL, gfx.screen, &dest, 10000); dest.y = y + 29; gfx_blit (menulistimages[1][7], NULL, gfx.screen, &dest, 10000); } //left &right for (j = 4; j < 29; j += 4) { dest.x = zx; dest.y = y + j; gfx_blit (menulistimages[1][3], NULL, gfx.screen, &dest, 10000); dest.x = z + zx + 4; gfx_blit (menulistimages[1][5], NULL, gfx.screen, &dest, 10000); } sprintf (text, "%s", players[i].name); font_draw (80, y, text, 0, 4); } // calc percentage, this a range from 0 to 255) switch (players[i].net.net_istep) { case 3: sprintf (text, "Getting Tunnel Data %d.", players[i].net.net_status); b = (players[i].net.net_status + 1) * 255 / s; break; case 2: sprintf (text, "Getting Field Data %d of %d.", players[i].net.net_status, map.size.y); b = (players[i].net.net_status + 1 + GAME_MAX_TUNNELS) * 255 / s; break; case 1: sprintf (text, "Getting Player Data %d of %d.", players[i].net.net_status, MAX_PLAYERS); b = (players[i].net.net_status + 1 + GAME_MAX_TUNNELS + map.size.y) * 255 / s; break; default: sprintf (text, "Ready"); b = 255; break; } //draw bar if (b > 0) { b1 = b * z / 255; dest.x = zx + 4; dest.y = y + 4; dest.w = menubuttonimages[2][0]->w; dest.h = menubuttonimages[2][0]->h; gfx_blit (menubuttonimages[2][0], NULL, gfx.screen, &dest, 10000); dest.x = zx + 4 + b1 - menubuttonimages[1][2]->w; if (dest.x < zx + 4) dest.x = zx + 4; dest.w = menubuttonimages[2][2]->w; dest.h = menubuttonimages[2][2]->h; gfx_blit (menubuttonimages[2][2], NULL, gfx.screen, &dest, 10000); if (b1 > menubuttonimages[2][0]->w + menubuttonimages[2][2]->w) { dest.w = menubuttonimages[2][1]->w; dest.h = menubuttonimages[2][1]->h; for (j = menubuttonimages[2][0]->w; j < b1 - menubuttonimages[2][2]->w; j += menubuttonimages[2][1]->w) { dest.x = j + zx + 4; gfx_blit (menubuttonimages[2][1], NULL, gfx.screen, &dest, 10000); } } } // draw old status in case of debug if (!players[i].net.net_istep) font_draw (80, y + 20, text, 0, 4); else if (debug) { redraw_logo (80, y + 35, gfx.res.x - 80, 15); font_draw (80, y + 35, text, 0, 4); } } gfx_blitdraw (); return; }
static void draw_title() { // background is dk grey, not pure black ClearScreen(0x20, 0x20, 0x20); // top logo int tx = (Graphics::SCREEN_WIDTH / 2) - (sprites[SPR_TITLE].w / 2) - 2; draw_sprite(tx, 40, SPR_TITLE); // draw menu int cx = (Graphics::SCREEN_WIDTH / 2) - (sprites[SPR_MENU].w / 2) - 8; int cy = (Graphics::SCREEN_HEIGHT / 2) - 8; for(int i=0;i<sprites[SPR_MENU].nframes;i++) { draw_sprite(cx, cy, SPR_MENU, i); if (i == title.cursel) { draw_sprite(cx - 16, cy - 1, title.sprite, title.selframe); } //RectI r = Sprites::get_sprite_rect(cx, cy, SPR_MENU, i); //Graphics::DrawRect(r.x, r.y, r.x + r.w, r.y + r.h, 255,255,255); cy += (sprites[SPR_MENU].h + 18); } // animate character if (++title.seltimer > 8) { title.seltimer = 0; if (++title.selframe >= sprites[title.sprite].nframes) title.selframe = 0; } // accreditation cx = (Graphics::SCREEN_WIDTH / 2) - (sprites[SPR_PIXEL_FOREVER].w / 2); int acc_y = Graphics::SCREEN_HEIGHT - 48; draw_sprite(cx, acc_y, SPR_PIXEL_FOREVER); // version static const char *VERSION = "NXEngine v. 1.0.0.4"; static const int SPACING = 5; int wd = GetFontWidth(VERSION, SPACING); cx = (Graphics::SCREEN_WIDTH / 2) - (wd / 2); font_draw(cx, acc_y + sprites[SPR_PIXEL_FOREVER].h + 4, VERSION, SPACING); // draw Nikumaru display if (title.besttime != 0xffffffff) niku_draw(title.besttime, true); // options { const char *str = "F3:Options"; cx = (Graphics::SCREEN_WIDTH / 2) - (GetFontWidth(str, 0) / 2) - 4; cy = (Graphics::SCREEN_HEIGHT - 8) - GetFontHeight(); int f3wd = font_draw(cx, cy, "F3", 0); font_draw(cx + f3wd, cy, ":Options", 0, &bluefont); #ifdef CONFIG_USE_TAPS RectI r = RectI(cx, cy, GetFontWidth(str, 0), GetFontHeight()); debug_absbox(r.x, r.y, r.x + r.w, r.y + r.h, 255, 255, 255); if (VJoy::ModeAware::wasTap(r)) { game.pause(GP_OPTIONS); } #endif } }
/* sets up everything for the network game.. on servers the game field will be created and the clients will wait for the game data within the network loop */ void net_transmit_gamedata () { int done = 0, keypressed = 0, x, y, // network upload status for one step p, i, net_istep; // network init step SDL_Event event; Uint8 *keys; Uint32 downtimestamp = 0; draw_logo (); if (GT_MP_PTPM) font_draw (100, 0, "Waiting for the Clients", 1, 0); else font_draw (100, 0, "Downloading Data", 1, 0); /* prepare everything for the loop */ for (x = 0; x < MAX_PLAYERS; x++) { players[x].net.timestamp = 0; players[x].net.net_status = -1; if ((PS_IS_aiplayer (players[x].state)) || (x == bman.p_servnr) || (x == bman.p2_nr) || (players[x].net.flags & NETF_local2) == NETF_local2) players[x].net.net_istep = 0; else players[x].net.net_istep = 3; } y = -1; if (GT_MP_PTPM) net_istep = 0; else net_istep = 3; draw_netupdatestate (1); SDL_Flip (gfx.screen); downtimestamp = timestamp; while (!done && (bman.state == GS_update || (GT_MP_PTPS && net_istep != 0))) { /* the network thing */ network_loop (); /* if PTPM check if all players are ready */ if (GT_MP_PTPM) { if (timestamp - downtimestamp > TIME_UPDATEINFO) { downtimestamp = timestamp; net_send_updateinfo (); } for (p = 0, i = 1; p < MAX_PLAYERS; p++) if (PS_IS_playing (players[p].state) && players[p].net.net_istep != 0) i = 0; if (i == 1) { /* all players are ready */ done = 1; bman.state = GS_ready; } } /* if PTPS get all data */ if (GT_MP_PTPS) { if (net_istep == 3) { /* get tunneldata */ if ((y < GAME_MAX_TUNNELS - 1 && y == players[bman.p_nr].net.net_status) || y == -1) { y++; downtimestamp = timestamp; send_tunneldata (&players[bman.p_servnr].net.addr, y, -1, -1); } else if (y < GAME_MAX_TUNNELS && y != players[bman.p_nr].net.net_status && y >= 0 && timestamp - downtimestamp > DOWNLOAD_TIMEOUT) { /* we have got no tunnel data */ y--; } else if (y == GAME_MAX_TUNNELS - 1 && players[bman.p_nr].net.net_status == y) { /* we have got all tunnel data */ y = -1; players[bman.p_nr].net.net_istep = --net_istep; players[bman.p_nr].net.net_status = -1; } } if (net_istep == 2) { /* get field data */ if ((y < map.size.y - 1 && y == players[bman.p_nr].net.net_status) || y == -1) { /* send field data req */ y++; downtimestamp = timestamp; send_getfield (&players[bman.p_servnr].net.addr, y); } else if (y < map.size.y && y != players[bman.p_nr].net.net_status && y >= 0 && timestamp - downtimestamp > DOWNLOAD_TIMEOUT) { /* getdata timed out - we have got no field data */ y--; } else if (y == map.size.y - 1 && players[bman.p_nr].net.net_status == y) { /* we have got all field data */ y = -1; players[bman.p_nr].net.net_istep = --net_istep; players[bman.p_nr].net.net_status = -1; } } if (net_istep == 1) { /* get player data */ if ((y < MAX_PLAYERS - 1 && y == players[bman.p_nr].net.net_status) || y == -1) { /* send player date req */ y++; downtimestamp = timestamp; send_getplayerdata (&players[bman.p_servnr].net.addr, y); } if (y < MAX_PLAYERS && y != players[bman.p_nr].net.net_status && y >= 0 && timestamp - downtimestamp > DOWNLOAD_TIMEOUT) { /* we have got no player data */ y--; } if (y == MAX_PLAYERS - 1 && players[bman.p_nr].net.net_status == y) { /* we have got all playerdata */ y = -1; players[bman.p_nr].net.net_istep = --net_istep; players[bman.p_nr].net.net_status = -1; downtimestamp = timestamp; send_playerstatus (&players[bman.p_servnr].net.addr, bman.p_nr, 0, 0); } } if (net_istep == 0 && players[bman.p_nr].net.net_status == -1 && timestamp - downtimestamp > DOWNLOAD_TIMEOUT) { /* server did not send informations back */ downtimestamp = timestamp; send_playerstatus (&players[bman.p_servnr].net.addr, bman.p_nr, 0, 0); } } /* do the grafik work */ draw_netupdatestate (0); if (s_fetchevent (&event) != 0) switch (event.type) { case (SDL_QUIT): bman.state = GS_quit; bman.p_nr = -1; done = 1; } keys = SDL_GetKeyState (NULL); if (keys[SDLK_ESCAPE] && event.type == SDL_KEYDOWN) { done = 1; bman.p_nr = -1; keypressed = 1; bman.state = GS_startup; } if (event.type == SDL_KEYUP) keypressed = 0; } timestamp = SDL_GetTicks (); // needed for time sync. SDL_Delay (1); // we don't need here anything better /* player is only watching so just go after we have got everything go to show the field */ if (GT_MP_PTPS && bman.state == GS_update && net_istep == 0 && players[bman.p_nr].gfx_nr == -1) { done = 1; bman.state = GS_running; } };
void game_draw_info () { int i, x, j, col; char text[255]; char scrtext[255]; SDL_Rect src, dest; if (GT_MP && (chat.oldscreen == NULL || chat.window.x != 4 || chat.window.y != 4.5 * 16)) { chat_show (4, 4.5 * 16, gfx.res.x - 8, gfx.offset.y - 4.5 * 16); chat_setactive (0, 0); } if (bman.updatestatusbar) { redraw_logo (0, 0, gfx.res.x, (4.5 * 16)); dest.x = dest.y = 0; dest.h = 4.5 * 16; dest.w = gfx.res.x; gfx_blitupdaterectadd (&dest); /* In Multiplayer mode draw Player names and count the players who are still alife. */ for (x = 0, j = 0, i = 0; i < MAX_PLAYERS; i++) if ((players[i].state & PSFM_used) != 0) { if (players[i].gfx_nr != -1 && PS_IS_used (players[i].state)) { src.x = 0; src.y = 0; src.w = dest.w = players[i].gfx->small_image->w; src.h = dest.h = players[i].gfx->small_image->h; dest.x = x; dest.y = j - 4; SDL_BlitSurface (players[i].gfx->small_image, &src, gfx.screen, &dest); } sprintf (scrtext, "%10s:%d %1d %1d", players[i].name, players[i].wins, players[i].points, players[i].nbrKilled); if (!PS_IS_alife (players[i].state)) { // Player is dead if ((players[i].state & PSF_used) != PSF_used) col = 4; else col = 3; } else { // player is alife if (bman.gametype == GT_team) col = teams[players[i].team_nr].col; else col = 0; } font_draw (x, j, scrtext, 0, col); x = x + 180; if (x >= gfx.res.x - (120 + 170)) { x = 0; j = j + 1.5 * font[0].size.x; } } x = gfx.res.x - 120; sprintf (text, "Bombs: %2d", players[bman.p_nr].bombs_n); font_draw (x, 0, text, 0, 0); sprintf (text, "Range: %2d", players[bman.p_nr].range); font_draw (x, 16, text, 0, 0); sprintf (text, "Speed: %1.1f", players[bman.p_nr].speed * 10); font_draw (x, 32, text, 0, 0); if (players[bman.p_nr].special.type != 0) { col = players[bman.p_nr].special.type + FT_sp_trigger - 1; dest.x = x - 32; dest.y = 16; dest.w = gfx.menu_field[col]->w; dest.h = gfx.menu_field[col]->h; SDL_BlitSurface (gfx.menu_field[col], NULL, gfx.screen, &dest); } if (bman.state == GS_ready && GT_MP_PTPM) font_gfxdraw (100, 32, "Press F4 to start the game", 0, COLOR_yellow, 0xFFFF); else if (bman.state == GS_ready) font_gfxdraw (100, 32, "Waiting for the Server to Start", 0, COLOR_yellow, 0xFFFF); } /* draw the warning part */ if (map.state != MS_normal) { hurrywarn_to -= timediff; if (bman.updatestatusbar || hurrywarn_to <= 0.0 || hurrywarn_to > HURRYWARN_TO_BLINKING) { hurrywarn_to = HURRYWARN_TO_BLINKING; hurrywarn_state = !hurrywarn_state; if (hurrywarn_state) { font_drawbold ((gfx.res.x - strlen ("HURRY HURRY") * font[1].size.x) / 2, 40, "HURRY HURRY", 1, 0, 2); font_draw ((gfx.res.x - strlen ("HURRY HURRY") * font[1].size.x) / 2, 40, "HURRY HURRY", 1, 1); } else { font_drawbold ((gfx.res.x - strlen ("HURRY HURRY") * font[1].size.x) / 2, 40, "HURRY HURRY", 1, 1, 2); font_draw ((gfx.res.x - strlen ("HURRY HURRY") * font[1].size.x) / 2, 40, "HURRY HURRY", 1, 0); } dest.x = dest.y = 0; dest.h = 4.5 * 16; dest.w = gfx.res.x; gfx_blitupdaterectadd (&dest); } } if (debug) debug_ingameinfo (); bman.updatestatusbar = 0; };
static void draw_banner(void) { FillRect(0, BANNER_TOP, Graphics::SCREEN_WIDTH, BANNER_BTM, NXColor(0, 0, 0)); font_draw(ms.textx, ms.texty, ms.bannertext, 0); }
static void draw_font_set() { int x0, x1, x2, x3; int y0, y1, y2, y3; int i, j, k; int num_rows = NUM_FONT_ROWS; int num_cols = NUM_FONT_COLS; int pw = UNIT_RECT_WIDTH - 1; int ph = UNIT_RECT_HEIGHT - 1; // draw back polys glBegin(GL_TRIANGLES); y0 = y1 = win_height() - UNIT_RECT_HEIGHT; y2 = y3 = win_height() - UNIT_RECT_HEIGHT + ph; k = 0; for(i = 0; i < num_rows; ++i) { x2 = x0 = 0; x1 = x3 = pw; for(j = 0; j < num_cols; ++j) { glColor3f(POLY_COLOR[0], POLY_COLOR[1], POLY_COLOR[2]); glVertex2d(x0, y0); glVertex2d(x1, y1); glVertex2d(x2, y2); glVertex2d(x1, y1); glVertex2d(x3, y3); glVertex2d(x2, y2); x0 += UNIT_RECT_WIDTH; x1 += UNIT_RECT_WIDTH; x2 += UNIT_RECT_WIDTH; x3 += UNIT_RECT_WIDTH; } y0 -= UNIT_RECT_HEIGHT; y1 -= UNIT_RECT_HEIGHT; y2 -= UNIT_RECT_HEIGHT; y3 -= UNIT_RECT_HEIGHT; } glEnd(); // draw font chars y0 = y1 = win_height() - UNIT_RECT_HEIGHT; y2 = y3 = win_height() - UNIT_RECT_HEIGHT + ph; k = 0; for(i = 0; i < num_rows; ++i) { x2 = x0 = 0; x1 = x3 = pw; for(j = 0; j < num_cols; ++j) { font_set_color(FONT_COLOR[0], FONT_COLOR[1], FONT_COLOR[2], FONT_COLOR[3]); char s[2] = "\0\0"; s[0] = k++; // for some reason, font_draw currently crashes drawing chars >= 128 if(k==128) { goto outtahere; } font_draw(x0, y0, s); x0 += UNIT_RECT_WIDTH; x1 += UNIT_RECT_WIDTH; x2 += UNIT_RECT_WIDTH; x3 += UNIT_RECT_WIDTH; } y0 -= UNIT_RECT_HEIGHT; y1 -= UNIT_RECT_HEIGHT; y2 -= UNIT_RECT_HEIGHT; y3 -= UNIT_RECT_HEIGHT; } outtahere: return; }
void game_showresult () { char text[255]; SDL_Event event; Uint8 *keys; int done = 0, keypressed = 0, x, y; gfx_blitdraw (); draw_logo (); strcpy (text, "Game Result"); x = (gfx.res.x - (font[2].size.x * strlen (text)) - 64) / 2; y = 0; font_drawbold (x, y, text, 2, 6, 2); font_draw (x, y, text, 2, 5); y += font[2].size.x; strcpy (text, "[CTRL],[RETURN] or [STRG] for another game"); x = (gfx.res.x - (font[1].size.x * strlen (text)) - 64) / 2; font_drawbold (x, gfx.res.y - (2 * font[0].size.y) - 2, text, 0, COLOR_brown, 1); font_draw (x, gfx.res.y - (2 * font[0].size.y) - 2, text, 0, COLOR_yellow); strcpy (text, "or [ESC] to leave the game."); x = (gfx.res.x - (font[1].size.x * strlen (text)) - 64) / 2; font_drawbold (x, gfx.res.y - font[0].size.y - 2, text, 0, COLOR_brown, 1); font_draw (x, gfx.res.y - font[0].size.y - 2, text, 0, COLOR_yellow); if (bman.gametype == GT_team) game_showresultteam (10, 50, gfx.res.x - 20, gfx.res.y - 100); else game_showresultnormal (10, 50, gfx.res.x - 20, gfx.res.y - 100); gfx_blitdraw (); SDL_Flip (gfx.screen); while (!done && bman.state != GS_quit) { /* do the keyboard handling */ if (s_fetchevent (&event) != 0) switch (event.type) { case (SDL_QUIT): bman.state = GS_quit; bman.p_nr = -1; done = 1; } keys = SDL_GetKeyState (NULL); if (keys[SDLK_ESCAPE] && event.type == SDL_KEYDOWN) { /* we want to quit */ done = 1; bman.p_nr = -1; keypressed = 1; bman.state = GS_startup; } if ((keys[SDLK_RETURN] || keys[SDLK_LCTRL] || keys[SDLK_RCTRL]) && (!keypressed) && (event.type = SDL_KEYDOWN)) { done = 1; keypressed = 1; } if (keys[SDLK_F8] && event.type == SDL_KEYDOWN) { /* Switch Fullscreen */ SDL_WM_ToggleFullScreen (gfx.screen); gfx.fullscreen = !gfx.fullscreen; bman.updatestatusbar = 1; // force an update } if (event.type == SDL_KEYUP) keypressed = 0; else if (event.type == SDL_KEYDOWN) keypressed = 1; s_delay (25); } if (bman.state != GS_quit && bman.state != GS_startup) bman.state = GS_running; };