static void match_case_menu_item_toggled (GtkCheckMenuItem *checkmenuitem, GeditViewFrame *frame) { GEDIT_SEARCH_SET_CASE_SENSITIVE (frame->priv->search_flags, gtk_check_menu_item_get_active (checkmenuitem)); update_search (frame); }
static void match_entire_word_menu_item_toggled (GtkCheckMenuItem *checkmenuitem, GeditViewFrame *frame) { GEDIT_SEARCH_SET_ENTIRE_WORD (frame->priv->search_flags, gtk_check_menu_item_get_active (checkmenuitem)); update_search (frame); }
void GameUpdate() { game* g = &g_game; if (is_key_pressed(KEY_RESET)) { memset(g->_map, 0, sizeof(g->_map)); g->_entities.free(); g->_player = 0; g->_cam_pos = vec2(MAP_WIDTH * 0.5f, 8.5f); g->_target_cam_y = 8.5f; g->_diff = 1; g->_diff_dmg = 1; g->_spawn_time = 800; g->_spawn_count = 6; g->_wave_incoming = true; g->_plr_dmg = 1; GameInit(); g_title = true; } if (g_title) { set_camera(vec2(), 10.0f); float ratio = g_WinSize.y / (float)g_WinSize.x; vec2 orig(-10.0f, -10.0f * ratio); draw_string(vec2(0.0f, -4.75), 0.15f, TEXT_CENTRE, colour(0.5f, 0.5f, 1.0f, 1.0f), "Tunnel Defense"); float y = -3.25f; draw_string(vec2(0.0f, y), 0.05f, TEXT_CENTRE, colour(0.3f, 0.3f, 0.6f, 1.0f), "Originally made for LD29 - post competition version"); y += 0.5f; y += 0.5f; draw_string(vec2(0.0f, y), 0.05f, TEXT_CENTRE, colour(0.6f, 0.3f, 0.3f, 1.0f), "Dig for your life, the creeps are coming and the"); y += 0.5f; draw_string(vec2(0.0f, y), 0.05f, TEXT_CENTRE, colour(0.6f, 0.3f, 0.3f, 1.0f), "only safe place is underground! Collect resources"); y += 0.5f; draw_string(vec2(0.0f, y), 0.05f, TEXT_CENTRE, colour(0.6f, 0.3f, 0.3f, 1.0f), "and build turrets to protect yourself."); y += 0.5f; y += 0.25f; float r = 5.0f; draw_string(vec2(-r, y), 0.05f, TEXT_LEFT, colour(0.6f, 0.6f, 0.6f, 1.0f), "\001\002\003\004"); draw_string(vec2(r, y), 0.05f, TEXT_RIGHT, colour(0.3f, 0.6f, 0.3f, 1.0f), "Move + Aim"); y += 0.5f; draw_string(vec2(-r, y), 0.05f, TEXT_LEFT, colour(0.6f, 0.6f, 0.6f, 1.0f), "%c", g_LocKeyZ); draw_string(vec2(r, y), 0.05f, TEXT_RIGHT, colour(0.3f, 0.6f, 0.3f, 1.0f), "Jump"); y += 0.5f; draw_string(vec2(-r, y), 0.05f, TEXT_LEFT, colour(0.6f, 0.6f, 0.6f, 1.0f), "%c", g_LocKeyX); draw_string(vec2(r, y), 0.05f, TEXT_RIGHT, colour(0.3f, 0.6f, 0.3f, 1.0f), "Dig block / shoot"); y += 0.5f; draw_string(vec2(-r, y), 0.05f, TEXT_LEFT, colour(0.6f, 0.6f, 0.6f, 1.0f), "%c", g_LocKeyC); draw_string(vec2(r, y), 0.05f, TEXT_RIGHT, colour(0.3f, 0.6f, 0.3f, 1.0f), "Build / upgrade turret"); y += 0.5f; y += 0.25f; draw_string(vec2(0.0f, y), 0.05f, TEXT_CENTRE, colour(0.15f, 0.3f, 0.15f, 1.0f), "Alternate controls - %c%c%c%c, %c, %c, %c", g_LocKeyW, g_LocKeyA, g_LocKeyS, g_LocKeyD, g_LocKeyI, g_LocKeyO, g_LocKeyP); y += 0.5f; y += 0.25f; draw_string(vec2(0.0f, y), 0.05f, TEXT_CENTRE, colour(0.3f, 0.15f, 0.3f, 1.0f), "Building / upgrading a turret costs 3 metal."); y += 0.5f; draw_string(vec2(0.0f, y), 0.05f, TEXT_CENTRE, colour(0.3f, 0.15f, 0.3f, 1.0f), "Building a turret increases your shot power."); y += 0.5f; y += 0.25f; draw_string(vec2(0.0f, y), 0.05f, TEXT_CENTRE, colour(0.5f, 0.5f, 0.5f, 1.0f), "press SPACE to START"); y+= 0.5f; y += 0.5f; draw_string(vec2(0.0f, y), 0.035f, TEXT_CENTRE, colour(0.15f, 0.15f, 0.15f, 1.0f), "by Stephen Cakebread @quantumrain"); if (is_key_pressed(KEY_FIRE) || is_key_pressed(KEY_ALT_FIRE)) g_title = false; return; } if (player* p = g->_player) { vec2 target_cam_pos = vec2(MAP_WIDTH * 0.5f, p->centre().y); float dy = target_cam_pos.y - g->_target_cam_y; float hyst = 1.25f; if (fabsf(dy) > hyst) { if (dy > 0.0f) g->_target_cam_y += dy - hyst; else g->_target_cam_y += dy + hyst; } target_cam_pos.y = g->_target_cam_y; update_search(g, to_ivec2(p->centre())); g->_cam_pos = lerp(g->_cam_pos, target_cam_pos, 0.2f); g->_plr_dmg = 1; for(uint32_t i = 0; i < g->_entities.size(); i++) { entity* e = g->_entities[i]; if (!(e->_flags & entity::FLAG_DESTROYED)) { if (e->_type == ET_TURRET) g->_plr_dmg++; } } } set_camera(g->_cam_pos, 15.0f); if (g->_player) { if (--g->_spawn_time <= 0) { if (g->_wave_incoming) { g->_spawn_count = 4 + 4 * (int)g->_diff; g->_diff_dmg = (int)(2.5f * (1 + g->_diff)) - 1; } g->_wave_incoming = false; vec2 pos(g_game_rand.frand(1.0f, MAP_WIDTH - 1.0f), 2.0f); if (bug* e = spawn_entity(&g_game, new bug(), pos)) { e->_max_damage = g->_diff_dmg; if (g_game_rand.rand(0, 5) == 0) e->_max_damage += g_game_rand.rand(0, g->_diff_dmg); if (g_game_rand.rand(0, 15) == 0) e->_max_damage += g_game_rand.rand(0, g->_diff_dmg); if (g_game_rand.rand(0, 30) == 0) e->_max_damage += g_game_rand.rand(0, g->_diff_dmg); } g->_spawn_time = clamp(60 - ((g->_diff * 5) / 4), 10, 60); if (--g->_spawn_count <= 0){ g->_diff += 1 + (g->_diff / 5); g->_spawn_time = 600; g->_wave_incoming = true; } } } tick_entities(g); purge_entities(g); update_particles(g); colour sky0(0.4f, 0.7f, 1.0f, 1.0f); colour sky1(0.45f, 0.75f, 1.0f, 1.0f); colour sky2(0.3f, 0.6f, 0.9f, 1.0f); colour sky3(0.35f, 0.65f, 0.9f, 1.0f); sky0 *= colour(0.65f, 0.0f); sky1 *= colour(0.65f, 0.0f); sky2 *= colour(0.35f, 1.0f); sky3 *= colour(0.35f, 1.0f); float sky_space = 4.5f; float sky_top = 4.75f; float sky_y = 10.0f; float sky_yf = 10.5f; float sky_yb = 11.0f; for(int j = 0; j < MAP_HEIGHT; j++) { colour bk_colour(get_master_colour(j) * colour(0.2f, 1.0f)); for(int i = 0; i < MAP_WIDTH; i++) { int t = g->get_tile(i, j); if (t == TT_EMPTY || t == TT_TURRET) { int hash = ((i * 7) ^ (j * 3)) + (i + j); hash ^= ((hash >> 3) * 9); int tile_num = 132 + (hash % 4); draw_tile(vec2((float)i, (float)j), vec2(i + 1.0f, j + 1.0f), bk_colour, tile_num, 0); } } }
static void search_init (GtkWidget *entry, GeditViewFrame *frame) { const gchar *entry_text; /* renew the flush timeout */ if (frame->priv->typeselect_flush_timeout != 0) { g_source_remove (frame->priv->typeselect_flush_timeout); frame->priv->typeselect_flush_timeout = g_timeout_add (GEDIT_VIEW_FRAME_SEARCH_DIALOG_TIMEOUT, (GSourceFunc)search_entry_flush_timeout, frame); } entry_text = gtk_entry_get_text (GTK_ENTRY (entry)); if (frame->priv->search_mode == SEARCH) { update_search (frame); run_search (frame, entry_text, FALSE, frame->priv->wrap_around, TRUE); } else { if (*entry_text != '\0') { gboolean moved, moved_offset; gint line; gint offset_line = 0; gint line_offset = 0; gchar **split_text = NULL; const gchar *text; GtkTextIter iter; GeditDocument *doc; doc = gedit_view_frame_get_document (frame); gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (doc), &iter, frame->priv->start_mark); split_text = g_strsplit (entry_text, ":", -1); if (g_strv_length (split_text) > 1) { text = split_text[0]; } else { text = entry_text; } if (*text == '-') { gint cur_line = gtk_text_iter_get_line (&iter); if (*(text + 1) != '\0') offset_line = MAX (atoi (text + 1), 0); line = MAX (cur_line - offset_line, 0); } else if (*entry_text == '+') { gint cur_line = gtk_text_iter_get_line (&iter); if (*(text + 1) != '\0') offset_line = MAX (atoi (text + 1), 0); line = cur_line + offset_line; } else { line = MAX (atoi (text) - 1, 0); } if (split_text[1] != NULL) { line_offset = atoi (split_text[1]); } g_strfreev (split_text); moved = gedit_document_goto_line (doc, line); moved_offset = gedit_document_goto_line_offset (doc, line, line_offset); gedit_view_scroll_to_cursor (GEDIT_VIEW (frame->priv->view)); if (!moved || !moved_offset) { set_entry_background (frame, frame->priv->search_entry, GEDIT_SEARCH_ENTRY_NOT_FOUND); } else { set_entry_background (frame, frame->priv->search_entry, GEDIT_SEARCH_ENTRY_NORMAL); } } } }