1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 /* 3 * Bomb-her-man 4 * Copyright (C) Marc-Antoine Perennou 2010 <Marc-Antoine@Perennou.com> 5 * Copyright (C) Hugo Mougard 2010 <mogzor@gmail.com> 6 * Copyright (C) Sardem FF7 2010 <sardemff7.pub@gmail.com> 7 * 8 * Bomb-her-man is free software: you can redistribute it and/or modify it 9 * under the terms of the GNU General Public License as published by the 10 * Free Software Foundation, either version 3 of the License, or 11 * (at your option) any later version. 12 * 13 * Bomb-her-man is distributed in the hope that it will be useful, but 14 * WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 * See the GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License along 19 * with this program. If not, see <http://www.gnu.org/licenses/>. 20 */ 21 22 #ifndef _ATOMICCENTER_HPP 23 #define _ATOMICCENTER_HPP 24 25 #include <ios> 26 #include <iostream> 27 #include <SDL.h> 28 29 #include "display/display.hpp" 30 #include "game/player.hpp" 31 #include "map/map.hpp" 32 #include "map/map-utils.hpp" 33 #include "bomb.hpp" 34 35 namespace bombherman 36 { 37 namespace bomb 38 { 39 /// Class used to manage Bombs 40 class AtomicCenter 41 { 42 public: 43 /// Plant a bomb 44 /** 45 * @param player The id of the player who planted the bomb (int) 46 * @param c The coords where the bomb has been planted (map::Coords) 47 * @param range The range of the bomb's explosion (Uint32) 48 * 49 * @return True if a bomb has been planted 50 */ 51 static bool plantBomb (int player, map::Coords & c, Uint32 range); 52 53 /// Remove a bomb 54 /* 55 * @param c The coords of the bomb to remove (map::Coords) 56 */ removeBomb(map::Coords & c)57 static void removeBomb (map::Coords & c) { bombs[c.x][c.y] = NULL; } 58 59 /// Get a bomb by its coords 60 /* 61 * @param c The coords where you're looking for a bomb (map::Coords) 62 * 63 * @return A pointer to the bomb (Bomb *) 64 */ getBomb(map::Coords & c)65 static Bomb * getBomb (map::Coords & c) { return bombs[c.x][c.y]; } 66 67 /// Make everything explode 68 static void boum(); 69 70 /// Decrease the number of bombs still alive bombExploded()71 static void bombExploded() { --AtomicCenter::numberOfBombs; } 72 private: 73 static std::vector< std::vector< Bomb * > > bombs; 74 static int numberOfBombs; 75 }; 76 } 77 } 78 79 #endif /* _ATOMICCENTER_HPP */ 80 81