From: Jason Woofenden Date: Fri, 16 Feb 2007 14:06:37 +0000 (+0000) Subject: Changes from August-November 2006 -- detailed history was lost. X-Git-Tag: 0.5~10 X-Git-Url: https://jasonwoof.com/gitweb/?p=vor.git;a=commitdiff_plain;h=88a9e026caed5568363cefb7d49308b875dc5e4a Changes from August-November 2006 -- detailed history was lost. Rounding errors that were causing crashes on x86. POV-Ray font. High score name entry. --- diff --git a/INSTALL b/INSTALL index 607ea94..ec19922 100644 --- a/INSTALL +++ b/INSTALL @@ -12,6 +12,8 @@ BUILDING "cd" to the vor source directory and type "make" at the command prompt. + For the brave: see also BUILDING ON WINDOWS below + RUNNING "./vor" @@ -23,8 +25,32 @@ INSTALLING Just type "make install" at the command prompt. - By default it puts executable in /usr/games/bin and the data in + By default it puts the executable in /usr/games/bin and the data in /usr/share/vor. If you'd like to change either, edit the Makefile before building. If you change these settings in the Makefile after building, you'll have to "make clean" and build again before installing. + + + +BUILDING ON WINDOWS + + 1) Grab a copy of the vor source code with the images already rendered. If + you want to compile from the latest sources in the repository, you'll have + to check out onto a unix machine, and "make data" to render the ships and + rocks. The source tarballs usually have these rendered already. + + 2) download sdl source from libsdl.org. follow these instructions to + install msys, mingw, and sdl: + + http://www.libsdl.org/extras/win32/mingw32/README.txt + + stay in the shell for step 3: + + 3) download, unpack and install sdl-mixer and sdl-image from source (should + (I hope) work the same way as installing sdl in step 2 above.) + + http://www.libsdl.org/projects/SDL_mixer/index.html + http://www.libsdl.org/projects/SDL_image/index.html + + 4) run this command in the vor source directory: mingw-make -f Makefile.win diff --git a/Makefile b/Makefile index 90e50a6..e94a765 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ cflags := $(sdl-cflags) $(paths) $(CFLAGS) my_objects := args.o dust.o file.o mt.o rocks.o score.o sprite.o sound.o my_objects += main.o -libs := SFont.o +libs := font.o objects := $(libs) $(my_objects) rocks := 00 01 02 03 04 05 06 07 08 09 @@ -39,7 +39,7 @@ rocks += 20 21 22 23 24 25 26 27 28 29 rocks += 30 31 32 33 34 35 36 37 38 39 rocks += 40 41 42 43 44 45 46 47 48 49 rocks := $(rocks:%=data/rock%.png) -graphics := data/ship.png data/life.png $(rocks) +graphics := data/ship.png data/life.png data/font.png $(rocks) INSTALL := install INSTALL_PROGRAM := $(INSTALL) -o games -g games @@ -63,7 +63,7 @@ program: vor $(my_objects): config.h -SFont.o: SFont.h +font.o: font.h args.o: args.h @@ -98,10 +98,10 @@ clean: program-clean maintainer-clean: program-clean data-clean program-clean: - rm -f *.o vor + rm -f *.o vor font_guts font_guts.pov data-clean: - rm -f $(graphics) + rm -f $(graphics) font_guts.pov mkinstalldirs: if [ ! -d $(DATA_PREFIX) ]; then mkdir $(DATA_PREFIX); fi diff --git a/Makefile.win b/Makefile.win index 90ceab3..29fe5e7 100644 --- a/Makefile.win +++ b/Makefile.win @@ -21,7 +21,7 @@ CFLAGS := -Wall -O3 -ISDL my_objects := args.o dust.o file.o mt.o rocks.o score.o sprite.o sound.o my_objects += main.o -libs := SFont.o +libs := font.o objects := $(libs) $(my_objects) rocks := 00 01 02 03 04 05 06 07 08 09 @@ -30,7 +30,7 @@ rocks += 20 21 22 23 24 25 26 27 28 29 rocks += 30 31 32 33 34 35 36 37 38 39 rocks += 40 41 42 43 44 45 46 47 48 49 rocks := $(rocks:%=data\rock%.png) -graphics := data\ship.png data\life.png $(rocks) +graphics := data\ship.png data\life.png data\font.png $(rocks) .PHONY: all clean @@ -42,7 +42,7 @@ all: vor $(my_objects): config.h -SFont.o: SFont.h +font.o: font.h args.o: args.h diff --git a/README b/README index 5f702d5..29eb721 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -Variations on Rockdodger 0.3 +Variations on Rockdodger 0.5 VoR is a quick action game where you drive a space ship and try to avoid crashing into rocks. Current information about vor can be found on the @@ -15,16 +15,12 @@ with quite a few modifications, both user-visible changes and internal technical improvements. Available for download from http://qualdan.com/vor/, or you can check out the -latest SVN copy from http://josh.qualdan.com:3/svn/vor/trunk/ (Warning: Not -Always On). +latest SVN copy from svn://svn.jasonwoof.org/vor/trunk/ Note: This is a fairly hard game, intended to be a quickie game for when you want to kill a few spare minutes. For reference, my best time [Josh Grams] is about 2 minutes in version 0.3. I'm not generally very good at video games, but -I have been playing this one for quite a while now. However, you can make it -substantially easier by slowing the game down. New in version 0.3, we have a -command-line option --game-speed=N%. New players may like to try it at 0.75 or -even 0.66. +I have been playing this one for quite a while now. Changes from Rock Dodgers @@ -49,10 +45,18 @@ User-Visible Changes: up/down speed variation). Noticeably hard...err...more "interesting". * Command-line option --game-speed. +0.4: + * Rocks now bounce off each other, and are pushed by particles. + * Now with two difficulties: normal and easy. + * Better new ship placement after you die. + +0.5: + * lots of bug fixes + * tweaks to engine and explosion graphics and new font + Internal Technical Changes: - * Upgraded to SFont 2.03, which has way less cruft, but no text input - routine. + * Replaced SFont with Jason's font.c * Started factoring a lot of stuff out of main into their own .c files. * Removed a bunch of unused code. * Function definitions: name at beginning of line (line following the return diff --git a/README.font b/README.font new file mode 100644 index 0000000..561db72 --- /dev/null +++ b/README.font @@ -0,0 +1,28 @@ +How the font is generated, and how to edit it. + +The font used in VoR is generated from the pixel layout in +font_template.txt.gz. You can edit this file easily with vim. Don't unzip it, +vim handles this for you. Just open it up and do ":set nowrap". You should now +see the font and be able to edit it nicely with replace mode (hit capital "R"). + +The font is generated from this template by creating a huge blob object in +povray. A small diffuse sphere is created at the location of each # in the +template file, and the result is rendered where the density of all those +combined spheres is high enough. + +If you create a font that has considerably different dimensions you will have +to fiddle with a few numbers in the sources: + + * update the TEMPLATE_WIDTH and TEMPLATE_HEIGHT constants in font_guts.c + + * If you've changed the aspect ratio considerably: update the "up" and + "right" vectors in font.pov These determine the aspect ratio, and what area + of the coordinate space is rendered. Be sure to leave enough space around + the edges so the font doesn't get clipped. Don't worry about excess black + around the edges, it will be cropped automatically after rendering. The + constant OUTPUT_WIDTH in font_guts.c is in povray units. + + +The font template was created from the 10x20 font from the misc-fixed pack. It +was tweaked slightly in particular so the dots on the j, i and ! characters +don't touch the rest of the character. diff --git a/args.c b/args.c index 519833a..3460d70 100644 --- a/args.c +++ b/args.c @@ -35,7 +35,7 @@ show_help(void) puts("Mandatory or optional arguments to long options are also mandatory or optional"); puts("for any corresponding short options."); putchar('\n'); - puts("Report bugs to ."); + puts("Report bugs at http://jasonwoof.com/contact.pl"); } int diff --git a/dust.c b/dust.c index 5ee9e20..7b62867 100644 --- a/dust.c +++ b/dust.c @@ -32,13 +32,34 @@ move_dust(float ticks) int i; float xscroll = screendx * ticks; float yscroll = screendy * ticks; + + // Originally this code was much simpler, but it would crash sometimes + // because the floating point numbers wouldn't always round the same + // direction, and we'd ocanially try to draw off the screen. + for(i=0; i= XSIZE) motes[i].x -= XSIZE; - else if(motes[i].x < 0) motes[i].x += XSIZE; - if(motes[i].y >= YSIZE) motes[i].y -= YSIZE; - else if(motes[i].y < 0) motes[i].y += YSIZE; + + if(motes[i].x < 0) { + motes[i].x += XSIZE; + } + if(motes[i].x > (XSIZE - 0.000001)) { + motes[i].x -= XSIZE; + if(motes[i].x < 0) { + motes[i].x = 0; + } + } + + if(motes[i].y < 0) { + motes[i].y += YSIZE; + } + if(motes[i].y > (YSIZE - 0.000001)) { + motes[i].y -= YSIZE; + if(motes[i].y < 0) { + motes[i].y = 0; + } + } } } diff --git a/font.c b/font.c new file mode 100644 index 0000000..b5ba465 --- /dev/null +++ b/font.c @@ -0,0 +1,207 @@ +// Copyright (C) 2006 Jason Woofenden +// +// This file is part of VoR. +// +// VoR is free software; you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or (at your option) +// any later version. +// +// VoR is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with VoR; see the file COPYING. If not, write to the +// Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +// MA 02111-1307, USA. + +#include +#include +#include + +#include "font.h" + +font *cur_font; +extern SDL_Surface *surf_screen; + +int font_height() { + return cur_font->bounds[0].h; +} + +void font_set(font *to) { + cur_font = to; +} + +// return true if column of pixels (pix points to the top one) is all black +int line_clear(unsigned char* pix, int height, int width) { + int i; + for(i = 0; i < height; ++i) { + if(pix[0] != 0) { + return 0; + } + pix += width; + } + + return 1; +} + + +// return the number of consecutive colums of pixels are still clear (or still not clear) +int find_change(unsigned char* pix, int height, int width) { + int i; + int state = line_clear(pix, height, width); + pix += 3; + + for(i = 1; /*forever*/; pix += 3, ++i) { + if(line_clear(pix, height, width) != state) { + return i; + } + } +} + +void font_free(font* garbage) { + SDL_FreeSurface(garbage->pixels); + free(garbage); +} + +font* font_load(const char *filename) { + font* new_font; + int i; + unsigned char* pix; + int x = 0; + int width; + + new_font = (font*) malloc(sizeof(font)); + if(!new_font) { + fprintf(stderr, "couldn't allocate memory for font.\n"); + exit(1); + } + new_font->pixels = (SDL_Surface*)IMG_Load(filename); + if(!new_font->pixels) { + fprintf(stderr, "couldn't load font file '%s'.\n", filename); + exit(1); + } + + //SDL_SetColorKey(new_font->pixels, SDL_SRCCOLORKEY, 0); + + pix = new_font->pixels->pixels; + + // set all font rects to be the full height + for(i = 0; i < 94; ++i) { + new_font->bounds[i].y = 0; + new_font->bounds[i].h = new_font->pixels->h; + } + + // find the characters + new_font->bounds[0].x = 0; // the first character starts at the begining + for(i = 0; i < 93; ) { + // find the end of the character + width = find_change(pix, new_font->pixels->h, new_font->pixels->pitch); + x += width; + pix += width * new_font->pixels->format->BytesPerPixel; + new_font->bounds[i].w = width; + + ++i; + + width = find_change(pix, new_font->pixels->h, new_font->pixels->pitch); + x += width; + pix += width * new_font->pixels->format->BytesPerPixel; + new_font->bounds[i].x = x; + } + new_font->bounds[93].w = new_font->pixels->w - new_font->bounds[93].x; // the last character ends at the end + + // There is a common problem where with some fonts there is a column of all + // black pixels between the parts of the double-quote, and this code thinks + // that it is two seperate characters. This code currently assumes that + // there is no such column. To change it so it assumes that the + // double-quote character looks like 2, change the loop above to start at + // zero, and uncomment the following indented stuff. + + // // The above has 3 problems: + // + // // 1) space is missing from the begining + // // 2) ! is first instead of seccond + // // 3) " is taking 2nd and 3rd position + // + // // merge pieces of double-quote + // width = font_rects[2].x - font_rects[1].x; + // font_rects[2].w += width; + // font_rects[2].x = font_rects[1].x; + // + // // move ! + // font_rects[1].x = font_rects[0].x; + // font_rects[1].w = font_rects[0].w; + + + // the width of the space is set to half the space between the first two characters + width = new_font->bounds[1].x - (new_font->bounds[0].x + new_font->bounds[0].w); + new_font->space_width = width / 2; + new_font->letter_spacing = new_font->space_width / 4 ; + if(new_font->space_width < 2) { + new_font->space_width = 2; + } + if(new_font->letter_spacing < 1) { + new_font->letter_spacing = 1; + } + + font_set(new_font); + return new_font; +} + +void font_write(int x, int y, const char* message) { + SDL_Rect dest = {x, y, 0, font_height()}; + char c; + + if(message[0] == 0) { + return; + } + + for(c = *message++; c; c = *message++) { + if(c > 31 && c < 127) { + if(c == 32) { + dest.x += cur_font->space_width; + } else { + c -= 33; + dest.w = cur_font->bounds[(int)c].w; + SDL_BlitSurface(cur_font->pixels, &(cur_font->bounds[(int)c]), surf_screen, &dest); + dest.x += dest.w; + } + dest.x += cur_font->letter_spacing; + } else { + fprintf(stderr, "tried to print unknown char: %d (0x%x)\n", c, c); + } + } +} + +// return the width in pixels of the string +int font_width(const char* message) { + int width = 0; + char c; + + if(message[0] == 0) { + return 0; + } + + for(c = *message++; c; c = *message++) { + if(c > 31 && c < 127) { + if(c == 32) { + width += cur_font->space_width; + } else { + c -= 33; + width += cur_font->bounds[(int)c].w; + } + width += cur_font->letter_spacing; + } else { + fprintf(stderr, "tried to print unknown char: %d (0x%x)\n", c, c); + } + } + + // don't count spacing after the last char + if(width) { + width -= cur_font->letter_spacing; + } + + return width; +} diff --git a/font.h b/font.h new file mode 100644 index 0000000..1077a47 --- /dev/null +++ b/font.h @@ -0,0 +1,20 @@ +// Copyright (C) 2006 Jason Woofenden PUBLIC DOMAIN + +#ifndef __font_h__ +#define __font_h__ + +typedef struct { + SDL_Surface *pixels; + SDL_Rect bounds[94]; + int space_width; + int letter_spacing; +} font; + +font *font_load(const char* filename); // sets as the current font +void font_free(font*); +void font_set(font*); +void font_write(int x, int y, const char* message); +int font_width(const char* message); +int font_height(); + +#endif diff --git a/font.pov b/font.pov new file mode 100644 index 0000000..0fa2d77 --- /dev/null +++ b/font.pov @@ -0,0 +1,41 @@ +// pass in a random seed (integer) to this file with +K + +#include "colors.inc" + +#declare RS = seed(clock + 1); + +#macro rnd() (rand(RS)) #end + + +camera +{ + orthographic + // the _length_ of the up and right vectors determine the aspect ratio of the image (and in the case of an orthographic projection, also the _area_ visible (unless angle is defined, in which case the angle determines the visible area)) + up <0, 0.40, 0> + right <30, 0, 0> + location <0, 0, -200> + look_at <0, 0, 0> + +} + +// same light sorce as ship.pov +light_source { <-500, 500, -700> White } + + +blob{ + #include "font_guts.pov" + threshold 3 + texture { + pigment { rgb < 0.75, 0.75, 1.0 > } + finish { + ambient 0.35 + brilliance 2 + diffuse 0.3 + metallic + specular 0.6 + roughness 1/60 + reflection 0.25 + } + normal { bumps 0.1 scale 0.25 } + } +} diff --git a/font_guts.c b/font_guts.c new file mode 100644 index 0000000..af076cb --- /dev/null +++ b/font_guts.c @@ -0,0 +1,31 @@ +#include + +#define TEMPLATE_WIDTH 1870 +#define TEMPLATE_HEIGHT 17 + +#define OUTPUT_WIDTH 29.0 + +#define FACTOR (OUTPUT_WIDTH / (float)TEMPLATE_WIDTH) +#define XMIN (0 - (TEMPLATE_WIDTH / 2)) +#define YMIN (TEMPLATE_HEIGHT / 2) + +int main(int argc, char** argv) { + int bit, x, y; + + x = XMIN; y = YMIN; + while((bit = getc(stdin)) != EOF) { + if(bit == '\n') { + x = XMIN; + --y; + continue; + } + + if(bit == '#') { + // parameters to sphere (in a blob) are: {, diameter, center-density} + printf("sphere { <%f, %f, 0>, %f, 2 }\n", (float)(x * FACTOR), (float)(y * FACTOR), (float)(2.5 * FACTOR)); + } + ++x; + } + + return 0; +} diff --git a/font_template.txt.gz b/font_template.txt.gz new file mode 100644 index 0000000..a4ef99d Binary files /dev/null and b/font_template.txt.gz differ diff --git a/gfx.mk b/gfx.mk index 762d236..dd82677 100644 --- a/gfx.mk +++ b/gfx.mk @@ -2,10 +2,18 @@ gfx-deps := gfx.mk povimg.sh data/ship.png: ship.pov $(gfx-deps) - ./povimg.sh +W32 +H32 $< > $@ + ./povimg.sh +W32 +H32 $< > $@ || sh -c "rm $@; false" data/life.png: ship.pov $(gfx-deps) - ./povimg.sh +W17 +H17 $< > $@ + ./povimg.sh +W17 +H17 $< > $@ || sh -c "rm $@; false" data/rock%.png: rocks.pov $(gfx-deps) - ./povimg.sh +H52 +W52 +K$* $< > $@ + ./povimg.sh +H52 +W52 +K$* $< > $@ || sh -c "rm $@; false" + +font_guts: font_guts.c + +font_guts.pov: font_guts font_template.txt.gz + gunzip font_template.txt.gz -c | ./font_guts > $@ || sh -c "rm $@ && false" + +data/font.png: font.pov font_guts.pov + ./povimg.sh +W3000 +H40 $< > $@ || sh -c "rm $@; false" diff --git a/globals.h b/globals.h index 24e016e..7f47314 100644 --- a/globals.h +++ b/globals.h @@ -3,7 +3,7 @@ #include #include -#include "SFont.h" +#include "font.h" struct bangdots { // Bang dots have the same colour as shield dots. @@ -38,7 +38,7 @@ extern SDL_Surface *surf_rock[NROCKS], // THE ROCKS *surf_font_big; // The big font -extern SFont_Font *g_font; +extern font *g_font; // Structure global variables extern struct enginedots edot[MAXENGINEDOTS], *dotptr; diff --git a/main.c b/main.c index e2ae44e..ccaf350 100644 --- a/main.c +++ b/main.c @@ -27,7 +27,7 @@ #include #include -#include "SFont.h" +#include "font.h" #include "args.h" #include "common.h" @@ -59,7 +59,7 @@ SDL_Surface *surf_font_big; // The big font -SFont_Font *g_font; +font *g_font; // Structure global variables struct enginedots edot[MAXENGINEDOTS], *dotptr = edot; @@ -196,7 +196,7 @@ move_bang_dots(float ticks) // move and clip bdot[i].x += (bdot[i].dx - screendx)*ticks; bdot[i].y += (bdot[i].dy - screendy)*ticks; - if(bdot[i].x < 0 || bdot[i].x >= XSIZE || bdot[i].y < 0 || bdot[i].y >= YSIZE) { + if(bdot[i].x < 0 || bdot[i].x >= (XSIZE - 0.000001) || bdot[i].y < 0 || bdot[i].y >= (YSIZE - 0.000001)) { bdot[i].active = 0; continue; } @@ -310,7 +310,7 @@ move_engine_dots(float ticks) { edot[i].x += (edot[i].dx - screendx)*ticks; edot[i].y += (edot[i].dy - screendy)*ticks; edot[i].life -= t_frame*3; - if(edot[i].life < 0 || edot[i].x<0 || edot[i].x >= XSIZE || edot[i].y < 0 || edot[i].y >= YSIZE) { + if(edot[i].life < 0 || edot[i].x<0 || edot[i].x >= (XSIZE - 0.000001) || edot[i].y < 0 || edot[i].y >= (YSIZE - 0.000001)) { edot[i].active = 0; continue; } @@ -375,6 +375,10 @@ load_ship(void) load_sprite(SPRITE(&ship), "ship.png"); } +void font_cleanup() { + font_free(g_font); +} + int init(void) { @@ -437,9 +441,11 @@ init(void) { // Load the font image s = add_data_path("font.png"); if(s) { - NULLERROR(surf_font_big = IMG_Load(s)); - free(s); - g_font = SFont_InitFont(surf_font_big); + g_font = font_load(s); + atexit(&font_cleanup); + } else { + fprintf(stderr, "could create path to font\n"); + exit(1); } init_engine_dots(); @@ -501,11 +507,11 @@ draw_game_over(void) text1 = msgs[g_easy][1]; } - x = (XSIZE-SFont_TextWidth(g_font,text0))/2 + cos(fadetimer/9)*10; - SFont_Write(surf_screen,g_font,x,YSIZE-100 + cos(fadetimer/6)*5,text0); + x = (XSIZE-font_width(text0))/2 + cos(fadetimer/9)*10; + font_write(x,YSIZE-100 + cos(fadetimer/6)*5,text0); - x = (XSIZE-SFont_TextWidth(g_font,text1))/2 + sin(fadetimer/9)*10; - SFont_Write(surf_screen,g_font,x,YSIZE-50 + sin(fadetimer/4)*5,text1); + x = (XSIZE-font_width(text1))/2 + sin(fadetimer/9)*10; + font_write(x,YSIZE-50 + sin(fadetimer/4)*5,text1); } void @@ -533,12 +539,12 @@ draw_title_page(void) SDL_BlitSurface(surf_b_rockdodger,NULL,surf_screen,&dest); text = msgs[g_easy][(int)(fadetimer/35)%NSEQUENCE]; - x = (XSIZE-SFont_TextWidth(g_font,text))/2 + cos(fadetimer/4.5)*10; - SFont_Write(surf_screen,g_font,x,YSIZE-100 + cos(fadetimer/3)*5,text); + x = (XSIZE-font_width(text))/2 + cos(fadetimer/4.5)*10; + font_write(x,YSIZE-100 + cos(fadetimer/3)*5,text); text = "Version " VERSION; - x = (XSIZE-SFont_TextWidth(g_font,text))/2 + sin(fadetimer/4.5)*10; - SFont_Write(surf_screen,g_font,x,YSIZE-50 + sin(fadetimer/2)*5,text); + x = (XSIZE-font_width(text))/2 + sin(fadetimer/4.5)*10; + font_write(x,YSIZE-50 + sin(fadetimer/2)*5,text); } void @@ -649,19 +655,17 @@ gameloop() { for(;;) { ms_frame = SDL_GetTicks() - ms_end; ms_end += ms_frame; + if(ms_frame > 1000) { + ms_frame = 1000; + } t_frame = opt_gamespeed * ms_frame / 50; frames++; while(SDL_PollEvent(&e)) { switch(e.type) { case SDL_QUIT: return; - case SDL_KEYUP: - if(e.key.keysym.sym == SDLK_ESCAPE - || e.key.keysym.sym == SDLK_q) - return; - break; case SDL_KEYDOWN: - if(state == HIGH_SCORE_ENTRY) + if(state == HIGH_SCORE_ENTRY) { if(!process_score_input(&e.key.keysym)) { // Write the high score table to the file write_high_score_table(); @@ -670,6 +674,13 @@ gameloop() { state_timeout = 200; play_tune(TUNE_TITLE_PAGE); } + } else if(e.key.keysym.sym == SDLK_q) { + return; + } + + if(e.key.keysym.sym == SDLK_ESCAPE) { + return; + } break; } } @@ -822,7 +833,7 @@ main(int argc, char **argv) { frames = 0; gameloop(); end = SDL_GetTicks(); - printf("%ld frames in %ld ms, %.2f fps.\n", frames, end-start, frames * 1000.0 / (end-start)); + // printf("%ld frames in %ld ms, %.2f fps.\n", frames, end-start, frames * 1000.0 / (end-start)); return 0; } diff --git a/povimg.sh b/povimg.sh index fcc21ac..fa9f7a1 100755 --- a/povimg.sh +++ b/povimg.sh @@ -1,3 +1,3 @@ #!/bin/sh -povray -D +A -O- +FP $* 2>/dev/null | pnmcrop | pnmtopng -transparent black 2>/dev/null +povray -D +A -O- +FP $* 2>/dev/null | pnmcrop | pnmtopng -transparent '#000000' -gamma .45 2>/dev/null diff --git a/score.c b/score.c index 78a03ac..6823b57 100644 --- a/score.c +++ b/score.c @@ -22,7 +22,7 @@ #include #include -#include "SFont.h" +#include "font.h" #include "common.h" #include "config.h" @@ -56,8 +56,6 @@ struct highscore g_scores[2][N_SCORES] = { static char *titles[2] = { "Normal\n", "Easy\n" }; -extern SFont_Font *g_font; - int g_easy = 0; int cur_score = -1; // which score we're currently entering. @@ -155,28 +153,28 @@ show_score(void) char s[16]; int r = snprintf(s, 16, "Time: "); snprintscore(s+r, 16-r, score); - SFont_Write(surf_screen, g_font, XSIZE-250, 0, s); + font_write(XSIZE-250, 0, s); } void display_scores(SDL_Surface *s, uint32_t x, uint32_t y) { char t[1024]; - int i,h = SFont_TextHeight(g_font); + int i,h = font_height(); - SFont_Write(s,g_font,x+30,y,"High scores"); + font_write(x+30, y, "High scores"); y += h; - if(g_easy) SFont_Write(s,g_font,x+75,y,"(easy)"); - else SFont_Write(s,g_font,x+60,y,"(normal)"); + if(g_easy) font_write(x+75,y,"(easy)"); + else font_write(x+60,y,"(normal)"); for(i = 0; isym == SDLK_RETURN) { SDL_EnableUNICODE(0); cur_score = -1; + if(n == 0) { + name[0] = '-'; + } return false; - } else name[n++] = key->unicode; + } else if(n < 12) { + if(key->unicode >= 32 && key->unicode <= 126) { + name[n++] = key->unicode; + } + } // else drop it } return true; } diff --git a/sound.c b/sound.c index 0dc94ef..5f97756 100644 --- a/sound.c +++ b/sound.c @@ -1,5 +1,5 @@ -#include -#include +#include +#include #include #include #include