supertux
mriceblock.hpp
1 // SuperTux
2 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
3 // 2023 Vankata453
4 //
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18 #ifndef HEADER_SUPERTUX_BADGUY_MRICEBLOCK_HPP
19 #define HEADER_SUPERTUX_BADGUY_MRICEBLOCK_HPP
20 
21 #include "badguy/walking_badguy.hpp"
22 
23 class MrIceBlock : public WalkingBadguy
24 {
25 public:
26  MrIceBlock(const ReaderMapping& reader,
27  const std::string& sprite_name = "images/creatures/iceblock/iceblock.sprite");
28 
29  virtual void initialize() override;
30  virtual HitResponse collision(GameObject& object, const CollisionHit& hit) override;
31  virtual void collision_solid(const CollisionHit& hit) override;
32  virtual HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit) override;
33  virtual HitResponse collision_player(Player& player, const CollisionHit& hit) override;
34 
35  virtual void active_update(float dt_sec) override;
36 
37  virtual void grab(MovingObject& object, const Vector& pos, Direction dir) override;
38  virtual void ungrab(MovingObject& object, Direction dir) override;
39  virtual bool is_portable() const override;
40 
41  virtual bool can_break() const override;
42 
43  virtual void ignite() override;
44  virtual void freeze() override;
45  virtual void unfreeze(bool melt = true) override;
46 
47  static std::string class_name() { return "mriceblock"; }
48  virtual std::string get_class_name() const override { return class_name(); }
49  static std::string display_name() { return _("Mr. Iceblock"); }
50  virtual std::string get_display_name() const override { return display_name(); }
51  virtual GameObjectClasses get_class_types() const override { return WalkingBadguy::get_class_types().add(typeid(MrIceBlock)); }
52 
53  virtual bool is_snipable() const override { return ice_state != ICESTATE_KICKED; }
54  virtual bool is_freezable() const override;
55 
56  virtual GameObjectTypes get_types() const override;
57  std::string get_default_sprite_name() const override;
58 
59  bool can_break();
60 
61 protected:
62  enum IceState {
63  ICESTATE_NORMAL,
64  ICESTATE_FLAT,
65  ICESTATE_GRABBED,
66  ICESTATE_KICKED,
67  ICESTATE_WAKING
68  };
69 
70 protected:
71  virtual bool collision_squished(GameObject& object) override;
72  void set_state(IceState state);
73 
74 private:
75  enum Type {
76  NORMAL,
77  LAPTOP
78  };
79 
80 private:
81  IceState ice_state;
82  Timer nokick_timer;
83  Timer flat_timer;
84  int squishcount;
85 
86 private:
87  MrIceBlock(const MrIceBlock&) = delete;
88  MrIceBlock& operator=(const MrIceBlock&) = delete;
89 };
90 
91 #endif
92 
93 /* EOF */
Base class for moving sprites that can hurt the Player.
Definition: badguy.hpp:38
virtual std::string get_display_name() const override
Returns the display name of the object, translated to the user&#39;s locale.
Definition: mriceblock.hpp:50
virtual HitResponse collision_badguy(BadGuy &badguy, const CollisionHit &hit) override
Called when the badguy collided with another badguy.
Definition: mriceblock.cpp:234
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: walking_badguy.hpp:55
virtual void collision_solid(const CollisionHit &hit) override
Called when the badguy collided with solid ground.
Definition: mriceblock.cpp:150
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: mriceblock.hpp:51
virtual bool is_snipable() const override
Can enemy be sniped by sliding or swimboosting Tux? Returns false if enemy is spiky or too large...
Definition: mriceblock.hpp:53
Base class for Badguys that walk on the floor.
Definition: walking_badguy.hpp:25
virtual bool collision_squished(GameObject &object) override
Called when the player hit the badguy from above.
Definition: mriceblock.cpp:253
virtual void grab(MovingObject &object, const Vector &pos, Direction dir) override
called each frame when the object has been grabbed.
Definition: mriceblock.cpp:349
This class is responsible for: Updating and drawing the object.
Definition: game_object.hpp:83
Definition: mriceblock.hpp:23
Base class for all dynamic/moving game objects.
Definition: moving_object.hpp:35
virtual void active_update(float dt_sec) override
called each frame when the badguy is activated.
Definition: mriceblock.cpp:105
virtual HitResponse collision_player(Player &player, const CollisionHit &hit) override
Called when the badguy collided with a player.
Definition: mriceblock.cpp:212
virtual HitResponse collision(GameObject &object, const CollisionHit &hit) override
Called when a collision with another object occurred.
Definition: mriceblock.cpp:194
A helper structure to list all the type_indexes of the classes in the type hierarchy of a given class...
Definition: game_object.hpp:57
virtual void initialize() override
called immediately before the first call to initialize
Definition: mriceblock.cpp:52
virtual void ignite() override
Kills the badguy by igniting it.
Definition: mriceblock.cpp:409
Simple timer designed to be used in the update functions of objects.
Definition: timer.hpp:24
virtual void freeze() override
Called when hit by an ice bullet, and is_freezable() returns true.
Definition: mriceblock.cpp:86
Definition: reader_mapping.hpp:32
virtual bool can_break() const override
True if this badguy can break bricks or open bonusblocks in his current form.
Definition: mriceblock.cpp:145
This module contains methods controlling the player.
Definition: player.hpp:47
This class collects data about a collision.
Definition: collision_hit.hpp:44
virtual void unfreeze(bool melt=true) override
Called to unfreeze the badguy.
Definition: mriceblock.cpp:95
virtual GameObjectTypes get_types() const override
Get all types of the object, if available.
Definition: mriceblock.cpp:59