New BadGuys (code only): 'walkingflame', 'swalkingflame' similar to spiky, sspiky...
authorLMH <lmh.0013@gmail.com>
Sat, 15 Jun 2013 22:13:04 +0000 (12:13 -1000)
committerLMH <lmh.0013@gmail.com>
Sat, 15 Jun 2013 22:33:09 +0000 (12:33 -1000)
20 files changed:
data/images/creatures/walkingflame/iced-left.png [new file with mode: 0644]
data/images/creatures/walkingflame/left-0.png [new file with mode: 0644]
data/images/creatures/walkingflame/left-1.png [new file with mode: 0644]
data/images/creatures/walkingflame/left-2.png [new file with mode: 0644]
data/images/creatures/walkingflame/sleeping-left.png [new file with mode: 0644]
data/images/creatures/walkingflame/waking-left-0.png [new file with mode: 0644]
data/images/creatures/walkingflame/waking-left-1.png [new file with mode: 0644]
data/images/creatures/walkingflame/waking-left-2.png [new file with mode: 0644]
data/images/creatures/walkingflame/walkingflame.sprite [new file with mode: 0644]
data/images/objects/candle/candle-light.xcf [deleted file]
data/images/objects/lightmap_light/lightmap_light-medium.png [new file with mode: 0644]
data/images/objects/lightmap_light/lightmap_light-medium.sprite [new file with mode: 0644]
data/levels/test/glow_effects.stl
src/badguy/ghostflame.cpp
src/badguy/ghostflame.hpp
src/badguy/iceflame.cpp
src/badguy/iceflame.hpp
src/badguy/walkingflame.cpp [new file with mode: 0644]
src/badguy/walkingflame.hpp [new file with mode: 0644]
src/supertux/object_factory.cpp

diff --git a/data/images/creatures/walkingflame/iced-left.png b/data/images/creatures/walkingflame/iced-left.png
new file mode 100644 (file)
index 0000000..09a3f11
Binary files /dev/null and b/data/images/creatures/walkingflame/iced-left.png differ
diff --git a/data/images/creatures/walkingflame/left-0.png b/data/images/creatures/walkingflame/left-0.png
new file mode 100644 (file)
index 0000000..6a0cd01
Binary files /dev/null and b/data/images/creatures/walkingflame/left-0.png differ
diff --git a/data/images/creatures/walkingflame/left-1.png b/data/images/creatures/walkingflame/left-1.png
new file mode 100644 (file)
index 0000000..d773b0a
Binary files /dev/null and b/data/images/creatures/walkingflame/left-1.png differ
diff --git a/data/images/creatures/walkingflame/left-2.png b/data/images/creatures/walkingflame/left-2.png
new file mode 100644 (file)
index 0000000..6b9721f
Binary files /dev/null and b/data/images/creatures/walkingflame/left-2.png differ
diff --git a/data/images/creatures/walkingflame/sleeping-left.png b/data/images/creatures/walkingflame/sleeping-left.png
new file mode 100644 (file)
index 0000000..fcbacb2
Binary files /dev/null and b/data/images/creatures/walkingflame/sleeping-left.png differ
diff --git a/data/images/creatures/walkingflame/waking-left-0.png b/data/images/creatures/walkingflame/waking-left-0.png
new file mode 100644 (file)
index 0000000..272cd3f
Binary files /dev/null and b/data/images/creatures/walkingflame/waking-left-0.png differ
diff --git a/data/images/creatures/walkingflame/waking-left-1.png b/data/images/creatures/walkingflame/waking-left-1.png
new file mode 100644 (file)
index 0000000..637654f
Binary files /dev/null and b/data/images/creatures/walkingflame/waking-left-1.png differ
diff --git a/data/images/creatures/walkingflame/waking-left-2.png b/data/images/creatures/walkingflame/waking-left-2.png
new file mode 100644 (file)
index 0000000..d773b0a
Binary files /dev/null and b/data/images/creatures/walkingflame/waking-left-2.png differ
diff --git a/data/images/creatures/walkingflame/walkingflame.sprite b/data/images/creatures/walkingflame/walkingflame.sprite
new file mode 100644 (file)
index 0000000..27d1df3
--- /dev/null
@@ -0,0 +1,41 @@
+(supertux-sprite
+ (action
+  (name "left")
+  (hitbox 6 10 31.8 31.8)
+  (images "left-0.png"
+   "left-1.png"
+   "left-2.png"))
+ (action
+  (name "right")
+  (hitbox 6 10 31.8 31.8)
+  (mirror-action "left"))
+ (action
+  (name "iced-left")
+  (hitbox 6 10 31.8 31.8)
+  (images "iced-left.png"))
+ (action
+  (name "iced-right")
+  (hitbox 6 10 31.8 31.8)
+  (mirror-action "iced-left")
+ )
+ (action
+  (name "sleeping-left")
+  (hitbox 6 10 31.8 31.8)
+  (images "sleeping-left.png"))
+ (action
+  (name "sleeping-right")
+  (hitbox 6 10 31.8 31.8)
+  (mirror-action "sleeping-left"))
+ (action
+  (name "waking-left")
+  (hitbox 6 10 31.8 31.8)
+  (fps 6.0)
+  (images "waking-left-0.png"
+   "waking-left-1.png"
+   "waking-left-2.png"))
+ (action
+  (name "waking-right")
+  (fps 6.0)
+  (hitbox 6 10 31.8 31.8)
+  (mirror-action "waking-left"))
+)
diff --git a/data/images/objects/candle/candle-light.xcf b/data/images/objects/candle/candle-light.xcf
deleted file mode 100644 (file)
index 1ab8fb5..0000000
Binary files a/data/images/objects/candle/candle-light.xcf and /dev/null differ
diff --git a/data/images/objects/lightmap_light/lightmap_light-medium.png b/data/images/objects/lightmap_light/lightmap_light-medium.png
new file mode 100644 (file)
index 0000000..66fe8c0
Binary files /dev/null and b/data/images/objects/lightmap_light/lightmap_light-medium.png differ
diff --git a/data/images/objects/lightmap_light/lightmap_light-medium.sprite b/data/images/objects/lightmap_light/lightmap_light-medium.sprite
new file mode 100644 (file)
index 0000000..670a152
--- /dev/null
@@ -0,0 +1,7 @@
+(supertux-sprite
+    (action
+      (name "default")
+      (images "lightmap_light-medium.png")
+      (hitbox 192 192 0 0)
+    )
+)
index a072fc0..e700056 100755 (executable)
@@ -22,7 +22,8 @@
                (flame  (x      576     )(y     480     )(speed 0.2))
                (iceflame       (x      736     )(y     480     )(speed 0.2))
                (ghostflame     (x      656     )(y     96      ))
-    (kugelblitz (x 48 )(y 576 ))
+    (walkingflame (x 224 )(y 192 ))
+    (swalkingflame (x 64 )(y 192 )(direction "right"))
 
                (tilemap        (name   "Interactive"   )                                                                                                                                                                                                                                                                                                               
                        (z-pos  0       )(solid #t      )                                                                                                                                                                                                                                                                                               
@@ -35,7 +36,7 @@
 0      0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       ;       128
 0      0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       ;       160
 0      0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       ;       192
-0      0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       ;       224
+48     48      48      48      48      48      48      48      48      48      48      48      48      0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       48      48      48      48      48      48      48      48      48      48      48      48      48      ;       224
 0      0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       ;       256
 0      0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       130     133     ;       288
 0      0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       0       129     133     ;       320
     (weak_block (x 96 )(y 352 ))
     (weak_block (x 128 )(y 352 ))
     (weak_block (x 160 )(y 352 ))
+
+    (magicblock (x 416 )(y 224 )(color 1 1 1 ))
+    (magicblock (x 448 )(y 224 )(color 1 1 1 ))
+    (magicblock (x 480 )(y 224 )(color 1 1 1 ))
+    (magicblock (x 512 )(y 224 )(color 1 1 1 ))
+    (magicblock (x 544 )(y 224 )(color 1 1 1 ))
+    (magicblock (x 576 )(y 224 )(color 1 1 1 ))
+    (magicblock (x 608 )(y 224 )(color 1 1 1 ))
+    (magicblock (x 640 )(y 224 )(color 1 1 1 ))
+    (magicblock (x 672 )(y 224 )(color 1 1 1 ))
+    (magicblock (x 704 )(y 224 )(color 1 1 1 ))
+    (magicblock (x 736 )(y 224 )(color 1 1 1 ))
+    (magicblock (x 768 )(y 224 )(color 1 1 1 ))
+    (magicblock (x 800 )(y 224 )(color 1 1 1 ))
+    (magicblock (x 832 )(y 224 )(color 1 1 1 ))
+    (magicblock (x 864 )(y 224 )(color 1 1 1 ))
+    (magicblock (x 896 )(y 224 )(color 1 1 1 ))
 ))                                                                                                                                                                                                                                                                                                                                                     
index 939ea91..f731e56 100644 (file)
@@ -1,5 +1,5 @@
-//  SuperTux
-//  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
+//  SuperTux badguy - Ghostflame a flame-like enemy that cannot be killed
+//  Copyright (C) 2013 LMH <lmh.0013@gmail.com>
 //
 //  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
index 8252178..572e976 100644 (file)
@@ -1,5 +1,5 @@
-//  SuperTux
-//  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
+//  SuperTux badguy - Ghostflame a flame-like enemy that cannot be killed
+//  Copyright (C) 2013 LMH <lmh.0013@gmail.com>
 //
 //  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
index 1ab9b16..1ff3ea7 100644 (file)
@@ -1,5 +1,5 @@
-//  SuperTux
-//  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
+//  SuperTux badguy - Iceflame a flame-like enemy that can be killed with fireballs
+//  Copyright (C) 2013 LMH <lmh.0013@gmail.com>
 //
 //  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
index f43f71d..9f1d8bc 100644 (file)
@@ -1,5 +1,5 @@
-//  SuperTux
-//  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
+//  SuperTux badguy - Iceflame a flame-like enemy that can be killed with fireballs
+//  Copyright (C) 2013 LMH <lmh.0013@gmail.com>
 //
 //  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
diff --git a/src/badguy/walkingflame.cpp b/src/badguy/walkingflame.cpp
new file mode 100644 (file)
index 0000000..7652f8e
--- /dev/null
@@ -0,0 +1,223 @@
+//  SuperTux badguy - walking flame that glows
+//  Copyright (C) 2013 LMH <lmh.0013@gmail.com>
+//
+//  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 3 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, see <http://www.gnu.org/licenses/>.
+
+#include "badguy/walkingflame.hpp"
+
+#include "audio/sound_manager.hpp"
+#include "object/player.hpp"
+#include "object/sprite_particle.hpp"
+#include "sprite/sprite.hpp"
+#include "supertux/object_factory.hpp"
+#include "supertux/sector.hpp"
+
+static const float WALKSPEED = 80;
+static const float MAXDROPHEIGHT = 20;
+
+WalkingFlame::WalkingFlame(const Reader& reader) :
+  WalkingBadguy(reader, "images/creatures/walkingflame/walkingflame.sprite", "left", "right"),
+  lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-medium.sprite"))
+{
+  walk_speed = WALKSPEED;
+  max_drop_height = MAXDROPHEIGHT;
+  lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
+  lightsprite->set_color(Color(1.0f, 0.9f, 0.8f));
+}
+
+void
+WalkingFlame::draw(DrawingContext& context)
+{
+  //Draw the Sprite.
+  sprite->draw(context, get_pos(), LAYER_OBJECTS);
+  //Draw the light
+  context.push_target();
+  context.set_target(DrawingContext::LIGHTMAP);
+  lightsprite->draw(context, get_bbox().get_middle(), 0);
+  context.pop_target();
+}
+
+void
+WalkingFlame::freeze()
+{
+  // attempting to freeze a flame causes it to go out
+  kill_fall();
+}
+
+bool
+WalkingFlame::is_freezable() const
+{
+  return true;
+}
+
+bool
+WalkingFlame::is_flammable() const
+{
+  return false;
+}
+
+void
+WalkingFlame::kill_fall()
+{
+  //TODO: get unique sound for ice-fire encounters
+  sound_manager->play("sounds/fall.wav", get_pos());
+  // throw a puff of smoke
+  Vector ppos = bbox.get_middle();
+  Vector pspeed = Vector(0, -150);
+  Vector paccel = Vector(0,0);
+  Sector::current()->add_object(new SpriteParticle("images/objects/particles/smoke.sprite", "default", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_BACKGROUNDTILES+2));
+  // extinguish the flame
+  sprite->set_action(dir == LEFT ? "extinguish-left" : "extinguish-right");
+  physic.set_velocity_y(0);
+  physic.set_acceleration_y(0);
+  physic.enable_gravity(false);
+  set_state(STATE_SQUISHED); // used to nullify any threat and remove
+
+  // start dead-script
+  run_dead_script();
+}
+
+/* The following handles a sleeping version */
+
+SWalkingFlame::SWalkingFlame(const Reader& reader) :
+  WalkingBadguy(reader, "images/creatures/walkingflame/walkingflame.sprite", "left", "right"), state(STATE_SLEEPING),
+  lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-medium.sprite"))
+{
+  walk_speed = WALKSPEED;
+  max_drop_height = MAXDROPHEIGHT;
+  lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
+  lightsprite->set_color(Color(1.0f, 0.9f, 0.8f));
+}
+
+void
+SWalkingFlame::initialize()
+{
+  state = STATE_SLEEPING;
+  physic.set_velocity_x(0);
+  sprite->set_action(dir == LEFT ? "sleeping-left" : "sleeping-right");
+}
+
+void
+SWalkingFlame::collision_solid(const CollisionHit& hit)
+{
+  if(state != STATE_WALKING) {
+    BadGuy::collision_solid(hit);
+    return;
+  }
+  WalkingBadguy::collision_solid(hit);
+}
+
+HitResponse
+SWalkingFlame::collision_badguy(BadGuy& badguy, const CollisionHit& hit)
+{
+  if(state != STATE_WALKING) {
+    return BadGuy::collision_badguy(badguy, hit);
+  }
+  return WalkingBadguy::collision_badguy(badguy, hit);
+}
+
+void
+SWalkingFlame::active_update(float elapsed_time) {
+
+  if(state == STATE_WALKING) {
+    WalkingBadguy::active_update(elapsed_time);
+    return;
+  }
+
+  if(state == STATE_SLEEPING) {
+
+    Player* player = this->get_nearest_player();
+    if (player) {
+      Rectf mb = this->get_bbox();
+      Rectf pb = player->get_bbox();
+
+      bool inReach_left = (pb.p2.x >= mb.p2.x-((dir == LEFT) ? 256 : 0));
+      bool inReach_right = (pb.p1.x <= mb.p1.x+((dir == RIGHT) ? 256 : 0));
+      bool inReach_top = (pb.p2.y >= mb.p1.y);
+      bool inReach_bottom = (pb.p1.y <= mb.p2.y);
+
+      if (inReach_left && inReach_right && inReach_top && inReach_bottom) {
+        // wake up
+        sprite->set_action(dir == LEFT ? "waking-left" : "waking-right", 1);
+        state = STATE_WAKING;
+      }
+    }
+
+    BadGuy::active_update(elapsed_time);
+  }
+
+  if(state == STATE_WAKING) {
+    if(sprite->animation_done()) {
+      // start walking
+      state = STATE_WALKING;
+      WalkingBadguy::initialize();
+    }
+
+    BadGuy::active_update(elapsed_time);
+  }
+}
+
+void
+SWalkingFlame::draw(DrawingContext& context)
+{
+  //Draw the Sprite.
+  sprite->draw(context, get_pos(), LAYER_OBJECTS);
+  //Draw the light
+  context.push_target();
+  context.set_target(DrawingContext::LIGHTMAP);
+  lightsprite->draw(context, get_bbox().get_middle(), 0);
+  context.pop_target();
+}
+
+void
+SWalkingFlame::freeze()
+{
+  // attempting to freeze a flame causes it to go out
+  kill_fall();
+}
+
+bool
+SWalkingFlame::is_freezable() const
+{
+  return true;
+}
+
+bool
+SWalkingFlame::is_flammable() const
+{
+  return false;
+}
+
+void
+SWalkingFlame::kill_fall()
+{
+  //TODO: get unique sound for ice-fire encounters
+  sound_manager->play("sounds/fall.wav", get_pos());
+  // throw a puff of smoke
+  Vector ppos = bbox.get_middle();
+  Vector pspeed = Vector(0, -150);
+  Vector paccel = Vector(0,0);
+  Sector::current()->add_object(new SpriteParticle("images/objects/particles/smoke.sprite", "default", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_BACKGROUNDTILES+2));
+  // extinguish the flame
+  sprite->set_action(dir == LEFT ? "extinguish-left" : "extinguish-right");
+  physic.set_velocity_y(0);
+  physic.set_acceleration_y(0);
+  physic.enable_gravity(false);
+  set_state(STATE_SQUISHED); // used to nullify any threat and remove
+
+  // start dead-script
+  run_dead_script();
+}
+
+/* EOF */
diff --git a/src/badguy/walkingflame.hpp b/src/badguy/walkingflame.hpp
new file mode 100644 (file)
index 0000000..7b782ed
--- /dev/null
@@ -0,0 +1,70 @@
+//  SuperTux badguy - walking flame that glows
+//  Copyright (C) 2013 LMH <lmh.0013@gmail.com>
+//
+//  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 3 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, see <http://www.gnu.org/licenses/>.
+
+#ifndef HEADER_SUPERTUX_BADGUY_WALKINGFLAME_HPP
+#define HEADER_SUPERTUX_BADGUY_WALKINGFLAME_HPP
+
+#include "badguy/walking_badguy.hpp"
+
+class WalkingFlame : public WalkingBadguy
+{
+public:
+  WalkingFlame(const Reader& reader);
+
+  void draw(DrawingContext& context);
+
+  void freeze();
+  bool is_freezable() const;
+  bool is_flammable() const;
+
+  virtual void kill_fall();
+
+private:
+  SpritePtr lightsprite;
+};
+
+class SWalkingFlame : public WalkingBadguy
+{
+public:
+  SWalkingFlame(const Reader& reader);
+
+  void initialize();
+  void collision_solid(const CollisionHit& hit);
+  HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit);
+  void active_update(float elapsed_time);
+  void draw(DrawingContext& context);
+
+  void freeze();
+  bool is_freezable() const;
+  bool is_flammable() const;
+
+  virtual void kill_fall();
+  
+protected:
+  enum SState {
+    STATE_SLEEPING,
+    STATE_WAKING,
+    STATE_WALKING
+  };
+  SState state;
+
+private:
+  SpritePtr lightsprite;
+};
+
+#endif
+
+/* EOF */
index 205739b..f309bdf 100644 (file)
@@ -68,6 +68,7 @@
 #include "badguy/totem.hpp"
 #include "badguy/treewillowisp.hpp"
 #include "badguy/walking_badguy.hpp"
+#include "badguy/walkingflame.hpp"
 #include "badguy/walkingleaf.hpp"
 #include "badguy/willowisp.hpp"
 #include "badguy/yeti.hpp"
@@ -216,8 +217,10 @@ ObjectFactory::init_factories()
   add_factory<Spiky>("spiky");
   add_factory<Stalactite>("stalactite");
   add_factory<Stumpy>("stumpy");
+  add_factory<SWalkingFlame>("swalkingflame");
   add_factory<Toad>("toad");
   add_factory<Totem>("totem");
+  add_factory<WalkingFlame>("walkingflame");
   add_factory<WalkingLeaf>("walkingleaf");
   add_factory<WillOWisp>("willowisp");
   add_factory<Yeti>("yeti");