-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSwitch.cpp
More file actions
43 lines (34 loc) · 1.02 KB
/
Copy pathSwitch.cpp
File metadata and controls
43 lines (34 loc) · 1.02 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
//////////////////////////////////////// INCLUDES & FORWARDS //////////////////////////////////////////
#include "Switch.h"
#include "Room.h"
////////////////////////////////////////// toggle //////////////////////////////////////////
void Switch::toggle()
{
isOn = !isOn;
if (isOn)
{
sprite = '/';
type = ObjectType::SWITCH_ON;
}
else
{
sprite = '\\';
type = ObjectType::SWITCH_OFF;
}
}
////////////////////////////////////////// setIsOn //////////////////////////////////////////
void Switch::setIsOn(bool on)
{
isOn = on;
sprite = isOn ? '/' : '\\';
type = isOn ? ObjectType::SWITCH_ON : ObjectType::SWITCH_OFF;
}
////////////////////////////////////////// onInteract //////////////////////////////////////////
bool Switch::onInteract(Player *player, Room *room)
{
if (player == nullptr || room == nullptr) return false;
toggle();
draw();
room->updatePuzzleState();
return true;
}