forked from luckymark/CCpp2017
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBullet.cpp
More file actions
42 lines (37 loc) · 712 Bytes
/
Bullet.cpp
File metadata and controls
42 lines (37 loc) · 712 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
41
42
#include "stdafx.h"
#include "Bullet.h"
#include "game.h"
//extern int head;
//extern int tail;
//extern bool empty;
extern sf::RenderWindow mainWindow;
Bullet::Bullet()
{
if (image.loadFromFile("images/bullet1.png") != true)
{
return;
}
}
void Bullet::draw()
{
sf::Sprite sprite(image);
sprite.setOrigin(BulletPointX, BulletPointY);
mainWindow.draw(sprite);
}
void Bullet::move(float timeDelta)
{
if (BulletPointY < 0)
{
BulletPointY = BulletPointY + 100*timeDelta;
}
else
{
Game::tail = (Game::tail + 1) % bulnumber;
Game::empty = true;
}
}
void Bullet::UseBullet()
{
BulletPointX = Plane::pointX - 30;
BulletPointY = Plane::pointY + 50;
}