X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fobject%2Fblock.h;h=2989ad85c0776f99f124ae807c95d5941371f026;hb=c0093d25093395cb62fc2526ab42be65a9f015b8;hp=bd750a02687052635b44086e90483e9a6fabf1ac;hpb=d46c78c842ab4090a3f46e560c891234167f124b;p=supertux.git diff --git a/src/object/block.h b/src/object/block.h index bd750a026..2989ad85c 100644 --- a/src/object/block.h +++ b/src/object/block.h @@ -1,11 +1,30 @@ -#ifndef __BOX_H__ -#define __BOX_H__ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. -#include "special/moving_object.h" +#ifndef __BLOCK_H__ +#define __BLOCK_H__ -namespace SuperTux { - class Sprite; -} +#include "moving_object.h" +#include "lisp/lisp.h" + +class Sprite; class Player; using namespace SuperTux; @@ -13,7 +32,7 @@ using namespace SuperTux; class Block : public MovingObject { public: - Block(const Vector& pos, Sprite* sprite); + Block(Sprite* sprite = 0); ~Block(); virtual HitResponse collision(GameObject& other, const CollisionHit& hit); @@ -21,7 +40,7 @@ public: virtual void draw(DrawingContext& context); protected: - virtual void hit(Player* player) = 0; + virtual void hit(Player& player) = 0; void start_bounce(); Sprite* sprite; @@ -35,12 +54,23 @@ class BonusBlock : public Block { public: BonusBlock(const Vector& pos, int data); + BonusBlock(const lisp::Lisp& lisp); + + void try_open(); protected: - virtual void hit(Player* player); + virtual void hit(Player& player); private: - int data; + enum Contents { + CONTENT_COIN, + CONTENT_FIREGROW, + CONTENT_ICEGROW, + CONTENT_STAR, + CONTENT_1UP + }; + + Contents contents; }; class Brick : public Block @@ -48,8 +78,10 @@ class Brick : public Block public: Brick(const Vector& pos, int data); + void try_break(bool playerhit = false); + protected: - virtual void hit(Player* player); + virtual void hit(Player& player); private: bool breakable;