added very basic zeekling code, made him a little smaller
authorMarek Moeckel <wansti@gmx.de>
Sun, 8 May 2005 18:53:00 +0000 (18:53 +0000)
committerMarek Moeckel <wansti@gmx.de>
Sun, 8 May 2005 18:53:00 +0000 (18:53 +0000)
SVN-Revision: 2445

basest/images/creatures/zeekling/left-0.png
basest/images/creatures/zeekling/left-1.png
basest/images/creatures/zeekling/left-2.png
basest/images/creatures/zeekling/left-3.png
basest/images/creatures/zeekling/squished.png
basest/images/sprites.strf
basest/levels/test/enemy3.stl
src/badguy/zeekling.cpp [new file with mode: 0644]
src/badguy/zeekling.h [new file with mode: 0644]

index 2b8081d..8cda2d1 100644 (file)
Binary files a/basest/images/creatures/zeekling/left-0.png and b/basest/images/creatures/zeekling/left-0.png differ
index e6604cc..3b29fec 100644 (file)
Binary files a/basest/images/creatures/zeekling/left-1.png and b/basest/images/creatures/zeekling/left-1.png differ
index aa36cf2..ee55ddd 100644 (file)
Binary files a/basest/images/creatures/zeekling/left-2.png and b/basest/images/creatures/zeekling/left-2.png differ
index 64544e6..226b670 100644 (file)
Binary files a/basest/images/creatures/zeekling/left-3.png and b/basest/images/creatures/zeekling/left-3.png differ
index f6cdcf9..9f00a4d 100644 (file)
Binary files a/basest/images/creatures/zeekling/squished.png and b/basest/images/creatures/zeekling/squished.png differ
index c3a4abe..9c1642f 100644 (file)
          (mirror-action "left"))
        (action
          (name "squished-left")
-         (x-offset 1)
+         (x-offset 2)
          (y-offset -19)
          (images "creatures/zeekling/squished.png"))
        (action
          (name "squished-right")
-         (x-offset 1)
+         (x-offset 2)
          (y-offset -19)
          (mirror-action "squished-left")))
          
index 3ade2b8..a798ed1 100644 (file)
@@ -78,6 +78,7 @@
   (objects
     (mriceblock  (x 439) (y 159) (stay-on-platform #t))
     (mriceblock  (x 479) (y 159) (stay-on-platform #f))
+    (zeekling  (x 1000) (y 140))
     (trampoline (x 250) (y 150) (power 7.5))
     (dispenser (x 700) (y 100) (badguy "random") (cycle 1))
   )
diff --git a/src/badguy/zeekling.cpp b/src/badguy/zeekling.cpp
new file mode 100644 (file)
index 0000000..41c4590
--- /dev/null
@@ -0,0 +1,90 @@
+//  $Id$
+// 
+//  SuperTux
+//  Copyright (C) 2005 Matthias Braun <matze@braunis.de>
+//
+//  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 <config.h>
+
+#include "zeekling.h"
+
+static const float SPEED = 150;
+
+//TODO: Make the Zeekling behave more interesting
+Zeekling::Zeekling(const lisp::Lisp& reader)
+{
+  reader.get("x", start_position.x);
+  reader.get("y", start_position.y);
+  bbox.set_size(31.8, 31.8);
+  sprite = sprite_manager->create("zeekling");
+  set_direction = false;
+}
+
+Zeekling::Zeekling(float pos_x, float pos_y, Direction d)
+{
+  start_position.x = pos_x;
+  start_position.y = pos_y;
+  bbox.set_size(63.8, 50.8);
+  sprite = sprite_manager->create("zeekling");
+  set_direction = true;
+  initial_direction = d;
+}
+
+void
+Zeekling::write(lisp::Writer& writer)
+{
+  writer.start_list("zeekling");
+
+  writer.write_float("x", start_position.x);
+  writer.write_float("y", start_position.y);
+
+  writer.end_list("zeekling");
+}
+
+void
+Zeekling::activate()
+{
+  if (set_direction) {dir = initial_direction;}
+  physic.set_velocity_x(dir == LEFT ? -SPEED : SPEED);
+  physic.enable_gravity(false);
+  sprite->set_action(dir == LEFT ? "left" : "right");
+}
+
+bool
+Zeekling::collision_squished(Player& player)
+{
+  sprite->set_action(dir == LEFT ? "squished-left" : "squished-right");
+  kill_squished(player);
+  kill_fall();
+  return true;
+}
+
+HitResponse
+Zeekling::collision_solid(GameObject& , const CollisionHit& hit)
+{
+  if(fabsf(hit.normal.y) > .5) { // hit floor or roof?
+    physic.set_velocity_y(0);
+  } else { // hit right or left
+    dir = (dir == LEFT ? RIGHT : LEFT);
+    sprite->set_action(dir == LEFT ? "left" : "right");
+    physic.set_velocity_x(dir == LEFT ? -SPEED : SPEED);
+  }
+
+  return CONTINUE;
+}
+
+IMPLEMENT_FACTORY(Zeekling, "zeekling")
diff --git a/src/badguy/zeekling.h b/src/badguy/zeekling.h
new file mode 100644 (file)
index 0000000..c2dbc3a
--- /dev/null
@@ -0,0 +1,43 @@
+//  $Id$
+// 
+//  SuperTux
+//  Copyright (C) 2005 Matthias Braun <matze@braunis.de>
+//
+//  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.
+
+#ifndef __ZEEKLING_H__
+#define __ZEEKLING_H__
+
+#include "badguy.h"
+
+class Zeekling : public BadGuy
+{
+public:
+  Zeekling(const lisp::Lisp& reader);
+  Zeekling(float pos_x, float pos_y, Direction d);
+
+  void activate();
+  void write(lisp::Writer& writer);
+  HitResponse collision_solid(GameObject& other, const CollisionHit& hit);
+
+protected:
+  bool collision_squished(Player& player);
+  bool set_direction;
+  Direction initial_direction;
+};
+
+#endif
+