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

21 lines
649 B
C++

#include "Light.h"
#include "CursesObj.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 << ")" << std::endl;
std::cout.flush();
}
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; }