MyGameProject::ShortRangeWeapon::ShortRangeWeapon(const Player& _player) :angle(0), MovingObject(_player.pos()), HitableObject(HitBox(ShapeElement::Circle(150), PhysicalState(0,_player.pos()))), player(_player), magnification(0), pow(3) {}
Enemy::Enemy(const Point2D& _initial_pos, Real _initial_angle, Class _enemy_class, const Player& _player, const Shape& _hitbox_shape, std::vector<gp::smart_ptr<Enemy>>& _enemies) :MovingObject(_initial_pos), ang(_initial_angle), HitableObject(HitBox(_hitbox_shape, PhysicalState(_initial_angle, _initial_pos))), player(_player), count(0), enemy_class(_enemy_class), enemies(_enemies), id(id_()++), state_(State::ALIVE) {}
//プレイヤー同士の衝突 void Player::PlayerHitPlayer(int x1, int y1,bool alive1,int direction1){ if (alive1 != FALSE && HitTimer1 < 1){ if (HitBox(x-PLAYER_SIZE/2, y-PLAYER_SIZE/2, x + PLAYER_SIZE/2, y + PLAYER_SIZE/2, x1 - PLAYER_SIZE / 2, y1 - PLAYER_SIZE / 2, x1 + PLAYER_SIZE/2, y1 + PLAYER_SIZE/2) && HitTimer > 4){ Effect::MakeExplosion2(x, y); switch (direction1) { case UP: //y -= 2; direction = UP; if (x + PLAYER_SIZE/2 < x1 - PLAYER_SIZE/2)direction = LEFT; if (x - PLAYER_SIZE / 2 > x1 + PLAYER_SIZE / 2)direction = RIGHT; break; case DOWN: //y += 2; direction = DOWN; if (y1 + PLAYER_SIZE / 2 > y)direction = Hanten(direction); if (x + PLAYER_SIZE / 2 < x1 - PLAYER_SIZE / 2)direction = LEFT; if (x - PLAYER_SIZE / 2 > x1 + PLAYER_SIZE / 2)direction = RIGHT; break; case RIGHT: //x += 2; direction = RIGHT; if (y + PLAYER_SIZE / 2 < y1 - PLAYER_SIZE / 2)direction = UP; if (y - PLAYER_SIZE / 2 > y1 + PLAYER_SIZE / 2)direction = DOWN; break; case LEFT: //x -= 2; direction = LEFT; if (y + PLAYER_SIZE / 2 < y1 - PLAYER_SIZE / 2)direction = UP; if (y - PLAYER_SIZE / 2 > y1 + PLAYER_SIZE / 2)direction = DOWN; break; default: break; } HitTimer1++; HitTimer = 0; MoveFlag = FALSE; } } }
sf::FloatRect UnitIcon::getHitBox(sf::Vector2f& Position) { sf::FloatRect HitBox(Position,sf::Vector2f(64,64)); return HitBox; }