From: Tobias Gläßer Date: Sun, 1 Feb 2004 22:28:19 +0000 (+0000) Subject: initial X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=6647401017d30a2bec4fe3b123b1bc6ca26633b6;p=supertux.git initial SVN-Revision: 107 --- diff --git a/data/images/background/arctis.png b/data/images/background/arctis.png new file mode 100644 index 000000000..c5cac49f2 Binary files /dev/null and b/data/images/background/arctis.png differ diff --git a/data/images/highscore/highscore.png b/data/images/highscore/highscore.png new file mode 100644 index 000000000..d08f0556b Binary files /dev/null and b/data/images/highscore/highscore.png differ diff --git a/data/images/highscore/highscore.xcf b/data/images/highscore/highscore.xcf new file mode 100644 index 000000000..d8ef93132 Binary files /dev/null and b/data/images/highscore/highscore.xcf differ diff --git a/src/text.c b/src/text.c new file mode 100644 index 000000000..6a31ed7a5 --- /dev/null +++ b/src/text.c @@ -0,0 +1,89 @@ +// +// C Implementation: text +// +// Description: +// +// +// Author: Tobias Glaesser , (C) 2004 +// +// Copyright: See COPYING file that comes with this distribution +// +// + +#include +#include "globals.h" +#include "defines.h" +#include "screen.h" +#include "text.h" + +void text_load(text_type* ptext, char* file) +{ + int x, y, c; + + c = 0; + + for(y = 0; y < 3 ; ++y) + { + for(x = 0; x < 26 ; ++x) + { + texture_load_part(&ptext->chars[c],file,x*16,y*16,16,16, USE_ALPHA); + ++c; + } + } +} + +void text_draw(text_type* ptext, char* text, int x, int y, int shadowsize, int update) +{ + +if(shadowsize != 0) +text_draw(&black_text,text,x+shadowsize,y+shadowsize, 0, update); + + int len = strlen(text); + int i; + for( i = 0; i < len; ++i) + { + if( text[i] >= 'A' && text[i] <= 'Z') + { + texture_draw(&ptext->chars[(int)(text[i] - 'A')],x+i*16,y,update); + } + else if( text[i] >= 'a' && text[i] <= 'z') + { + texture_draw(&ptext->chars[(int)(text[i] - 'a') + 26],x+i*16,y,update); + } + else if ( text[i] >= '!' && text[i] <= '9') + { + texture_draw(&ptext->chars[(int)(text[i] - '!') + 52],x+i*16,y,update); + } + else if ( text[i] == '?') + { + texture_draw(&ptext->chars[77],x+i*16,y,update); + } + else if ( text[i] == '\n') + { + y += 18; + } + } +} + +void text_drawf(text_type* ptext, char* text, int x, int y, int halign, int valign, int shadowsize, int update) +{ +if(halign == A_RIGHT) +x += screen->w; +else if(halign == A_HMIDDLE) +x += screen->w/2 - ((strlen(text)*16)/2); + +if(valign == A_BOTTOM) +y += screen->h - 16; +else if(valign == A_VMIDDLE) +y += screen->h/2; + +text_draw(ptext,text,x,y,shadowsize,update); + +} + +void text_free(text_type* ptext) +{ + int c; + for( c = 0; c < 78; ++c) + texture_free(&ptext->chars[c]); +} diff --git a/src/text.h b/src/text.h new file mode 100644 index 000000000..a395f1149 --- /dev/null +++ b/src/text.h @@ -0,0 +1,41 @@ +// +// C Interface: text +// +// Description: +// +// +// Author: Tobias Glaesser , (C) 2004 +// +// Copyright: See COPYING file that comes with this distribution +// +// + +#ifndef SUPERTUX_TEXT_H +#define SUPERTUX_TEXT_H + +#include "texture.h" + +/* Text type */ +typedef struct text_type + { + texture_type chars[78]; + } +text_type; + +enum { + A_LEFT, + A_HMIDDLE, + A_RIGHT, + A_TOP, + A_VMIDDLE, + A_BOTTOM, + A_NONE +}; + +void text_load(text_type* ptext, char* file); +void text_draw(text_type* ptext, char* text, int x, int y, int shadowsize, int update); +void text_drawf(text_type* ptext, char* text, int x, int y, int halign, int valign, int shadowsize, int update); +void text_free(text_type* ptext); + +#endif /*SUPERTUX_TEXT_H*/ +