So I ported some code over from DBPro to try out my fresh install of DarkGDK, After a few minor snags (forgetting those pesky semi-colons!
) I got the program to compile and run, with one small problem.. It doesn't do what it does in DBPro
.
DBPro:
INK RGB(255, 255, 255), RGB(255, 255, 255)
CLS
DISSECT("FONT_SHEET.BMP", 13, 8, 1, 0, 255, 0)
PRINTF("Shop Clerk", 10, 10, 1)
PRINTF("That'll be $100", 10, 20, 2)
WHILE 1
SLEEP 10
IF SPACEKEY() > 0 THEN CLEARF() : PRINTF("Thank'ya", 10, 10, 1)
SYNC:CLS
ENDWHILE
FUNCTION PRINTF(QUERY AS STRING, X, Y, LINENUM)
IF LEN(QUERY) <= 128
FOR A = 0 TO LEN(QUERY)
FOR ALPHA = 1 TO 95
IF MID$(QUERY, A) = CHR$(ALPHA + 31) THEN SPRITE A + (LINENUM * 128), X + ((A * 6) - 6), Y, ALPHA
SET SPRITE A + (LINENUM * 128), 0, 1
NEXT ALPHA
NEXT A
ENDIF
ENDFUNCTION RESULT
FUNCTION CLEARF()
FOR A = 128 TO 512
IF SPRITE EXIST(A) THEN DELETE SPRITE A
NEXT A
ENDFUNCTION
FUNCTION DISSECT(FILENAME AS STRING, ACROSS, DOWN, START, R, G, B)
SET IMAGE COLORKEY R, G, B
LOAD BITMAP FILENAME, 1
X = BITMAP WIDTH(1)/ ACROSS
Y = BITMAP HEIGHT(1)/ DOWN
FOR A = 0 TO DOWN - 1
FOR B = 0 TO ACROSS - 1
GET IMAGE START + A * ACROSS + B, X * B, Y * A, X * B + X, Y * A + Y, 1
NEXT B
NEXT A
DELETE BITMAP 1
ENDFUNCTION
DarkGDK:
#include "DarkGDK.h"
void dissect (char* filename, int across, int down, int start, int r, int g, int b);
void printfont (char* query, int x, int y, int line);
void clearfont (void);
void DarkGDK (void)
{
dbSyncOn ();
dbSyncRate (60);
dbRandomize (dbTimer ());
dbInk (dbRGB (255, 255, 255), dbRGB (255, 255, 255));
dbCLS ();
dissect ("FONT_SHEET.bmp", 13, 8, 1, 0, 255, 0);
printfont ("Hello World!", 10, 10, 1);
while (LoopGDK ())
{
dbSleep (10);
if (dbSpaceKey () > 0)
{
clearfont ();
printfont ("Goodbye Cruel World! :(", 10, 10, 1);
}
dbSync ();
dbCLS ();
}
clearfont ();
return;
}
void printfont (char* query, int x, int y, int line)
{
int i;
int a;
if (dbLen (query) <= 128)
{
for (a = 0; a < dbLen (query); a++)
{
for (i = 0; i < 96; i++)
{
if (dbMid (query, a) == dbChr(i + 31))
{
dbSprite (a + (line * 128), x + ((a * 6) - 6), y, i);
}
dbSetSprite (a + (line * 128), 0, 1);
}
}
}
}
void clearfont (void)
{
int i;
for (i = 0; i < 512; i++)
{
if (dbSpriteExist(i))
{
dbDeleteSprite(i);
}
}
}
void dissect (char* filename, int across, int down, int start, int r, int g, int b)
{
int ia = 0;
int ib = 0;
dbSetImageColorKey( r, g, b);
dbLoadBitmap (filename, 1);
int x = dbBitmapWidth (1) / across;
int y = dbBitmapHeight (1) / down;
for (ia = 0; ia < down; ia++)
{
for (ib = 0; ib < across; ib++)
{
dbGetImage (start + ia * across + ib, x * ib, y * ia, x * ib + x, y * ia + y, 1);
}
}
}
That's the code, and what it does is takes the Font Sheet (Attached) and cuts it up into single characters then analyzes the input string and pastes the characters to the screen thus making the string in a custom font. And it works all fine and well in DBPro, but not DarkGDK.
I am a complete noob at C++ so go easy
EDIT: I found the problem lies somewhere in the Dissect function..
EDIT2: Further testing leads me to believe that the dbGetImage command is not implemented correctly in my program, even though it's the same syntax as the DBPro command. Also uploaded Original DBP source.
If you have X-ray vision, can you see through your own eyelids?