я новичок в программировании, и я должен сделать для игры, мы кодируем выстрел из дробовика, но у нас есть проблема, и я не знаю, как это сделать
Я хочу добавить в игру пулю, чтобы при стрельбе она разбивалась на несколько маленьких пуль в разных направлениях, так что в основном выстрел из дробовика.
У меня уже есть нормальная пуля с его положением, вектором и скоростью, и вы уже можете стрелять. но моя проблема в том, или я не понимаю, как я могу разделить одну пулю после того, как я выстрелил в нее несколькими пулями, и как каждая из них получает свое положение и вектор перемещения
Bullet class{
Vector2 moveVector;
float speed =15;
public void setMoveVector(float x, float y) {
moveVector = new Vector2(x,y);}
// in that area here its for the bullet how it moving/acting including if the path is free or blocked by walls or something
if(map.pathFree(getX(), getY(), getX()+ moveVector.x * speed, getY() + moveVector.y * speed, this)) {
setPosition(getX() + moveVector.x * speed, getY() + moveVector.y * speed);
//somewhere here sould come the code splitting the bullet
//removing the bullet after a distance
DistanceIndex += speed;
if(DistanceIndex >= 1000) {
remove();
}
}
else
HitWall();
if(outsideMap()) this.remove();
}
....
}
Obj Class
//class/object/gamefigure using/creating the bullet
.....
public void shootingMethod(){
......
double direction_x = Math.cos(Math.toRadians(rotation));
double direction_y = Math.sin(Math.toRadians(rotation));
Bullet bullet = new Bullet();
....
bullet.setMoveVector((float)direction_x, (float)directoin_y);
}
Изображение моей проблемы, я имею в виду