diff ppl.c @ 164:a49d431ff40e

Add a hardcoded font to PPL.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 06 Oct 2012 08:00:34 +0300
parents f1aa6e90ad22
children 3e8e0dc30711
line wrap: on
line diff
--- a/ppl.c	Sat Oct 06 08:00:24 2012 +0300
+++ b/ppl.c	Sat Oct 06 08:00:34 2012 +0300
@@ -8,6 +8,8 @@
 #include "dmimage.h"
 #include "dmtext.h"
 
+#include "pplfont.h"
+
 #include <errno.h>
 
 struct
@@ -576,30 +578,10 @@
         goto error_exit;
     }
 
-#if 0
-    if ((file = dmf_create_stdio(optFontFilename, "rb")) == NULL)
-    {
-        dmError("Error opening font file '%s', %d: %s\n",
-            optFontFilename, errno, strerror(errno));
-        goto error_exit;
-    }
-    SDL_Surface *fontbmap = dmLoadImage(file);
-    dmf_close(file);
-    if (fontbmap == NULL)
-    {
-        dmError("Could not load image file '%s'.\n", optFontFilename);
-        goto error_exit;
-    }
-
-    if ((result = dmCreateBitmapFontFromImage(fontbmap, 8, 8, &font)) != DMERR_OK)
-    {
-        dmError("Could not create a font from image, %d: %s\n",
-            result, dmErrorStr(result));
-        goto error_exit;
-    }
-    SDL_FreeSurface(fontbmap);
-#else
-    if ((file = dmf_create_stdio("fnsmall.fnt", "rb")) == NULL)
+    // Get font
+//    file = dmf_create_stdio("fnsmall.fnt", "rb");
+    file = dmf_open_memio(optFontFilename, dmPlayerFont, sizeof(dmPlayerFont));
+    if (file == NULL)
     {
         dmError("Error opening font file '%s', %d: %s\n",
             optFontFilename, errno, strerror(errno));
@@ -613,7 +595,6 @@
             result, dmErrorStr(result));
         goto error_exit;
     }
-#endif
 
     // Initialize SDL components
     if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER) != 0)
@@ -747,9 +728,7 @@
 
         currTick = SDL_GetTicks();
 #if 1
-
-
-        if (engine.plr->row != prevRow || currTick - prevTick > 50)
+        if (engine.plr->row != prevRow || currTick - prevTick > 100)
         {
             dmClearSurface(engine.screen, col.boxBg);
             
@@ -794,7 +773,7 @@
             SDL_UnlockSurface(engine.screen);
 
         SDL_Flip(engine.screen);
-        SDL_Delay(engine.pauseFlag ? 100 : 15);
+        SDL_Delay(engine.pauseFlag ? 100 : 10);
     }
 
 error_exit: