AnimAction.cpp

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2003-2006 The Pentagram team
00003 
00004 This program is free software; you can redistribute it and/or
00005 modify it under the terms of the GNU General Public License
00006 as published by the Free Software Foundation; either version 2
00007 of the License, or (at your option) any later version.
00008 
00009 This program is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with this program; if not, write to the Free Software
00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 */
00018 
00019 #include "pent_include.h"
00020 #include "AnimAction.h"
00021 #include "Actor.h"
00022 
00023 void AnimAction::getAnimRange(unsigned int lastanim, int lastdir,
00024                                           bool firststep, int dir,
00025                                           unsigned int& startframe, unsigned int& endframe) const
00026 {
00027         startframe = 0;
00028         endframe = size;
00029 
00030         if (flags & AAF_TWOSTEP) {
00031                 // two-step animation?
00032                 if (firststep) {
00033                         if (flags & (AAF_LOOPING | AAF_LOOPING2)) {// CHECKME: unknown flag
00034                                 // for a looping animation, start at the end to
00035                                 // make things more fluid
00036                                 startframe = size - 1;
00037                         } else {
00038                                 startframe = 0;
00039                         }
00040                         endframe = size/2;
00041                 } else {
00042                         // second step starts halfway
00043                         startframe = size / 2;
00044                         if (flags & (AAF_LOOPING | AAF_LOOPING2)) {// CHECKME: unknown flag
00045                                 endframe = size - 1;
00046                         }
00047                 }
00048         } else {
00049                 if (lastanim == action && lastdir == dir && size > 1)
00050                 {
00051                         // skip first frame if repeating an animation
00052                         startframe = 1;
00053                 }
00054         }
00055 }
00056 
00057 void AnimAction::getAnimRange(Actor* actor, int dir,
00058                                                           unsigned int& startframe,
00059                                                           unsigned int& endframe) const
00060 {
00061         getAnimRange(actor->getLastAnim(), actor->getDir(),
00062                                  (actor->getActorFlags() & Actor::ACT_FIRSTSTEP) != 0,
00063                                  dir, startframe, endframe);
00064 }

Generated on Fri Jul 27 22:27:09 2007 for pentagram by  doxygen 1.4.7