mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Missiles add spaceship vel; point in direction fired.
This issue was visible as crooked missiles when firing in a direction other than that of travel, and being able to keep pace with fired missiles.
This commit is contained in:
parent
a1c106ce1c
commit
46efe8923f
1 changed files with 6 additions and 4 deletions
|
@ -483,7 +483,7 @@ void AsteroidField::Think(float deltatime)
|
|||
class Missile : public Actor
|
||||
{
|
||||
public:
|
||||
Missile(Vector pos, Vector vel, float ttl);
|
||||
Missile(Vector pos, Vector vel, Vector direction, float ttl);
|
||||
virtual bool IsA(const char* classname)
|
||||
{
|
||||
return !strcmp(classname, "Missile") || Actor::IsA(classname);
|
||||
|
@ -494,14 +494,16 @@ public:
|
|||
|
||||
private:
|
||||
float ttl;
|
||||
Vector direction;
|
||||
|
||||
};
|
||||
|
||||
Missile::Missile(Vector pos, Vector vel, float ttl)
|
||||
Missile::Missile(Vector pos, Vector vel, Vector direction, float ttl)
|
||||
{
|
||||
this->pos = pos;
|
||||
this->vel = vel;
|
||||
this->ttl = ttl;
|
||||
this->direction = direction;
|
||||
}
|
||||
|
||||
void Missile::Think(float deltatime)
|
||||
|
@ -525,7 +527,7 @@ void Missile::Render()
|
|||
uint32_t shipcolor = MakeColor(31, 255, 31);
|
||||
const float MISSILE_LEN = 5.0f;
|
||||
Vector from = screenpos;
|
||||
Vector to = screenpos + vel * (MISSILE_LEN / vel.Size());
|
||||
Vector to = screenpos + direction * (MISSILE_LEN / direction.Size());
|
||||
DrawLine(shipcolor, from.x, from.y, to.x, to.y);
|
||||
}
|
||||
|
||||
|
@ -609,7 +611,7 @@ void Spaceship::Think(float deltatime)
|
|||
const Vector P3(16.0f, 0.0f);
|
||||
Vector spawnpos = pos + P3.Rotate(shipangle) * 1.1;
|
||||
Vector spawnvel = Vector(speed, 0.0).Rotate(shipangle);
|
||||
new Missile(spawnpos, spawnvel, ttl);
|
||||
new Missile(spawnpos, vel + spawnvel, spawnvel, ttl);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue