Mercurial > fife-parpg
comparison engine/core/video/animation.cpp @ 378:64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
author | vtchill@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Mon, 11 Jan 2010 23:34:52 +0000 |
parents | 3804348fe3fb |
children | 16c2b3ee59ce |
comparison
equal
deleted
inserted
replaced
377:fe6fb0e0ed23 | 378:64738befdf3b |
---|---|
77 val = i->second.index; | 77 val = i->second.index; |
78 } | 78 } |
79 return val; | 79 return val; |
80 } | 80 } |
81 | 81 |
82 bool Animation::isValidIndex(int index) { | 82 bool Animation::isValidIndex(int index) const{ |
83 int size = m_frames.size(); | 83 int size = m_frames.size(); |
84 if ((size == 0) || (index > (size - 1)) || (index < 0)) { | 84 return size > 0 && index >= 0 && index < size; |
85 return false; | |
86 } | |
87 return true; | |
88 } | 85 } |
89 | 86 |
90 Image* Animation::getFrame(int index) { | 87 Image* Animation::getFrame(int index) { |
91 if (isValidIndex(index)) { | 88 if (isValidIndex(index)) { |
92 return m_frames[index].image.get<Image>(); | 89 return m_frames[index].image.get<Image>(); |
97 | 94 |
98 Image* Animation::getFrameByTimestamp(unsigned int timestamp) { | 95 Image* Animation::getFrameByTimestamp(unsigned int timestamp) { |
99 return getFrame(getFrameIndex(timestamp)); | 96 return getFrame(getFrameIndex(timestamp)); |
100 } | 97 } |
101 | 98 |
102 int Animation::getFrameDuration(int index) { | 99 int Animation::getFrameDuration(int index) const{ |
103 if (isValidIndex(index)) { | 100 if (isValidIndex(index)) { |
104 return m_frames[index].duration; | 101 return m_frames[index].duration; |
105 } else { | 102 } else { |
106 return -1; | 103 return -1; |
107 } | 104 } |
110 unsigned int Animation::getNumFrames() const { | 107 unsigned int Animation::getNumFrames() const { |
111 return m_frames.size(); | 108 return m_frames.size(); |
112 } | 109 } |
113 | 110 |
114 void Animation::setDirection(unsigned int direction) { | 111 void Animation::setDirection(unsigned int direction) { |
115 m_direction = direction % 360; | 112 m_direction %= 360; |
116 } | 113 } |
117 } | 114 } |
118 /* vim: set noexpandtab: set shiftwidth=2: set tabstop=2: */ | 115 /* vim: set noexpandtab: set shiftwidth=2: set tabstop=2: */ |