From: Marek Moeckel Date: Sun, 8 May 2005 18:53:00 +0000 (+0000) Subject: added very basic zeekling code, made him a little smaller X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=354da395bda1f813280b26cc8d0c0547bf187c7d;p=supertux.git added very basic zeekling code, made him a little smaller SVN-Revision: 2445 --- diff --git a/basest/images/creatures/zeekling/left-0.png b/basest/images/creatures/zeekling/left-0.png index 2b8081d7f..8cda2d19d 100644 Binary files a/basest/images/creatures/zeekling/left-0.png and b/basest/images/creatures/zeekling/left-0.png differ diff --git a/basest/images/creatures/zeekling/left-1.png b/basest/images/creatures/zeekling/left-1.png index e6604cc49..3b29fec9f 100644 Binary files a/basest/images/creatures/zeekling/left-1.png and b/basest/images/creatures/zeekling/left-1.png differ diff --git a/basest/images/creatures/zeekling/left-2.png b/basest/images/creatures/zeekling/left-2.png index aa36cf253..ee55dddff 100644 Binary files a/basest/images/creatures/zeekling/left-2.png and b/basest/images/creatures/zeekling/left-2.png differ diff --git a/basest/images/creatures/zeekling/left-3.png b/basest/images/creatures/zeekling/left-3.png index 64544e64f..226b67042 100644 Binary files a/basest/images/creatures/zeekling/left-3.png and b/basest/images/creatures/zeekling/left-3.png differ diff --git a/basest/images/creatures/zeekling/squished.png b/basest/images/creatures/zeekling/squished.png index f6cdcf99d..9f00a4d44 100644 Binary files a/basest/images/creatures/zeekling/squished.png and b/basest/images/creatures/zeekling/squished.png differ diff --git a/basest/images/sprites.strf b/basest/images/sprites.strf index c3a4abec5..9c1642ff0 100644 --- a/basest/images/sprites.strf +++ b/basest/images/sprites.strf @@ -1307,12 +1307,12 @@ (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"))) diff --git a/basest/levels/test/enemy3.stl b/basest/levels/test/enemy3.stl index 3ade2b81b..a798ed14f 100644 --- a/basest/levels/test/enemy3.stl +++ b/basest/levels/test/enemy3.stl @@ -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 index 000000000..41c45903e --- /dev/null +++ b/src/badguy/zeekling.cpp @@ -0,0 +1,90 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// 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 + +#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 index 000000000..c2dbc3aa7 --- /dev/null +++ b/src/badguy/zeekling.h @@ -0,0 +1,43 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// 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 +