void TreeCommunicator::send_policy(int level, const std::vector<struct geopm_policy_message_s> &policy) { if (level < 0 || level >= num_level() || level == root_level()) { throw Exception("TreeCommunicator::send_policy()", GEOPM_ERROR_LEVEL_RANGE, __FILE__, __LINE__); } else { m_level[level]->send_policy(policy, level_size(level)); } }
void Background::draw(DrawingContext& context) { if(image.get() == NULL) return; Sizef level_size(Sector::current()->get_width(), Sector::current()->get_height()); Sizef screen(SCREEN_WIDTH, SCREEN_HEIGHT); Sizef translation_range = level_size - screen; Vector center_offset(context.get_translation().x - translation_range.width / 2.0f, context.get_translation().y - translation_range.height / 2.0f); // FIXME: We are not handling 'pos' draw_image(context, Vector(level_size.width / 2.0f, level_size.height / 2.0f) + center_offset * (1.0f - speed)); }
void Background::draw(DrawingContext& context) { if(Editor::is_active() && !EditorInputCenter::render_background) return; if(image.get() == NULL) return; Sizef level_size(Sector::current()->get_width(), Sector::current()->get_height()); Sizef screen(SCREEN_WIDTH, SCREEN_HEIGHT); Sizef translation_range = level_size - screen; Vector center_offset(context.get_translation().x - translation_range.width / 2.0f, context.get_translation().y - translation_range.height / 2.0f); float px = has_pos_x ? pos.x : level_size.width/2; float py = has_pos_y ? pos.y : level_size.height/2; draw_image(context, Vector(px, py) + center_offset * (1.0f - speed)); }
/* player_t 와 physicsactor_t 사이의 interface*/ void physics_adapter(player_t *player, player_t **team, int team_size, brick_list_t *brick_list, item_list_t *item_list, object_list_t *object_list) { actor_t *act = player->actor; physicsactor_t *pa = player->pa; obstaclemap_t *obstaclemap; /* 변수들을 변환한다. */ physicsactor_set_position(pa, act->position); if(physicsactor_is_in_the_air(pa) || player_is_getting_hit(player) || player_is_dying(player)) { physicsactor_set_xsp(pa, act->speed.x); physicsactor_set_ysp(pa, act->speed.y); } else { physicsactor_set_gsp(pa, act->speed.x); physicsactor_set_ysp(pa, 0.0f); } /* capturing input */ if(input_button_down(act->input, IB_RIGHT)) physicsactor_walk_right(pa); if(input_button_down(act->input, IB_LEFT)) physicsactor_walk_left(pa); if(input_button_down(act->input, IB_DOWN)) physicsactor_duck(pa); if(input_button_down(act->input, IB_UP)) physicsactor_look_up(pa); if(input_button_down(act->input, IB_FIRE1)) physicsactor_jump(pa); /* obstacle map 생성 */ obstaclemap = obstaclemap_create(); for(; brick_list; brick_list = brick_list->next) { if(brick_list->data->brick_ref->property != BRK_NONE && brick_list->data->enabled && brick_image(brick_list->data) != NULL && !ignore_obstacle(brick_list->data->brick_ref->angle, player->disable_wall, brick_list->data->layer, player->layer)) obstaclemap_add_obstacle(obstaclemap, brick2obstacle(brick_list->data)); } for(; item_list; item_list = item_list->next) { if(item_list->data->obstacle && !ignore_obstacle(0, player->disable_wall, BRL_DEFAULT, player->layer)) obstaclemap_add_obstacle(obstaclemap, item2obstacle(item_list->data)); } for(; object_list; object_list = object_list->next) { if(object_list->data->obstacle && !ignore_obstacle(object_list->data->obstacle_angle, player->disable_wall, BRL_DEFAULT, player->layer)) obstaclemap_add_obstacle(obstaclemap, object2obstacle(object_list->data)); } /* physics actor 업데이트 */ physicsactor_update(pa, obstaclemap); /* obstacle map 삭제 */ obstaclemap = obstaclemap_destroy(obstaclemap); /* can't leave the screen */ if(physicsactor_get_position(pa).x < 20) { physicsactor_set_position(pa, v2d_new(20, physicsactor_get_position(pa).y)); physicsactor_set_xsp(pa, 0.0f); physicsactor_set_gsp(pa, 0.0f); } else if(physicsactor_get_position(pa).x > level_size().x - 20) { physicsactor_set_position(pa, v2d_new(level_size().x - 20, physicsactor_get_position(pa).y)); physicsactor_set_xsp(pa, 0.0f); physicsactor_set_gsp(pa, 0.0f); } /* 변수 unconverting */ act->position = physicsactor_get_position(pa); act->speed = physicsactor_is_in_the_air(pa) || player_is_getting_hit(player) || player_is_dying(player) ? v2d_new(physicsactor_get_xsp(pa), physicsactor_get_ysp(pa)) : v2d_new(physicsactor_get_gsp(pa), 0.0f); /* misc */ act->mirror = !physicsactor_is_facing_right(pa) ? IF_HFLIP : IF_NONE; act->angle = ((int)((256 - physicsactor_get_angle(pa)) * 1.40625f) % 360) * PI / 180.0f; }