-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathslot.cpp
More file actions
54 lines (49 loc) · 1.63 KB
/
slot.cpp
File metadata and controls
54 lines (49 loc) · 1.63 KB
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
/* Jacoby King
* 11/08/2022
* CIS164 Final Project
*/
#include "slot.h"
//Slot object constructor
Slot::Slot()
{
//Setting the Slot object to the first QPixmap position
slotPosition = 0;
setPixmap(chipPosition);
//Initializing and connecting the slotPositionTimer to the updatePixmap() slot
slotPositionTimer = new QTimer();
connect(slotPositionTimer, SIGNAL(timeout()), this, SLOT(updatePixmap()));
}
//Slot, used to update the Pixmap of the object
void Slot::updatePixmap()
{
//If the slotPosition equals zero, that means it is currently at chipPosition, therefor change it to coinPosition and adjust the slotPosition
if(slotPosition == 0){
setPixmap(coinPosition);
slotPosition = 1;
}
//If the slotPosition equals one, that means it is currently at coinPosition, therefor change it to dicePosition and adjust the slotPosition
else if(slotPosition == 1){
setPixmap(dicePosition);
slotPosition = 2;
}
//If the slotPosition equals 2, that means it is currently at dicePosition, therefor change it to chipPosition and adjust the slotPosition
else if(slotPosition == 2){
setPixmap(chipPosition);
slotPosition = 0;
}
}
//Called for each Slot when the slot machine is spun, starts slotPositionTimer
void Slot::startSlot()
{
slotPositionTimer->start(85);
}
//Called for each Slot when the slot machine is spun after a delay, stops slotPositionTimer
void Slot::stopSlot()
{
slotPositionTimer->stop();
}
//Called when there is a win, updates the Pixmap
void Slot::win()
{
setPixmap(winPosition);
}