-
Notifications
You must be signed in to change notification settings - Fork 0
/
shot.cpp
73 lines (68 loc) · 1.68 KB
/
shot.cpp
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#pragma once
#include "shot.h"
void AddNewShot(std::vector<Shot> & shotList, Direction & dirLast, Vector2f & pos, float & time, Sprite & sprite_shot, Sprite & sprite_grenade, ShotType shotType) //adding new shot in list
{
Shot shot;
switch (dirLast)
{
case UP:
shot.dir = UP;
break;
case DOWN:
shot.dir = DOWN;
break;
case UPLEFT: case LEFT: case DOWNLEFT:
shot.dir = LEFT;
break;
case UPRIGHT: case RIGHT: case DOWNRIGHT:
shot.dir = RIGHT;
break;
}
Texture texture;
if (shotType == BULLET)
{
//shot.pos = hero.sprite.getPosition();
shot.distance = 0;
shot.sprite = sprite_shot;
shot.type = shotType;
shot.sprite.setPosition(pos);
switch (shot.dir)
{
case UP:
shot.sprite.setTextureRect(IntRect(2, 5, 3, 7));
break;
case RIGHT:
shot.sprite.setTextureRect(IntRect(0, 0, 7, 3));
shot.sprite.setPosition(pos.x, pos.y + 10.f);
break;
case DOWN:
shot.sprite.setTextureRect(IntRect(10, 5, 3, 7));
break;
case LEFT:
shot.sprite.setTextureRect(IntRect(8, 0, 7, 3));
shot.sprite.setPosition(pos.x, pos.y + 10.f);
break;
}
}
else
{
//shot.pos = hero.sprite.getPosition();
shot.distance = 0;
shot.sprite = sprite_grenade;
shot.type = shotType;
shot.startTime = time;
Texture texture;
//AddNewShot(hero, sprite_shot, game);
//shot.sprite.setPosition(hero.sprite.getPosition());
shot.currentFrame = 0;
shot.isExploded = false;
shot.sprite.setPosition(pos);
}
shot.pos = shot.sprite.getPosition();
//cout << "SHOTEEEEEE " << pos.x << " " << pos.y << endl;
shotList.push_back(shot);
};
void DeleteShots(vector<Shot> & shots)
{
shots.clear();
}