[56] | 1 | /* |
---|
| 2 | * Abuse - dark 2D side-scrolling platform game |
---|
| 3 | * Copyright (c) 1995 Crack dot Com |
---|
[494] | 4 | * Copyright (c) 2005-2011 Sam Hocevar <sam@hocevar.net> |
---|
[56] | 5 | * |
---|
| 6 | * This software was released into the Public Domain. As with most public |
---|
[555] | 7 | * domain software, no warranty is made or implied by Crack dot Com, by |
---|
| 8 | * Jonathan Clark, or by Sam Hocevar. |
---|
[56] | 9 | */ |
---|
| 10 | |
---|
[555] | 11 | #if defined HAVE_CONFIG_H |
---|
| 12 | # include "config.h" |
---|
| 13 | #endif |
---|
[56] | 14 | |
---|
[2] | 15 | #include <ctype.h> |
---|
| 16 | |
---|
[512] | 17 | #include "common.h" |
---|
| 18 | |
---|
[481] | 19 | #include "fonts.h" |
---|
[56] | 20 | |
---|
[39] | 21 | void JCFont::put_string(image *screen, int x, int y, char const *st, int color) |
---|
[2] | 22 | { while (*st) |
---|
| 23 | { put_char(screen,x,y,*st,color); |
---|
| 24 | st++; |
---|
| 25 | x+=tl; |
---|
| 26 | } |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | void JCFont::put_char(image *screen, int x, int y, char ch, int color) |
---|
| 30 | { |
---|
[4] | 31 | if (let[(int)ch]) |
---|
[2] | 32 | { |
---|
| 33 | if (color>=0) |
---|
[533] | 34 | let[(int)ch]->PutColor(screen,vec2i(x,y),color); |
---|
| 35 | else let[(int)ch]->PutImage(screen,vec2i(x,y)); |
---|
[2] | 36 | } |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | JCFont::JCFont(image *letters) |
---|
| 40 | { |
---|
[512] | 41 | tl=(letters->Size().x+1)/32; |
---|
| 42 | th=(letters->Size().y+1)/8; |
---|
[2] | 43 | |
---|
[513] | 44 | image tmp(vec2i(tl,th)); |
---|
[124] | 45 | |
---|
[2] | 46 | int ch; |
---|
[124] | 47 | |
---|
[494] | 48 | for (ch=0; ch<256; ch++) |
---|
[124] | 49 | { |
---|
| 50 | tmp.clear(); |
---|
[661] | 51 | tmp.PutPart(letters, vec2i(0, 0), vec2i(((int)ch%32)*tl, ((int)ch/32)*th), |
---|
[662] | 52 | vec2i(((int)ch%32)*tl+tl, ((int)ch/32)*th+th), 1); |
---|
[644] | 53 | let[ch] = new TransImage(&tmp, "JCfont"); |
---|
[124] | 54 | } |
---|
[2] | 55 | } |
---|
| 56 | |
---|
| 57 | JCFont::~JCFont() |
---|
| 58 | { |
---|
| 59 | int ch; |
---|
[494] | 60 | for (ch=0; ch<256; ch++) |
---|
[124] | 61 | delete let[ch]; |
---|
[2] | 62 | } |
---|
| 63 | |
---|