[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] rev 2327 - in trunk: . data/data src src/actions
From: |
Ingo Ruhnke |
Subject: |
[Pingus-CVS] rev 2327 - in trunk: . data/data src src/actions |
Date: |
Mon, 10 May 2004 12:23:47 +0200 |
Author: grumbel
Date: 2004-05-10 12:23:47 +0200 (Mon, 10 May 2004)
New Revision: 2327
Added:
trunk/src/state_sprite.cxx
trunk/src/state_sprite.hxx
Modified:
trunk/configure.ac
trunk/data/data/pingus.xml
trunk/src/Makefile.am
trunk/src/actions/walker.cxx
trunk/src/actions/walker.hxx
trunk/src/direction.cxx
trunk/src/direction.hxx
Log:
- changed animation code a bit
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2004-05-09 19:36:09 UTC (rev 2326)
+++ trunk/configure.ac 2004-05-10 10:23:47 UTC (rev 2327)
@@ -47,7 +47,7 @@
if test "x$with_gettext" != "xno"; then
dnl -- gettext macros --
- ALL_LINGUAS="cs de da es fi fr it no pt sr sv tr" # nl
+ ALL_LINGUAS="cs de da es fi fr it no pt sr sv tr nl"
dnl AM_WITH_NLS
dnl AM_LC_MESSAGES
Modified: trunk/data/data/pingus.xml
===================================================================
--- trunk/data/data/pingus.xml 2004-05-09 19:36:09 UTC (rev 2326)
+++ trunk/data/data/pingus.xml 2004-05-10 10:23:47 UTC (rev 2327)
@@ -1,10 +1,23 @@
<resources>
<section name="Pingus">
- <sprite name="floaterlayer">
- <image file="../images/pingus/floaterlayer.png">
- <grid pos="0,0" size="32,32" array="8,2"/>
- </image>
- </sprite>
+
+ <section name="floaterlayer">
+
+ <sprite name="left">
+ <translation origin="bottom_center" x="0" y="2"/>
+ <image file="../images/pingus/floaterlayer.png">
+ <grid pos="0,0" size="32,32" array="8,1"/>
+ </image>
+ </sprite>
+
+ <sprite name="right">
+ <translation origin="bottom_center" x="0" y="2"/>
+ <image file="../images/pingus/floaterlayer.png">
+ <grid pos="0,32" size="32,32" array="8,1"/>
+ </image>
+ </sprite>
+ </section>
+
<sprite name="rocketlauncher0">
<image file="../images/pingus/rocketlauncher.png">
<grid pos="0,0" size="32,32" array="7,2"/>
@@ -70,6 +83,25 @@
<grid pos="0,0" size="32,32" array="11,2"/>
</image>
</sprite>
+
+ <section name="walker">
+ <sprite name="left">
+ <animation speed="60" />
+ <translation origin="bottom_center" x="0" y="2"/>
+ <image file="../images/pingus/walker.png">
+ <grid pos="0,0" size="32,32" array="8,1"/>
+ </image>
+ </sprite>
+
+ <sprite name="right">
+ <animation speed="60" />
+ <translation origin="bottom_center" x="0" y="2"/>
+ <image file="../images/pingus/walker.png">
+ <grid pos="0,32" size="32,32" array="8,1"/>
+ </image>
+ </sprite>
+ </section>
+
<sprite name="walker0">
<image file="../images/pingus/walker.png">
<grid pos="0,0" size="32,32" array="8,2"/>
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2004-05-09 19:36:09 UTC (rev 2326)
+++ trunk/src/Makefile.am 2004-05-10 10:23:47 UTC (rev 2327)
@@ -256,6 +256,8 @@
spot_map.hxx \
sprite.cxx \
sprite.hxx \
+state_sprite.hxx \
+state_sprite.cxx \
start_screen.hxx \
start_screen.cxx \
stat_manager.hxx \
Modified: trunk/src/actions/walker.cxx
===================================================================
--- trunk/src/actions/walker.cxx 2004-05-09 19:36:09 UTC (rev 2326)
+++ trunk/src/actions/walker.cxx 2004-05-10 10:23:47 UTC (rev 2327)
@@ -22,6 +22,7 @@
#include "../gui/graphic_context.hxx"
#include "../string_converter.hxx"
#include "../pingu.hxx"
+#include "../pingus_resource.hxx"
#include "../debug.hxx"
#include "walker.hxx"
@@ -29,13 +30,14 @@
namespace Actions {
Walker::Walker (Pingu* p)
- : PinguAction(p),
- walker("Pingus/walker" + to_string(pingu->get_owner()), "pingus", 15.0f),
- floaterlayer("Pingus/floaterlayer", "pingus", 15.0f)
+ : PinguAction(p)
{
- walker.set_align_center_bottom();
- floaterlayer.set_align_center_bottom();
+ walker.load(Direction::LEFT,
PingusResource::load_sprite("Pingus/walker/left", "pingus"));
+ walker.load(Direction::RIGHT,
PingusResource::load_sprite("Pingus/walker/right" , "pingus"));
+ floaterlayer.load(Direction::LEFT,
PingusResource::load_sprite("Pingus/floaterlayer/left", "pingus"));
+ floaterlayer.load(Direction::RIGHT,
PingusResource::load_sprite("Pingus/floaterlayer/right", "pingus"));
+
// Reset the velocity
pingu->set_velocity(Vector());
}
@@ -44,8 +46,8 @@
Walker::update ()
{
// update the sprite
- walker.update();
- floaterlayer.update();
+ walker(pingu->direction).update(0.033);
+ floaterlayer(pingu->direction).update(0.033);
Vector last_pos = pingu->get_pos();
@@ -205,22 +207,11 @@
void
Walker::draw (GraphicContext& gc)
{
- if (pingu->direction.is_left())
- {
- walker.set_direction(Sprite::LEFT);
- floaterlayer.set_direction(Sprite::LEFT);
- }
- else
- {
- walker.set_direction(Sprite::RIGHT);
- floaterlayer.set_direction(Sprite::RIGHT);
- }
+ gc.draw(walker(pingu->direction), pingu->get_pos());
- gc.draw(walker, pingu->get_pos() + Vector (0, +2));
-
if (pingu->get_fall_action() && pingu->get_fall_action()->get_type() ==
Actions::Floater)
{
- gc.draw(floaterlayer, pingu->get_pos() + Vector(0, +2));
+ gc.draw(floaterlayer(pingu->direction), pingu->get_pos());
}
}
Modified: trunk/src/actions/walker.hxx
===================================================================
--- trunk/src/actions/walker.hxx 2004-05-09 19:36:09 UTC (rev 2326)
+++ trunk/src/actions/walker.hxx 2004-05-10 10:23:47 UTC (rev 2327)
@@ -21,6 +21,7 @@
#define HEADER_PINGUS_ACTIONS_WALKER_HXX
#include "../pingu_action.hxx"
+#include "../state_sprite.hxx"
#include "../sprite.hxx"
namespace Pingus {
@@ -29,8 +30,8 @@
class Walker : public PinguAction
{
private:
- Sprite walker;
- Sprite floaterlayer;
+ StateSprite walker;
+ StateSprite floaterlayer;
enum { max_steps = 5 }; // max nr. of pixels that pingu can walk up/down
Modified: trunk/src/direction.cxx
===================================================================
--- trunk/src/direction.cxx 2004-05-09 19:36:09 UTC (rev 2326)
+++ trunk/src/direction.cxx 2004-05-10 10:23:47 UTC (rev 2327)
@@ -21,7 +21,7 @@
namespace Pingus {
-Direction::Direction() : direction(0)
+Direction::Direction() : direction(NONE)
{
}
@@ -47,37 +47,34 @@
void
Direction::change()
{
- direction = -direction;
+ if (direction == LEFT)
+ direction = RIGHT;
+ else
+ direction = LEFT;
}
void
Direction::left()
{
- direction = -1;
+ direction = LEFT;
}
void
Direction::right()
{
- direction = 1;
+ direction = RIGHT;
}
bool
Direction::is_left() const
{
- if (direction == -1)
- return true;
- else
- return false;
+ return (direction == LEFT);
}
bool
Direction::is_right() const
{
- if (direction == 1)
- return true;
- else
- return false;
+ return direction == RIGHT;
}
} // namespace Pingus
Modified: trunk/src/direction.hxx
===================================================================
--- trunk/src/direction.hxx 2004-05-09 19:36:09 UTC (rev 2326)
+++ trunk/src/direction.hxx 2004-05-10 10:23:47 UTC (rev 2327)
@@ -27,8 +27,10 @@
/// Simple class for managing the direction of a pingu
class Direction
{
+public:
+ enum Dir { LEFT = -1, NONE = 0, RIGHT = +1 };
private:
- int direction;
+ Dir direction;
public:
Direction ();
Added: trunk/src/state_sprite.cxx
===================================================================
--- trunk/src/state_sprite.cxx 2004-05-09 19:36:09 UTC (rev 2326)
+++ trunk/src/state_sprite.cxx 2004-05-10 10:23:47 UTC (rev 2327)
@@ -0,0 +1,51 @@
+// $Id$
+//
+// Pingus - A free Lemmings clone
+// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
+//
+// 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 "pingus_error.hxx"
+#include "state_sprite.hxx"
+
+namespace Pingus {
+
+StateSprite::StateSprite()
+{
+}
+
+void
+StateSprite::load(int state, CL_Sprite sprite)
+{
+ sprites[state] = sprite;
+}
+
+CL_Sprite&
+StateSprite::operator()(int state)
+{
+ Sprites::iterator i = sprites.find(state);
+ if (i != sprites.end())
+ {
+ return i->second;
+ }
+ else
+ {
+ throw PingusError("StateSprite error");
+ }
+}
+
+} // namespace Pingus
+
+/* EOF */
Added: trunk/src/state_sprite.hxx
===================================================================
--- trunk/src/state_sprite.hxx 2004-05-09 19:36:09 UTC (rev 2326)
+++ trunk/src/state_sprite.hxx 2004-05-10 10:23:47 UTC (rev 2327)
@@ -0,0 +1,47 @@
+// $Id$
+//
+// Pingus - A free Lemmings clone
+// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
+//
+// 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 HEADER_STATE_SPRITE_HXX
+#define HEADER_STATE_SPRITE_HXX
+
+#include <map>
+#include <ClanLib/Display/sprite.h>
+
+namespace Pingus {
+
+/** Simple Wrapper class around CL_Sprite that allows to have multiple
+ sprites for different states (running, walking, left, right) */
+class StateSprite
+{
+private:
+ typedef std::map<int, CL_Sprite> Sprites;
+ Sprites sprites;
+
+public:
+ StateSprite();
+
+ void load(int state, CL_Sprite);
+ CL_Sprite& operator()(int state);
+};
+
+} // namespace Pingus
+
+#endif
+
+/* EOF */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] rev 2327 - in trunk: . data/data src src/actions,
Ingo Ruhnke <=