/* **draw\_level()** draws the game frames, using * the content of the level (the wizard, level tiles, monsters, etc..). * It uses the level_data stored inside the data arg as well * as the LEVEL string that represents the level map using * ascii chars as tiles index; */ static void draw_level(void* data, float elapsed_ms) { struct level_data* ldata = data; struct rectangle tile_size = { 0, 0, 16, 16 }; unsigned int i; char fps[10]; sprintf(fps, "FPS:%02.0f", 1000 / elapsed_ms); if (ldata->wizard->sprite->active_animation == ldata->wizard->spell) { if (ldata->wizard->sprite->current_frame > 1) shake_screen(elapsed_ms); } else { relax_screen(elapsed_ms); } for (i = 0; i < strlen(LEVEL); i++) { if (LEVEL[i] != ' ') { int x = 16 * (i % 13); int y = 16 * (i / 13); draw_image(LEVEL[i] == '-' ? ldata->grass_tile : ldata->earth_tile, x, y, &tile_size, 0); } } draw_sprite(ldata->tree.sprite, 100, 56); draw_sprite(ldata->wizard->sprite, xy(ldata->wizard->pos.x, ldata->wizard->pos.y)); draw_text(ldata->font, fps, 75, 3); }
// This function destroys a non-core process and everything downlinked from it static void noncore_proc_explodes(struct proc_struct* destroyed_pr, int destroyer_team) { /* struct cloud_struct* cl = new_cloud(CLOUD_PROC_EXPLODE, 32, destroyed_pr->position.x, destroyed_pr->position.y); if (cl != NULL) { cl->angle = destroyed_pr->angle; cl->colour = destroyer_team; cl->data [0] = destroyed_pr->shape; cl->speed.x = 0; cl->speed.y = 0; }*/ struct proc_struct* parent_pr = destroyed_pr->group_connection_ptr [0]; int parent_connection_index = destroyed_pr->connected_from [0]; // int parent_downlink_index = destroyed_pr->connected_from_link [0]; // parent_pr->group_connection [parent_connection_index] = NULL; parent_pr->group_connection_exists [parent_connection_index] = 0; procs_destroyed_in_this_explosion = w.core[destroyed_pr->core_index].group_members_current; // subtracted from below int i; for (i = 1; i < GROUP_CONNECTIONS; i++) // Note i starts at 1 (don't destroy uplink) { if (destroyed_pr->group_connection_exists [i]) { destroy_procs_recursively(&w.core[destroyed_pr->core_index], destroyed_pr->group_connection_ptr[i], destroyer_team); } } w.core[destroyed_pr->core_index].group_member[destroyed_pr->group_member_index].exists = 0; // core->group_members--; this is dealt with by set_basic_group_properties() destroy_a_proc(destroyed_pr, destroyer_team); play_game_sound(SAMPLE_BANG, TONE_2C, 60, 10, destroyed_pr->position.x, destroyed_pr->position.y); reset_group_after_composition_change(&w.core[destroyed_pr->core_index]); procs_destroyed_in_this_explosion -= w.core[destroyed_pr->core_index].group_members_current; // fpr("\n procs_destroyed_in_this_explosion %i", procs_destroyed_in_this_explosion); struct cloud_struct* cl = new_cloud(CLOUD_SUB_PROC_EXPLODE, 64, destroyed_pr->position.x, destroyed_pr->position.y); if (cl != NULL) { cl->angle = destroyed_pr->angle; cl->colour = destroyed_pr->player_index; //destroyer_team; cl->data [0] = destroyed_pr->shape; cl->data [1] = procs_destroyed_in_this_explosion; cl->speed.x = 0; cl->speed.y = 0; cl->display_size_x1 = -200; cl->display_size_y1 = -200; cl->display_size_x2 = 200; cl->display_size_y2 = 200; } explosion_fragments(destroyed_pr->position.x, destroyed_pr->position.y, destroyed_pr->speed.x, destroyed_pr->speed.y, 6, destroyed_pr->player_index); explosion_affects_block_nodes(destroyed_pr->position.x, destroyed_pr->position.y, 200 + (procs_destroyed_in_this_explosion * 20), destroyed_pr->player_index); shake_screen(destroyed_pr->position.x, destroyed_pr->position.y, 6 + procs_destroyed_in_this_explosion); }
// This function destroys an entire process from the core. // It then destroys group members using the group_member array rather than recursively through connections, // because the fact that the group no longer exists means that some steps involved in removing a proc from a group can be ignored. void core_proc_explodes(struct proc_struct* core_pr, int destroyer_team) { struct core_struct* core = &w.core[core_pr->core_index]; struct cloud_struct* cl = new_cloud(CLOUD_MAIN_PROC_EXPLODE, 64, core_pr->position.x, core_pr->position.y); if (cl != NULL) { cl->angle = core_pr->angle; cl->colour = core_pr->player_index; cl->data [0] = core_pr->shape; cl->data [1] = core->group_members_current; cl->speed.x = 0; cl->speed.y = 0; cl->display_size_x1 = -300; cl->display_size_y1 = -300; cl->display_size_x2 = 300; cl->display_size_y2 = 300; } explosion_fragments(core_pr->position.x, core_pr->position.y, core_pr->speed.x, core_pr->speed.y, 6, core_pr->player_index); explosion_affects_block_nodes(core_pr->position.x, core_pr->position.y, 200 + (core->group_members_current * 20), core_pr->player_index); int i; remove_core_from_selection(core_pr->core_index); if (templ[core->player_index][core->template_index].first_build_object_member != -1) clear_build_queue_for_core(core->player_index, core->index); if (core->special_AI_type != 0) special_AI_destroyed(core); // this may create a bubble that will be turned into a cloud below. core->exists = 0; core->destroyed_timestamp = w.world_time; if (core->bubble_text_time > w.world_time - BUBBLE_TOTAL_TIME) { // if the core had a bubble, it stays on as a cloud (and refers to bubble data in the core's core_struct, // which should still be usable because the core will be deallocating) struct cloud_struct* bubble_cl = new_cloud(CLOUD_BUBBLE_TEXT, BUBBLE_TOTAL_TIME, core_pr->position.x, core_pr->position.y); if (bubble_cl != NULL) { bubble_cl->created_timestamp = core->bubble_text_time; bubble_cl->destruction_timestamp = bubble_cl->created_timestamp + BUBBLE_TOTAL_TIME; bubble_cl->data [0] = core->index; bubble_cl->display_size_x1 = -300; bubble_cl->display_size_y1 = -40; bubble_cl->display_size_x2 = 300; bubble_cl->display_size_y2 = 40; } } destroy_a_proc(&w.proc[core->process_index], destroyer_team); w.proc[core->process_index].reserved = 0; for (i = 1; i < core->group_members_max; i++) // note for i = 1 { sancheck(core->group_member[i].index, 0, w.max_procs, "core_proc_explodes: core->group_member[i].index"); w.proc[core->group_member[i].index].reserved = 0; // core has been destroyed, so proc no longer reserved if (core->group_member[i].exists) { cl = new_cloud(CLOUD_SUB_PROC_EXPLODE, 64, w.proc[core->group_member[i].index].position.x, w.proc[core->group_member[i].index].position.y); if (cl != NULL) { cl->angle = w.proc[core->group_member[i].index].angle; cl->colour = core->player_index; cl->data [0] = w.proc[core->group_member[i].index].shape; cl->data [1] = 1; cl->speed.x = 0; cl->speed.y = 0; cl->display_size_x1 = -200; cl->display_size_y1 = -200; cl->display_size_x2 = 200; cl->display_size_y2 = 200; } procs_destroyed_in_this_explosion ++; explosion_fragments(w.proc[core->group_member[i].index].position.x, w.proc[core->group_member[i].index].position.y, w.proc[core->group_member[i].index].speed.x, w.proc[core->group_member[i].index].speed.y, 6, core->player_index); destroy_a_proc(&w.proc[core->group_member[i].index], destroyer_team); } } // play_game_sound(SAMPLE_BANG, TONE_2C - (procs_destroyed_in_this_explosion / 3), 100, 10, core->core_position.x, core->core_position.y); int bang_sample = SAMPLE_BANG; if (procs_destroyed_in_this_explosion > 1) bang_sample = SAMPLE_BANG2; play_game_sound(bang_sample, TONE_2C - (procs_destroyed_in_this_explosion / 3), 50, 10, core->core_position.x, core->core_position.y); shake_screen(core->core_position.x, core->core_position.y, 16 + procs_destroyed_in_this_explosion); }