-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenemy.cpp
More file actions
41 lines (34 loc) · 809 Bytes
/
Copy pathenemy.cpp
File metadata and controls
41 lines (34 loc) · 809 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
#include "enemy.h"
Enemy::Enemy()
{
tm=0.f;
explode=false;
AbleToMove=true;
markHit=false;
score_b=true;
inv_initX = 0;
inv_initY = 0;
if (!inv_i.loadFromFile("data/ufo2.png")) std::cout << "Failed to load Image" << std::endl;
//else std::cout << "Image loaded" << std::endl;
inv_imgW = inv_i.getSize().x;
inv_imgH = inv_i.getSize().y;
std::cout << inv_imgH << std::endl;
inv.setTexture(inv_i);
}
double Enemy::randrange(double from, double to)
{
double tmp=to-from;
return ((double)rand())/RAND_MAX*tmp+from;
}
void Enemy::SetRand(sf::Vector2f cent)
{
int max_bnd = cent.x+(400-inv_imgW);
int max_h = 600-inv_imgH;
inv_initX=randrange(max_bnd,max_bnd+100);
inv_initY=randrange(1,max_h);
inv.setPosition(inv_initX, inv_initY);
}
//pl_newX/Y
//inv_newX/Y
//pl_imgH/W
//inv_imgH/W