summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/Makefile.am4
-rw-r--r--src/simpleanimation.cpp52
-rw-r--r--src/simpleanimation.h59
5 files changed, 124 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 621a4bbb..939d477c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,10 @@
-2007-03-12 Bjørn Lindeijer <bjorn@lindeijer.nl>
+2007-03-12 Philipp Sehmisch <tmw@crushnet.org>
+
+ * src/simpleanimation.cpp, src/simpleanimation.h, src/CmakeLists.txt,
+ src/Makefile.am: Added a simple animation class that hosts a looping
+ animation without the action and direction stuff from AnimatedSprite.
+
+2007-03-12 Bjørn Lindeijer <bjorn@lindeijer.nl>
* data/graphics/items/armor-head-rangerhat.png: New version of ranger hat
icon by Pauan.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 20ac32be..261bb161 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -304,6 +304,8 @@ SET(SRCS
player.h
properties.h
serverinfo.h
+ simpleanimation.cpp
+ simpleanimation.h
sound.cpp
sound.h
sprite.h
@@ -327,4 +329,4 @@ TARGET_LINK_LIBRARIES(tmw
INSTALL(TARGETS tmw RUNTIME DESTINATION ${PKG_BINDIR})
-SET_TARGET_PROPERTIES(tmw PROPERTIES COMPILE_FLAGS "${FLAGS}")
+SET_TARGET_PROPERTIES(tmw PROPERTIES COMPILE_FLAGS "${FLAGS}") \ No newline at end of file
diff --git a/src/Makefile.am b/src/Makefile.am
index e1a16daa..a8632678 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -253,6 +253,8 @@ tmw_SOURCES = gui/browserbox.cpp \
player.h \
properties.h \
serverinfo.h \
+ simpleanimation.cpp \
+ simpleanimation.h \
sound.cpp \
sound.h \
sprite.h \
@@ -267,4 +269,4 @@ INCLUDES = \
tmw_LDFLAGS = $(all_libraries) $(LIBSDL_RPATH) `pkg-config --libs libxml-2.0`
tmw_CXXFLAGS = -Wall -Werror $(OPENGL_CFLAGS) $(LIBSDL_CFLAGS) `pkg-config --cflags libxml-2.0` $(CURL_CFLAGS)
tmw_LDADD = $(LIBSDL_LIBS) -lguichan_sdl $(OPENGL_LIBS) $(CURL_LIBS)
-tmw_TARGET = tmw
+tmw_TARGET = tmw \ No newline at end of file
diff --git a/src/simpleanimation.cpp b/src/simpleanimation.cpp
new file mode 100644
index 00000000..5baf8fc9
--- /dev/null
+++ b/src/simpleanimation.cpp
@@ -0,0 +1,52 @@
+/*
+ * The Mana World
+ * Copyright 2004 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * The Mana World 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
+ * any later version.
+ *
+ * The Mana World 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 The Mana World; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#include "simpleanimation.h"
+
+#include "graphics.h"
+
+
+void SimpleAnimation::update(unsigned int timePassed)
+{
+ mAnimationTime+=timePassed;
+ if (mAnimationTime > mCurrentFrame->delay)
+ {
+ mAnimationTime = 0;
+ mAnimationPhase++;
+ if (mAnimationPhase >= mAnimation->getLength())
+ {
+ mAnimationPhase = 0;
+ }
+ mCurrentFrame = mAnimation->getFrame(mAnimationPhase);
+ }
+}
+
+Image *SimpleAnimation::getCurrentImage() const
+{
+ return mCurrentFrame->image;
+}
+
+SimpleAnimation::~SimpleAnimation()
+{
+ delete mAnimation;
+}
diff --git a/src/simpleanimation.h b/src/simpleanimation.h
new file mode 100644
index 00000000..084211ea
--- /dev/null
+++ b/src/simpleanimation.h
@@ -0,0 +1,59 @@
+/*
+ * The Mana World
+ * Copyright 2004 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * The Mana World 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
+ * any later version.
+ *
+ * The Mana World 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 The Mana World; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#ifndef _TMW_SIMPLEANIMAION_H
+#define _TMW_SIMPLEANIMAION_H
+
+#include "resources/animation.h"
+
+class Frame;
+class Graphics;
+
+/**
+ * This class is a leightweight alternative to the AnimatedSprite class.
+ * It hosts a looping animation without actions and directions.
+ */
+class SimpleAnimation
+{
+ public:
+ SimpleAnimation(Animation *animation):
+ mAnimation(animation),
+ mAnimationTime(0),
+ mAnimationPhase(0),
+ mCurrentFrame(mAnimation->getFrame(0))
+ {};
+
+ ~SimpleAnimation();
+
+ void update(unsigned int timePassed);
+
+ Image *getCurrentImage() const;
+
+ private:
+ Animation *mAnimation; /**< The hosted animation */
+ unsigned int mAnimationTime; /**< Time in game ticks the current frame is shown*/
+ unsigned int mAnimationPhase; /**< Current animation phase when the appearance is ANIMATION*/
+ Frame *mCurrentFrame;
+};
+
+#endif