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