-
Notifications
You must be signed in to change notification settings - Fork 0
/
blueshell.cpp
65 lines (58 loc) · 1.33 KB
/
blueshell.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
#include "blueshell.h"
/* Constructor for a blue shell, sets velocity to 1
@param pm Pixmap pointer to show picture
@param nx Initial x cooridinate to set position
@param ny Initial y coordinate to set poition **/
BlueShell:: BlueShell(QPixmap *pm, int nx, int ny) : Thing(pm,nx,ny)
{
*pm = pm->scaled(50, 50, Qt::KeepAspectRatio);
vX = 1;
vY = 1;
}
/* Default destructor **/
BlueShell :: ~BlueShell()
{}
/* Checks counter and sets velocities and updates position based on where item should be in square cycle **/
void BlueShell:: move()
{
if(counter <= 150)
{
x+=vX;
}
if(counter > 150 && counter <= 300)
{
y+=vY;
}
if(counter > 300 && counter <= 450)
{
x-=vX;
}
if(counter > 450)
{
y-=vY;
}
setPos(x,y);
}
/* @return 2-- tells switch in MainWindow to execute blue shell collision **/
int BlueShell:: executePower()
{
return 2;
}
/* Sets the vX variable of the item, used for velocity
@param nvx An int passed into from MainWindow **/
void BlueShell:: setvX(int nvx)
{
vX= nvx;
}
/* Sets the vY variable of the item, used for velocity
@param nvx An int passed into from MainWindow **/
void BlueShell:: setvY(int nvy)
{
vY = nvy;
}
/* Sets the counter to be used for square path in move()
@param counter1 a counter passed by MainWindow **/
void BlueShell:: setCounter(int counter1)
{
counter = counter1;
}