supertux
kamikazesnowball.hpp
1 // SuperTux
2 // Copyright (C) 2008 Wolfgang Becker <uafr@gmx.de>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef HEADER_SUPERTUX_BADGUY_KAMIKAZESNOWBALL_HPP
18 #define HEADER_SUPERTUX_BADGUY_KAMIKAZESNOWBALL_HPP
19 
20 #include "badguy/badguy.hpp"
21 
24 class KamikazeSnowball : public BadGuy
25 {
26 public:
27  KamikazeSnowball(const ReaderMapping& reader,
28  const std::string& sprite_name = "images/creatures/snowball/kamikaze-snowball.sprite");
29 
30  virtual void initialize() override;
31  virtual void collision_solid(const CollisionHit& hit) override;
32  static std::string class_name() { return "kamikazesnowball"; }
33  virtual std::string get_class_name() const override { return class_name(); }
34  static std::string display_name() { return _("Kamikaze Snowball"); }
35  virtual std::string get_display_name() const override { return display_name(); }
36  virtual GameObjectClasses get_class_types() const override { return BadGuy::get_class_types().add(typeid(KamikazeSnowball)); }
37  virtual bool is_snipable() const override { return true; }
38 
39 protected:
40  virtual bool collision_squished(GameObject& object) override;
41  virtual HitResponse collision_player(Player& player, const CollisionHit& hit) override;
42  virtual void kill_collision();
43 
44 private:
45  KamikazeSnowball(const KamikazeSnowball&) = delete;
46  KamikazeSnowball& operator=(const KamikazeSnowball&) = delete;
47 };
48 
49 class LeafShot final : public KamikazeSnowball
50 {
51 public:
52  LeafShot(const ReaderMapping& reader);
53 
54  virtual void initialize() override;
55  virtual bool is_freezable() const override;
56 
57  virtual void freeze() override;
58  virtual void unfreeze(bool melt = true) override;
59  virtual void kill_collision() override;
60 
61  virtual std::string get_overlay_size() const override { return "2x1"; }
62 
63  static std::string class_name() { return "leafshot"; }
64  virtual std::string get_class_name() const override { return class_name(); }
65  static std::string display_name() { return _("Leafshot"); }
66  virtual std::string get_display_name() const override { return display_name(); }
67  virtual GameObjectClasses get_class_types() const override { return KamikazeSnowball::get_class_types().add(typeid(LeafShot)); }
68 
69  virtual bool is_snipable() const override { return true; }
70 
71  GameObjectTypes get_types() const override;
72  std::string get_default_sprite_name() const override;
73 
74 protected:
75  virtual bool collision_squished(GameObject& object) override;
76 
77 private:
78  enum Type {
79  NORMAL,
80  CORRUPTED
81  };
82 
83 private:
84  LeafShot(const LeafShot&) = delete;
85  LeafShot& operator=(const LeafShot&) = delete;
86 };
87 
88 #endif
89 
90 /* EOF */
Base class for moving sprites that can hurt the Player.
Definition: badguy.hpp:38
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: badguy.hpp:71
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: kamikazesnowball.hpp:69
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: kamikazesnowball.hpp:36
virtual bool collision_squished(GameObject &object) override
Called when the player hit the badguy from above.
Definition: kamikazesnowball.cpp:43
virtual void initialize() override
called immediately before the first call to initialize
Definition: kamikazesnowball.cpp:35
virtual void freeze()
Called when hit by an ice bullet, and is_freezable() returns true.
Definition: badguy.cpp:968
Definition: kamikazesnowball.hpp:49
virtual std::string get_display_name() const override
Returns the display name of the object, translated to the user&#39;s locale.
Definition: kamikazesnowball.hpp:35
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: kamikazesnowball.hpp:37
Kamikaze Snowball will fly in one direction until he hits something.
Definition: kamikazesnowball.hpp:24
This class is responsible for: Updating and drawing the object.
Definition: game_object.hpp:83
virtual std::string get_display_name() const override
Returns the display name of the object, translated to the user&#39;s locale.
Definition: kamikazesnowball.hpp:66
virtual HitResponse collision_player(Player &player, const CollisionHit &hit) override
Called when the badguy collided with a player.
Definition: kamikazesnowball.cpp:81
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 GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: kamikazesnowball.hpp:67
Definition: reader_mapping.hpp:32
This module contains methods controlling the player.
Definition: player.hpp:47
virtual void unfreeze(bool melt=true)
Called to unfreeze the badguy.
Definition: badguy.cpp:1006
virtual GameObjectTypes get_types() const
Get all types of the object, if available.
Definition: game_object.cpp:255
virtual void collision_solid(const CollisionHit &hit) override
Called when the badguy collided with solid ground.
Definition: kamikazesnowball.cpp:53
This class collects data about a collision.
Definition: collision_hit.hpp:44