4 * Created on: Aug 8, 2012
13 using geometry::Vector;
18 void Font::DrawChar(char c, SDL_Surface *dest, const Vector<int> &position) const {
21 int col(colOffset + (c % 0x10));
22 int row(rowOffset + (c / 0x10));
23 sprite->Draw(dest, position, col, row);
26 void Font::DrawString(const char *s, SDL_Surface *dest, const Vector<int> &positionIn, int maxChars) const {
29 Vector<int> position(positionIn);
30 Vector<int> step(CharWidth(), 0);
31 for (int i(0); s[i] && (maxChars <= 0 || i < maxChars); ++i, position += step) {
32 DrawChar(s[i], dest, position);
36 void Font::DrawDigit(int digit, SDL_Surface *dest, const Vector<int> &position) const {
39 DrawChar(digit + 0x30, dest, position);
42 void Font::DrawNumber(int numberIn, SDL_Surface *dest, const Vector<int> &positionIn, int digits) const {
46 if (digits > 0 && numberIn >= pow(10.0, digits)) {
47 numberIn = pow(10.0, digits) - 1;
50 Vector<int> position(positionIn);
51 Vector<int> step(sprite->Width(), 0);
55 while (number < pow(10.0, i) && i > 0) {
68 DrawDigit((number / m) % 10, dest, position);