-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBullet.cpp
More file actions
40 lines (33 loc) · 887 Bytes
/
Bullet.cpp
File metadata and controls
40 lines (33 loc) · 887 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 "Bullet.h"
#include "Myengine/ResourceManager.h"
Bullet::Bullet(glm::vec2 pos, glm::vec2 dir, float speed, int lifeTime)
{
_position = pos;
_direction = dir;
_speed = speed;
_lifeTime = lifeTime;
}
Bullet::~Bullet()
{
}
void Bullet::draw(Myengine::SpriteBatch &spriteBatch)
{
glm::vec4 uv(0.0f, 0.0f, 1.0f, 1.0f);
static Myengine::GLTexture texture = Myengine::ResourceManager::getTexture("textures/jimmy-jump-pack/PNG/CharacterRight_Standing.png");
Myengine::ColorRGBA8 color;
color.r = 255;
color.g = 255;
color.b = 255;
color.a = 255;
glm::vec4 posAndSize = glm::vec4(_position.x, _position.y, 30, 30);
spriteBatch.draw(posAndSize, uv, texture.id, 0.0f, color);
}
bool Bullet::update()
{
_position += _direction * _speed;
_lifeTime--;
if (_lifeTime == 0) {
return true;
}
return false;
}