/** * \brief Create the item representing a new power. * \param fill_color The color inside the effect. * \param border_color The color of the border of the effect. */ void ptb::power_effect::show_change_effect ( const bear::visual::color& fill_color, const bear::visual::color& border_color ) { bear::star* new_decoration = new bear::star( 16, 1, border_color, 2, fill_color ); new_decoration->set_z_position(get_z_position() - 10); new_decoration->set_size( 160, 160 ); new_item( *new_decoration ); new_decoration->set_center_of_mass(get_center_of_mass()); const bear::universe::time_type d(0.5); bear::universe::forced_tracking mvt(d); mvt.set_reference_point_on_center( *this ); new_decoration->set_forced_movement(mvt); bear::decorative_effect* decoration_effect = new bear::decorative_effect; decoration_effect->set_duration(d); bear::visual::color init_color, end_color; init_color.set(1,1,1,1); end_color.set(1,1,1,0); decoration_effect->set_color( init_color, end_color ); decoration_effect->set_item(new_decoration, true); new_item( *decoration_effect ); } // power_effect::show_change_effect()
int main (void) { int i, j, res; for (i = 0; i < NMAX; i++) for (j = 0; j < NMAX; j++) a[i][j] = i + j; for (i = 0; i < NMAX; i++) { x1[i] = 0; x2[i] = 2*i; y1[i] = 100 - i; y2[i] = i; } res = mvt (NMAX); #if DEBUG fprintf (stderr, "res = %d \n", res); #endif if (res != 199900000) abort (); return 0; }
/** * \brief Create item. */ void rp::zeppelin::create_item() { base_item* const item = m_item->clone(); item->set_top_middle( get_mark_world_position("anchor") ); item->set_global( is_global() ); entity* e = dynamic_cast<entity*>( m_item ); if ( e != NULL ) item->set_z_position(get_z_position() + 1); new_item( *item ); m_drop_item = handle_type(item); bear::universe::forced_tracking mvt ( item->get_center_of_mass() - get_center_of_mass() ); mvt.set_reference_point_on_center( *this ); mvt.set_auto_remove(true); item->set_forced_movement( mvt ); } // zeppelin::create_item()
int main (void) { int i, j, res; for (i = 0; i < NMAX; i++) for (j = 0; j < NMAX; j++) a[i][j] = j; for (i = 0; i < NMAX; i++) x[i] = i; res = mvt (NMAX); #if DEBUG fprintf (stderr, "res = %d \n", res); #endif if (res != 2001) abort (); return 0; }
Movement::Movement(const xmlNode* xml) : ref_count(1), nb_loops(0), duration_per_frame(15), always_moving(false) { XmlReader::ReadStringAttr(xml, "name", type); ASSERT(type != ""); MSG_DEBUG("body.movement", " Loading movement %s", type.c_str()); XmlReader::ReadUintAttr(xml, "duration_per_frame", duration_per_frame); XmlReader::ReadUintAttr(xml, "nb_loops", nb_loops); // Load the test rectangle test_left = test_right = test_top = test_bottom = 0; const xmlNode* collision_rect = XmlReader::GetMarker(xml, "collision_rect"); if (!collision_rect) { fprintf(stderr, "No collision rect for %s\n", type.c_str()); return; } XmlReader::ReadUintAttr(collision_rect, "left", test_left); XmlReader::ReadUintAttr(collision_rect, "right", test_right); XmlReader::ReadUintAttr(collision_rect, "top", test_top); XmlReader::ReadUintAttr(collision_rect, "bottom", test_bottom); MSG_DEBUG("body.movement", "Collision rect set to (%u,%u) -> (%u,%u)\n", test_left, test_top, test_left, test_bottom); xmlNodeArray nodes = XmlReader::GetNamedChildren(xml, "frame"); xmlNodeArray::const_iterator it = nodes.begin(), end = nodes.end(); MSG_DEBUG("body.movement", " Found "SIZET_FORMAT"u movement frames", nodes.size()); MSG_DEBUG("body.movement", " Nb loops: %i", nb_loops); // We know the number of member frames that will be read, // so we can set set the array size now frames.reserve(nodes.size()); for (; it != end; ++it) { xmlNodeArray members = XmlReader::GetNamedChildren(*it, "member"); MSG_DEBUG("body.movement", " Found "SIZET_FORMAT"u frame members", members.size()); member_def def; def.reserve(members.size()); xmlNodeArray::const_iterator it2; for (it2 = members.begin(); it2 != members.end(); ++it2) { const xmlNode *child = *it2; std::string member_type; XmlReader::ReadStringAttr(child, "type", member_type); member_mvt mvt(member_type); int dx = 0, dy = 0, angle_deg = 0; Double scale_x = ONE, scale_y = ONE, tmp_alpha = ONE; XmlReader::ReadIntAttr(child, "dx", dx); XmlReader::ReadIntAttr(child, "dy", dy); XmlReader::ReadDoubleAttr(child, "scale_x", scale_x); XmlReader::ReadDoubleAttr(child, "scale_y", scale_y); XmlReader::ReadDoubleAttr(child, "alpha", tmp_alpha); XmlReader::ReadIntAttr(child, "angle", angle_deg); XmlReader::ReadBoolAttr(child, "follow_crosshair", mvt.follow_crosshair); XmlReader::ReadBoolAttr(child, "follow_half_crosshair", mvt.follow_half_crosshair); XmlReader::ReadBoolAttr(child, "follow_speed", mvt.follow_speed); XmlReader::ReadBoolAttr(child, "follow_direction", mvt.follow_direction); XmlReader::ReadIntAttr(child, "follow_cursor_square_limit", mvt.follow_cursor_square_limit); if (tmp_alpha < ZERO || tmp_alpha > ONE) tmp_alpha = 1.0; mvt.SetAngle(angle_deg * PI / 180); mvt.pos.x = dx; mvt.pos.y = dy; mvt.alpha = tmp_alpha; mvt.scale.x = scale_x; mvt.scale.y = scale_y; always_moving |= mvt.follow_cursor_square_limit!=0; always_moving |= mvt.follow_crosshair; always_moving |= mvt.follow_half_crosshair; always_moving |= mvt.follow_speed; always_moving |= mvt.follow_direction; def.push_back(mvt); } frames.push_back(def); } }