Deuxieme commit
This commit is contained in:
@@ -10,11 +10,9 @@ class Bomb {
|
|||||||
bool _active;
|
bool _active;
|
||||||
public:
|
public:
|
||||||
Bomb(): _position({0, 0}), _timer(3), _active(false) {
|
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) {
|
Bomb(Position position) : _position(position), _timer(3), _active(false) {
|
||||||
std::cout << "Bomb created at " << position << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void activate() { _active = true; }
|
void activate() { _active = true; }
|
||||||
|
|||||||
@@ -1,10 +1,3 @@
|
|||||||
//Bomberman.cpp
|
//Bomberman.cpp
|
||||||
#include "Bomberman.hpp"
|
#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;
|
|
||||||
}
|
|
||||||
|
|||||||
+7
-2
@@ -7,10 +7,15 @@ class Bomberman {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Position _position;
|
Position _position;
|
||||||
unsigned short _numberOfBombs;
|
unsigned short _maxNumberOfBombs = 1;
|
||||||
|
unsigned short _numberOfBombsPlanted = 0;
|
||||||
Bomb _bomb;
|
Bomb _bomb;
|
||||||
public:
|
public:
|
||||||
Bomberman(){std::cout << "Bomberman created!" << std::endl;}
|
Bomberman(){std::cout << "Bomberman created!" << std::endl;}
|
||||||
Bomberman(const Position &position, unsigned short numberOfBombs);
|
|
||||||
~Bomberman(){std::cout << "Bomberman destroyed!" << std::endl;};
|
~Bomberman(){std::cout << "Bomberman destroyed!" << std::endl;};
|
||||||
|
int plantBomb();
|
||||||
|
friend std::ostream& operator<<(std::ostream &os, const Bomberman &bomberman) {
|
||||||
|
os << "Bomberman at " << bomberman._position << ", Number of bombs: " << bomberman._numberOfBombs;
|
||||||
|
return os;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,13 +8,15 @@ SRC = main.cpp \
|
|||||||
|
|
||||||
OBJ = $(SRC:.cpp=.o)
|
OBJ = $(SRC:.cpp=.o)
|
||||||
|
|
||||||
all: $(NAME)
|
|
||||||
|
|
||||||
$(NAME): $(OBJ)
|
$(NAME): $(OBJ)
|
||||||
$(CC) $(CFLAGS) -o $@ $^
|
$(CC) $(CFLAGS) -o $@ $(OBJ)
|
||||||
|
|
||||||
$(OBJ): $(SRC)
|
$(OBJ): $(SRC)
|
||||||
$(CC) $(CFLAGS) -c $(SRC) -o $@
|
$(CC) $(CFLAGS) -c $(SRC)
|
||||||
|
|
||||||
|
all: $(NAME)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(OBJ)
|
rm -f $(OBJ)
|
||||||
fclean: clean
|
fclean: clean
|
||||||
|
|||||||
Reference in New Issue
Block a user