-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProjectile.cpp
More file actions
41 lines (32 loc) · 876 Bytes
/
Projectile.cpp
File metadata and controls
41 lines (32 loc) · 876 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "stdafx.h"
#include "Projectile.h"
using namespace LarasEngine;
Projectile::Projectile (int x, int y, double r, TypId id)
: GameObject (x, y, id)
, lifetime (0.0)
{
path.setP1 (QPointF (0.f, 0.f));
SetRotation (std::floor (r));
}
void Projectile::Update ()
{
double lag = TimeInfo::Me ().GetFactor ();
lifetimeMs += TimeInfo::Me().GetFrameTime ();
lifetime += lag;
Translate (path.p2() * lag);
if (!launchVelocity.isNull ())
Translate (launchVelocity * lag);
QRectF rect = GetImageRect ();
deleteMe = (rect.y () <= 0 && rect.y () >= screenH);
}
void LarasEngine::Projectile::SetLaunchVelocity (QPointF p)
{
launchVelocity = p;
//Translate (p * TimeInfo::Me ().GetFactor ());
}
void LarasEngine::Projectile::ReadJson (const QJsonObject& json)
{
GameObject::ReadJson (json);
path.setP2 (velocity);
path.setAngle (path.angle () - rotation);
}