/
Kotopeska
/
RiseUpGame
Обзор
Документация
Войти
/
Kotopeska
/
RiseUpGame
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
model/GameObject.h
58 строк
2 KB
Kotopeska
init
10 май 2025, 17:31
10 май 2025, 17:31
dd8efb4
Код
Авторство
О чём код?
#ifndef GAMEOBJECT_H #define GAMEOBJECT_H #include <string> #include <iostream> namespace Model { class GameObject { private: float m_x, m_y; float m_width, m_height; bool m_active; std::string m_tag; public: GameObject(float x, float y, float width, float height, const std::string &tag = "GameObject") : m_x(x), m_y(y), m_width(width), m_height(height), m_active(true), m_tag(tag) {} virtual ~GameObject() = default; virtual void update() = 0; virtual void reset() {} virtual bool checkCollision(const GameObject &other) const { if (!m_active || !other.m_active) { return false; } bool collision = (m_x < other.m_x + other.m_width && m_x + m_width > other.m_x && m_y < other.m_y + other.m_height && m_y + m_height > other.m_y); return collision; } float getX() const { return m_x; } float getY() const { return m_y; } float getWidth() const { return m_width; } float getHeight() const { return m_height; } bool isActive() const { return m_active; } const std::string &getTag() const { return m_tag; } void setX(float x) { m_x = x; } void setY(float y) { m_y = y; } void setWidth(float width) { m_width = width; } void setHeight(float height) { m_height = height; } void setActive(bool active) { m_active = active; } }; } // namespace Model #endif // GAMEOBJECT_H