-
Notifications
You must be signed in to change notification settings - Fork 0
/
Fleet_Move.cpp
45 lines (37 loc) · 1.37 KB
/
Fleet_Move.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
#include "Fleet_Move.h"
void move_blue(int, std::vector < Alien_Blue > &, int);
void move_red(int, std::vector < Alien_Red > &, int);
void move_gold(int, std::vector < Alien_Gold > &, int);
void move_purple(int, std::vector < Alien_Purple > &, int);
void fleet_move(int & direction,
std::vector < Alien_Blue > & fleet_blue,
std::vector < Alien_Red > & fleet_red,
std::vector < Alien_Gold> & fleet_gold,
std::vector < Alien_Purple > & fleet_purple)
{
if (fleet_blue[0].x() <= 0) direction = -direction;
if (fleet_blue[10].x() >= W - fleet_blue[0].w() - 10) direction = -direction;
for (int i = 0; i < 22; ++i)
{
move_blue(direction, fleet_blue, i);
if (i < 9) move_red(direction, fleet_red, i);
if (i < 3)move_gold(direction, fleet_gold, i);
if (i < 6)move_purple(direction, fleet_purple, i);
}
}
void move_blue(int direction, std::vector < Alien_Blue > & fleet_blue, int i)
{
fleet_blue[i].move(direction);
}
void move_red(int direction, std::vector < Alien_Red > & fleet_red, int i)
{
fleet_red[i].move(direction);
}
void move_gold(int direction, std::vector < Alien_Gold > & fleet_gold, int i)
{
fleet_gold[i].move(direction);
}
void move_purple(int direction, std::vector < Alien_Purple > & fleet_purple, int i)
{
fleet_purple[i].move(direction);
}