commit 33c6f3ccff7b34ccd9a3304955bc242f87efd7f4 Author: YANNIS Date: Thu May 29 16:06:07 2025 +0200 first commit diff --git a/Bomb.hpp b/Bomb.hpp new file mode 100644 index 0000000..401a532 --- /dev/null +++ b/Bomb.hpp @@ -0,0 +1,28 @@ +//Bomb.hpp +#pragma once +#include "Position.hpp" +#include + +class Bomb { + private: + Position _position; + unsigned short _timer; + bool _active; + public: + Bomb(): _position({0, 0}), _timer(3), _active(false) { + std::cout << "Bomb created at default position " << std::endl; + }; + + Bomb(Position position) : _position(position), _timer(3), _active(false) { + std::cout << "Bomb created at " << position << std::endl; + } + + void activate() { _active = true; } + void deactivate() { _active = false; } + bool isActive() const { return _active; } + + void setPosition(Position position) { _position = position; } + Position getPosition() const { return _position; } + + unsigned short getTimer() const { return _timer; } +}; diff --git a/Bomberman.cpp b/Bomberman.cpp new file mode 100644 index 0000000..f9b11e0 --- /dev/null +++ b/Bomberman.cpp @@ -0,0 +1,10 @@ +//Bomberman.cpp +#include "Bomberman.hpp" + +Bomberman::Bomberman(const Position &position, unsigned short numberOfBombs) + : _position(position), _numberOfBombs(numberOfBombs) { + std::cout << "Bomberman created at position (" + << _position.getX() << ", " << _position.getY() + << ") with " << _numberOfBombs + << " bombs!" << std::endl; +} diff --git a/Bomberman.hpp b/Bomberman.hpp new file mode 100644 index 0000000..a09867a --- /dev/null +++ b/Bomberman.hpp @@ -0,0 +1,16 @@ +// Bomberman.hpp +#pragma once +#include +#include "Position.hpp" +#include "Bomb.hpp" +class Bomberman { + + private: + Position _position; + unsigned short _numberOfBombs; + Bomb _bomb; + public: + Bomberman(){std::cout << "Bomberman created!" << std::endl;} + Bomberman(const Position &position, unsigned short numberOfBombs); + ~Bomberman(){std::cout << "Bomberman destroyed!" << std::endl;}; +}; diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1bf3678 --- /dev/null +++ b/Makefile @@ -0,0 +1,23 @@ +NAME = Bomberman + +CC = g++ +CFLAGS = -Wall -Wextra -Werror -g3 + +SRC = main.cpp \ + Bomberman.cpp \ + +OBJ = $(SRC:.cpp=.o) + +all: $(NAME) + +$(NAME): $(OBJ) + $(CC) $(CFLAGS) -o $@ $^ + +$(OBJ): $(SRC) + $(CC) $(CFLAGS) -c $(SRC) -o $@ +clean: + rm -f $(OBJ) +fclean: clean + rm -f $(NAME) +re: fclean all +.PHONY: all clean fclean re diff --git a/Position.hpp b/Position.hpp new file mode 100644 index 0000000..bf99fe0 --- /dev/null +++ b/Position.hpp @@ -0,0 +1,19 @@ +//Position.hpp +#pragma once +#include + +class Position { + private: + int _x; + int _y; + public: + Position() : _x(0), _y(0) {} + ~Position() {} + Position(int x, int y) : _x(x), _y(y) {} + int getX() const { return _x; } + int getY() const { return _y; } + friend std::ostream& operator<<(std::ostream& os, const Position& pos) { + os << "Position(" << pos._x << ", " << pos._y << ")"; + return os; + } +}; diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..83685bc --- /dev/null +++ b/main.cpp @@ -0,0 +1,6 @@ +#include "Bomberman.hpp" + +int main (void){ + Bomberman bomberman; + return 0; +}