Rounding errors that were causing crashes on x86.
POV-Ray font.
High score name entry.
"cd" to the vor source directory and type "make" at the command prompt.
+ For the brave: see also BUILDING ON WINDOWS below
+
RUNNING
"./vor"
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
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
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
$(my_objects): config.h
-SFont.o: SFont.h
+font.o: font.h
args.o: args.h
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
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
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
$(my_objects): config.h
-SFont.o: SFont.h
+font.o: font.h
args.o: args.h
-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
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
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
--- /dev/null
+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.
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 <josh@qualdan.com>.");
+ puts("Report bugs at http://jasonwoof.com/contact.pl");
}
int
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<N_DUST_MOTES; i++) {
motes[i].x -= xscroll / (1.3 + motes[i].z);
motes[i].y -= yscroll / (1.3 + motes[i].z);
- if(motes[i].x >= 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;
+ }
+ }
}
}
--- /dev/null
+// 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 <stdlib.h>
+#include <SDL.h>
+#include <SDL_image.h>
+
+#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;
+}
--- /dev/null
+// 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
--- /dev/null
+// 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 }
+ }
+}
--- /dev/null
+#include <stdio.h>
+
+#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: {<x, y, z>, diameter, center-density}
+ printf("sphere { <%f, %f, 0>, %f, 2 }\n", (float)(x * FACTOR), (float)(y * FACTOR), (float)(2.5 * FACTOR));
+ }
+ ++x;
+ }
+
+ return 0;
+}
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"
#include <SDL.h>
#include <inttypes.h>
-#include "SFont.h"
+#include "font.h"
struct bangdots {
// Bang dots have the same colour as shield dots.
*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;
#include <stdlib.h>
#include <string.h>
-#include "SFont.h"
+#include "font.h"
#include "args.h"
#include "common.h"
*surf_font_big; // The big font
-SFont_Font *g_font;
+font *g_font;
// Structure global variables
struct enginedots edot[MAXENGINEDOTS], *dotptr = edot;
// 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;
}
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;
}
load_sprite(SPRITE(&ship), "ship.png");
}
+void font_cleanup() {
+ font_free(g_font);
+}
+
int
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();
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
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
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();
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;
}
}
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;
}
#!/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
#include <stdlib.h>
#include <string.h>
-#include "SFont.h"
+#include "font.h"
#include "common.h"
#include "config.h"
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.
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; i<N_SCORES; i++) {
y += h;
snprintf(t, 1024, "#%1d",i+1);
- SFont_Write(s, g_font, x, y, t);
+ font_write(x, y, t);
snprintscore(t, 1024, g_scores[g_easy][i].score);
- SFont_Write(s, g_font, x+50, y, t);
+ font_write(x+50, y, t);
if(i == cur_score) snprintf(t, 1024, "%s_", g_scores[g_easy][i].name);
else snprintf(t, 1024, "%s", g_scores[g_easy][i].name);
- SFont_Write(s, g_font, x+180, y, t);
+ font_write(x+180, y, t);
}
}
if(key->sym == 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;
}
-#include <SDL/SDL.h>
-#include <SDL/SDL_mixer.h>
+#include <SDL.h>
+#include <SDL_mixer.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>