Files
cppcourse/397/SolutionEx21/Light.cpp
T
2026-10-05 11:27:21 +02:00

22 lines
615 B
C++

#include "Light.h"
#include "Pelican.h"
#include "Screen.h"
#include <iostream>
Light::Light(std::string name, int x, int y, int color) : x(x), y(y), c(color), name(name) {}
Light::~Light() {
std::cout << "Deleting light (" << name << ", " << x << ", " << y << ", " << c << ")"
<< "\n";
}
void Light::set(LightState newState) {
state = newState;
Screen::write(name.c_str(), x, y, state == FLASH ? (128 + c) : (state == OFF ? 0 : c));
// 128 + color was used to make a character flash (but not any more)
}
Light::LightState Light::get(void) { return state; }