-Worldmap cleanups (use DrawingContext transformstack)
[supertux.git] / src / object / block.h
index bd750a0..9f54049 100644 (file)
@@ -1,7 +1,8 @@
-#ifndef __BOX_H__
-#define __BOX_H__
+#ifndef __BLOCK_H__
+#define __BLOCK_H__
 
 #include "special/moving_object.h"
+#include "lisp/lisp.h"
 
 namespace SuperTux {
   class Sprite;
@@ -13,7 +14,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 +22,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 +36,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 +60,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;