4 * Created on: Aug 8, 2012
12 using geometry::Vector;
17 void Font::DrawChar(char c, SDL_Surface *dest, const Vector<int> &position) const {
18 int col(colOffset + (c % 0x10));
19 int row(rowOffset + (c / 0x10));
20 sprite->Draw(dest, position, col, row);
23 void Font::DrawString(const char *s, SDL_Surface *dest, const Vector<int> &positionIn, int maxChars) const {
24 Vector<int> position(positionIn);
25 Vector<int> step(CharWidth(), 0);
26 for (int i(0); s[i] && (maxChars <= 0 || i < maxChars); ++i, position += step) {
27 DrawChar(s[i], dest, position);
31 void Font::DrawDigit(int digit, SDL_Surface *dest, const Vector<int> &position) const {
32 DrawChar(digit + 0x30, dest, position);
35 void Font::DrawNumber(int numberIn, SDL_Surface *dest, const Vector<int> &positionIn, int digits) const {
37 if (digits > 0 && numberIn >= pow(10.0, digits)) {
38 numberIn = pow(10.0, digits) - 1;
41 Vector<int> position(positionIn);
42 Vector<int> step(sprite->Width(), 0);
46 while (number < pow(10.0, i) && i > 0) {
59 DrawDigit((number / m) % 10, dest, position);