// Add values to the distance and angles void Direction::Add_Direction(const float in_distance, const float in_angle_x, const float in_angle_y) { Set_Direction(distance + in_distance, Get_X_Angle() + in_angle_x, Get_Y_Angle() + in_angle_y); return; }
void cEato::Create_From_Stream(XMLElement* attributes) { int posx = 0, posy = 0; std::string image_dir = m_img_dir; std::string direction = Get_Direction_Name(m_start_direction); for (XMLElement* node = attributes->FirstChildElement(); node; node = node->NextSiblingElement()) { const char* name = node->Attribute("name"); const char* value = node->Attribute("value"); if (!strcmp(name, "posx")) { posx = atoi(value); } else if (!strcmp(name, "posy")) { posy = atoi(value); } else if (!strcmp(name, "image_dir")) { image_dir = value; } else if (!strcmp(name, "direction")) { direction = value; } } Set_Pos(static_cast<float>(posx), static_cast<float>(posy), 1); Set_Image_Dir(image_dir.c_str()); Set_Direction(Get_Direction_Id(direction.c_str())); }
void cRokko :: Init( void ) { m_type = TYPE_ROKKO; m_massive_type = MASS_PASSIVE; m_pos_z = 0.03f; m_editor_pos_z = 0.09f; m_can_be_on_ground = 0; m_player_range = 4000; Set_Rotation_Affects_Rect( 1 ); Set_Active( 0 ); m_fire_resistant = 0; m_ice_resistance = 1; m_can_be_hit_from_shell = 0; Set_Direction( DIR_LEFT ); Set_Speed( 8.5f ); m_min_distance_front = 200; Set_Max_Distance_Front( 1000 ); Set_Max_Distance_Sides( 400 ); m_state = STA_STAY; m_smoke_counter = 0; m_kill_sound = "enemy/rokko/hit.wav"; m_kill_points = 250; m_life_left = 500; }
bool cRokko::Editor_Direction_Select(const CEGUI::EventArgs& event) { const CEGUI::WindowEventArgs& windowEventArgs = static_cast<const CEGUI::WindowEventArgs&>(event); CEGUI::ListboxItem* item = static_cast<CEGUI::Combobox*>(windowEventArgs.window)->getSelectedItem(); Set_Direction(Get_Direction_Id(item->getText().c_str())); return 1; }
void cSpikeball :: Create_From_Stream( CEGUI::XMLAttributes &attributes ) { // position Set_Pos( static_cast<float>(attributes.getValueAsInteger( "posx" )), static_cast<float>(attributes.getValueAsInteger( "posy" )), 1 ); // color Set_Color( static_cast<DefaultColor>(Get_Color_Id( attributes.getValueAsString( "color", Get_Color_Name( m_color_type ) ).c_str() )) ); // direction Set_Direction( Get_Direction_Id( attributes.getValueAsString( "direction", Get_Direction_Name( m_start_direction ) ).c_str() ) ); }
// Set the coordinates of the direction void Direction::Set_Coordinates(const float x, const float y, const float z) { float Z = z * -1; Set_Direction( (float) (sqrt(x*x + y*y + Z*Z)), (float) (atan2(x, Z) * DEGREES_PER_RADIAN), (float) (atan2(y, sqrt(x*x + Z*Z)) * DEGREES_PER_RADIAN)); return; }
void cRokko :: Create_From_Stream( CEGUI::XMLAttributes &attributes ) { // position Set_Pos( static_cast<float>(attributes.getValueAsInteger( "posx" )), static_cast<float>(attributes.getValueAsInteger( "posy" )), 1 ); // direction Set_Direction( Get_Direction_Id( attributes.getValueAsString( "direction", Get_Direction_Name( m_start_direction ) ).c_str() ) ); // speed Set_Speed( attributes.getValueAsFloat( "speed", m_speed ) ); }
cRokko::cRokko(XmlAttributes& attributes, cSprite_Manager* sprite_manager) : cEnemy(sprite_manager) { cRokko::Init(); // position Set_Pos(string_to_float(attributes["posx"]), string_to_float(attributes["posy"]), true); // direction Set_Direction(Get_Direction_Id(attributes.fetch("direction", Get_Direction_Name(m_start_direction)))); // speed Set_Speed(string_to_float(attributes.fetch("speed", float_to_string(m_speed)))); }
void cEato::Init(void) { m_type = TYPE_EATO; m_player_range = 1000; m_pos_z = 0.087f; m_can_be_on_ground = 0; Set_Rotation_Affects_Rect(1); m_fire_resistant = 1; m_state = STA_STAY; Set_Image_Dir("enemy/eato/brown/"); Set_Direction(DIR_UP_LEFT); m_kill_sound = "enemy/eato/die.ogg"; m_kill_points = 150; }
void cSpikeball :: Init( void ) { m_type = TYPE_SPIKEBALL; m_pos_z = 0.09f; m_gravity_max = 29.0f; m_counter_stay = 0.0f; m_counter_walk = 0.0f; m_counter_running = 0.0f; m_running_particle_counter = 0.0f; m_color_type = COL_DEFAULT; Set_Color( COL_GREY ); m_state = STA_FALL; Set_Moving_State( STA_WALK ); Set_Direction( DIR_RIGHT ); }
cFlyon::cFlyon(XmlAttributes& attributes, cSprite_Manager* sprite_manager) : cEnemy(sprite_manager) { cFlyon::Init(); // position Set_Pos(string_to_float(attributes["posx"]), string_to_float(attributes["posy"]), true); // image directory Set_Image_Dir(utf8_to_path(attributes.fetch("image_dir", path_to_utf8(m_img_dir)))); // direction Set_Direction(Get_Direction_Id(attributes.fetch("direction", Get_Direction_Name(m_start_direction)))); // max distance Set_Max_Distance(string_to_int(attributes.fetch("max_distance", int_to_string(m_max_distance)))); // speed Set_Speed(string_to_float(attributes.fetch("speed", float_to_string(m_speed)))); }
void cRokko::Init(void) { m_type = TYPE_ROKKO; m_name = "Rokko"; m_massive_type = MASS_PASSIVE; m_pos_z = 0.03f; m_gravity_max = 0; m_editor_pos_z = 0.09f; m_can_be_on_ground = 0; m_camera_range = 4000; Set_Rotation_Affects_Rect(1); Set_Active(0); m_fire_resistant = 1; m_ice_resistance = 1; m_can_be_hit_from_shell = 0; Set_Direction(DIR_LEFT); Set_Speed(8.5f); m_min_distance_front = 200; Set_Max_Distance_Front(1000); Set_Max_Distance_Sides(400); m_state = STA_STAY; m_manual = false; m_smoke_counter = 0; m_kill_sound = "enemy/rokko/hit.wav"; m_kill_points = 250; Add_Image(pVideo->Get_Surface("enemy/rokko/yellow/fly_1.png")); Add_Image(pVideo->Get_Surface("enemy/rokko/yellow/fly_2.png")); Add_Image(pVideo->Get_Surface("enemy/rokko/yellow/fly_3.png")); Add_Image(pVideo->Get_Surface("enemy/rokko/yellow/break_1.png")); Add_Image(pVideo->Get_Surface("enemy/rokko/yellow/break_2.png")); Add_Image(pVideo->Get_Surface("enemy/rokko/yellow/break_3.png")); Set_Image_Num(0, true); Set_Animation(true); Set_Animation_Image_Range(0, 2); Set_Time_All(130, true); }
void cFlyon::Init(void) { m_type = TYPE_FLYON; m_name = "Flyon"; m_pos_z = 0.06f; Set_Rotation_Affects_Rect(1); m_editor_pos_z = 0.089f; m_camera_range = 1000; m_can_be_on_ground = 0; m_can_be_ground = 0; m_state = STA_STAY; Set_Direction(DIR_UP); Set_Image_Dir(utf8_to_path("enemy/flyon/orange/")); Set_Max_Distance(200); Set_Speed(5.8f); m_kill_sound = "enemy/flyon/die.ogg"; m_kill_points = 100; m_wait_time = Get_Random_Float(0.0f, 70.0f); m_move_back = 0; }
//! initialize port, timers, and initial direction void BLDC3PhaseSensor::Motor_init() { cli(); //MCUCR |= (1<<PUD); // Disable all pull-ups // Init_MC_timers(); Init_MC_timer1_pwm(); // Timer1 used to generate PWM Init_MC_pin_change_interrupt(); // init pin for hall interrupt //Set initial direction. Set_Direction(direction); // bring up output PWM pins // initiate commutation EIFR=EIFR; sei(); hallService->service(); /* *ddr_hall |= hall_mask; //Lock HALL sensor by driving Hall lines *port_hall |= hall_mask; *port_hall &= ~hall_mask; //Release HALL sensor lines and trigger PC interrupt *ddr_hall &= ~hall_mask; EIFR=EIFR; sei(); DDRB|=0xFF; */ }
// Construct a new direction based off of distance and 2 angles Direction::Direction(const float in_distance, const float in_angle_x, const float in_angle_y) { Set_Direction(in_distance, in_angle_x, in_angle_y); return; }
// Make the distance 1 void Direction::Normalize(const float unit) { Set_Direction(unit, Get_X_Angle(), Get_Y_Angle()); }