]> git.localhorst.tv Git - l2e.git/blobdiff - src/graphics/SimpleAnimation.cpp
new language, new compiler
[l2e.git] / src / graphics / SimpleAnimation.cpp
index baed3419188b2f393e0e27ade3d3b56f7e38f0f3..75a327bd786c30a3809953cf39e37da8d0fe3906 100644 (file)
@@ -9,6 +9,46 @@ using loader::TypeDescription;
 
 namespace graphics {
 
+SimpleAnimation::SimpleAnimation()
+: numFrames(0)
+, col(0)
+, row(0) {
+
+}
+
+SimpleAnimation::SimpleAnimation(
+               const Sprite *sprite,
+               int frameTime,
+               int numFrames,
+               int col,
+               int row,
+               bool repeat)
+: Animation(sprite, frameTime, repeat)
+, numFrames(numFrames)
+, col(col)
+, row(row) {
+
+}
+
+SimpleAnimation::SimpleAnimation(loader::noinit_t n)
+: Animation(n) {
+
+}
+
+
+int SimpleAnimation::NumFrames() const {
+       return numFrames;
+}
+
+int SimpleAnimation::Col(int frame) const {
+       return col;
+}
+
+int SimpleAnimation::Row(int frame) const {
+       return row + frame;
+}
+
+
 void SimpleAnimation::CreateTypeDescription() {
        SimpleAnimation sa;
        Animation *a(&sa);
@@ -16,6 +56,7 @@ void SimpleAnimation::CreateTypeDescription() {
        TypeDescription &td(TypeDescription::Create(TYPE_ID, "SimpleAnimation"));
        td.SetDescription("An animation that uses a fixed column and increasing row of a sprite based on the frame number.");
        td.SetConstructor(&Construct);
+       td.SetInitializer(&Initialize);
        td.SetSize(sizeof(SimpleAnimation));
        td.AddSupertype(Animation::TYPE_ID, ((char *)a) - ((char *)&sa));
 
@@ -29,4 +70,8 @@ void SimpleAnimation::Construct(void *data) {
        new (data) SimpleAnimation;
 }
 
+void SimpleAnimation::Initialize(void *data) {
+       new (data) SimpleAnimation(loader::noinit);
+}
+
 }