X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fgraphics%2FSimpleAnimation.cpp;h=24985f91ebb12e5db89143389f29a29a71f2d4d8;hb=2255d436a0c2acc10b015827366a72b2ece86094;hp=17a0857832ce8dcfbe75b297f9113515aad4f8a3;hpb=46d158b25b842d2ec4b9734af09ca6006c934498;p=l2e.git diff --git a/src/graphics/SimpleAnimation.cpp b/src/graphics/SimpleAnimation.cpp index 17a0857..24985f9 100644 --- a/src/graphics/SimpleAnimation.cpp +++ b/src/graphics/SimpleAnimation.cpp @@ -1,33 +1,67 @@ -/* - * SimpleAnimation.cpp - * - * Created on: Sep 5, 2012 - * Author: holy - */ - #include "SimpleAnimation.h" +#include "../loader/Interpreter.h" #include "../loader/TypeDescription.h" using loader::FieldDescription; +using loader::Interpreter; 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) { + +} + + +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); - int animationId(TypeDescription::GetTypeId("Animation")); - int numberId(TypeDescription::GetTypeId("Number")); - - TypeDescription &td(TypeDescription::CreateOrGet("SimpleAnimation")); + 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.SetSize(sizeof(SimpleAnimation)); - td.AddSupertype(animationId, ((char *)a) - ((char *)&sa)); + td.AddSupertype(Animation::TYPE_ID, ((char *)a) - ((char *)&sa)); + + Animation::AddFields(td, sa, ((char *)a) - ((char *)&sa)); + td.AddField("framecount", FieldDescription(((char *)&sa.numFrames) - ((char *)&sa), Interpreter::NUMBER_ID).SetDescription("number of frames of a single run")); + td.AddField("col", FieldDescription(((char *)&sa.col) - ((char *)&sa), Interpreter::NUMBER_ID).SetDescription("the column of the sprite to draw from")); + td.AddField("row", FieldDescription(((char *)&sa.row) - ((char *)&sa), Interpreter::NUMBER_ID).SetDescription("the row of the sprite of the first frame")); +} - td.AddField("framecount", FieldDescription(((char *)&sa.numFrames) - ((char *)&sa), numberId, false)); - td.AddField("col", FieldDescription(((char *)&sa.col) - ((char *)&sa), numberId, false)); - td.AddField("row", FieldDescription(((char *)&sa.row) - ((char *)&sa), numberId, false)); +void SimpleAnimation::Construct(void *data) { + new (data) SimpleAnimation; } }