The goal is to create a map from an image, and create the scenario from the file later.
Thanks to help from some of you I have been progressing, but I can not continue with my project.
This is the 'code One'.
// CODE EXAMPLE 1
// ==============
// Proyecto realizado con DarkGDK ; Project make with DarkGDK
#include "DarkGDK.h"
void DarkGDK ( void )
{
char szCodigo [129] = "";
bool bBit_Map [128] [128];
dbSetDisplayMode ( 1024, 768, 32);
dbSetWindowOff ( );
dbSyncOn ( );
dbSyncRate (60);
dbSetDir("media");
dbLoadImage( "laberinto1.bmp" , 1 ); //Bitmap Size 128x128
dbPasteImage( 1 , 0 , 0 );
// PART 1. OUTPUT
if (dbFileExist ("mapa.txt")==1) dbDeleteFile ("mapa.txt");
dbOpenToWrite (1,"mapa.txt");
for (int y=0; y < 128; y++)
{
for (int x=0; x < 128; x++)
{
if (dbPoint(x,y)==0)
strcat (szCodigo, "0");
else strcat (szCodigo, "1");
}
dbWriteString ( 1 , szCodigo);
strcpy (szCodigo, "");
}
dbCloseFile ( 1 );
dbCLS ( ); // Clear Screen
// PART 2. INPUT
dbOpenToRead (1,"mapa.txt");
for (int y=1; y < 129; y++)
{
dbReadString (1,szCodigo);
for (int x=1; x < 129; x++)
{
if ((szCodigo [x-1]) == '0')
bBit_Map [ x ] [ y ] = 0;
else bBit_Map [ x ] [ y ] = 1;
}
}
dbCloseFile ( 1 );
// PART 3. DISPLAY bBit_Map
for (int y = 1; y < 129; y++)
{
for (int x = 1; x < 129; x++)
{
dbText ( (dbTextWidth ("0"))*x, (dbTextHeight ("0"))*y, dbStr ( bBit_Map [x] [y]));
}
}
// END. PRESS <ESC> TO EXIT
while ( LoopGDK ( ) )
{
// update screen
dbSync ( );
}
return;
}
This is the 'code Two'.
// CODE EXAMPLE 2
// ==============
// Proyecto realizado con DarkGDK ; Project make with DarkGDK
#include "DarkGDK.h"
void DarkGDK ( void )
{
char szCodigo [129] = "";
static int iVar1, iVar2;
bool bBit_Map [128] [128];
dbSetDisplayMode ( 1024, 768, 32);
dbSetWindowOff ( );
dbSyncOn ( );
dbSyncRate (60);
dbSetDir("media");
dbLoadImage( "laberinto1.bmp" , 1 ); //Bitmap Size 128x128
dbPasteImage( 1 , 0 , 0 );
// PART 1. OUTPUT
if (dbFileExist ("mapa.txt")==1) dbDeleteFile ("mapa.txt");
dbOpenToWrite (1,"mapa.txt");
for (int y=0; y < 128; y++)
{
for (int x=0; x < 128; x++)
{
if (dbPoint(x,y)==0)
szCodigo [x] = '0';
else szCodigo [x] = '1';
}
dbWriteString ( 1 , szCodigo);
}
dbCloseFile ( 1 );
dbCLS ( ); // Clear Screen
// PART 2. INPUT
dbOpenToRead (1,"mapa.txt");
dbReadString (1,szCodigo);
while ((dbFileEnd ( 1 )) == 0)
{
iVar1 = dbLen (szCodigo);
iVar2++;
for (int x=0; x < iVar1; x++)
{
if ((szCodigo [x]) == '0')
bBit_Map [ x+1 ] [ iVar2 ] = 0;
else bBit_Map [ x+1 ] [ iVar2 ] = 1;
}
dbReadString (1,szCodigo);
}
dbCloseFile ( 1 );
// PART 3. DISPLAY bBit_Map
for (int y = 1; y < 129; y++)
{
for (int x = 1; x < 129; x++)
{
dbText ( 8*x, 15*y, dbStr ( bBit_Map [x] [y]));
}
}
// END. PRESS <ESC> TO EXIT
while ( LoopGDK ( ) )
{
// update screen
dbSync ( );
}
return;
}
Both codes do the same thing. If viewing the file from a notepad, everything is OK. But when viewing the variable bBit_Map, all values are 1.
I think it is because Part 2 of code, only loads the first line of the file, which is 1111111111111111111111111111111...(All 1)
I try, collecting all the strings before saving the file, in that other 'code three', but don't work.
// CODE EXAMPLE 3
// ==============
// Proyecto realizado con DarkGDK ; Project make with DarkGDK
#include "DarkGDK.h"
void DarkGDK ( void )
{
dbSetDisplayMode ( 1024, 768, 32);
dbSetWindowOff ( );
dbSyncOn ( );
dbSyncRate (60);
dbSetDir("media");
dbLoadImage( "laberinto1.bmp" , 1 ); // Bitmap size 128x128
dbPasteImage( 1 , 0 , 0 );
bool bBit_Map [128] [128];
char szCodigo [16385] = ""; // (128*128)+1 = 16385
int iVar1=0;
for (int y=0; y < 128; y++)
{
for (int x=0; x < 128; x++)
{
if (dbPoint(x,y)==0)
szCodigo [iVar1] = '0';
else szCodigo [iVar1] = '1';
iVar1++;
}
}
if (dbFileExist ("mapa.txt")==1) dbDeleteFile ("mapa.txt");
dbOpenToWrite ( 1, "mapa.txt");
dbWriteString ( 1, szCodigo); //No compile error, but this order break
dbCloseFile ( 1 );
return;
}
Finally, I searched tutorials on <fstream>, but it is still not operating near the DarkGDK. 'Code Four'.
// CODE EXAMPLE 4
// ==============
// Dark GDK - The Game Creators - www.thegamecreators.com
// the wizard has created a very simple project that uses Dark GDK
// it contains the basic code for a GDK application
// whenever using Dark GDK you must ensure you include the header file
#include <fstream>
#include "DarkGDK.h"
// the main entry point for the application is this function
void DarkGDK ( void )
{
// turn on sync rate and set maximum rate to 60 fps
dbSyncOn ( );
dbSyncRate ( 60 );
// our main loop
while ( LoopGDK ( ) )
{
// update the screen
dbSync ( );
}
// return back to windows
return;
}
/* REPORT:
1>libcpmtd.lib(xdebug.obj) : warning LNK4098: la biblioteca predeterminada'libcmt.lib' entra en conflicto con otras bibliotecas; use la biblioteca /NODEFAULTLIB:biblioteca
1>libcpmtd.lib(xdebug.obj) : error LNK2019: símbolo externo __malloc_dbg sin resolver al que se hace referencia en la función "void * __cdecl operator new(unsigned int,struct std::_DebugHeapTag_t const &,char *,int)" (??2@YAPAXIABU_DebugHeapTag_t@std@@PADH@Z)
1>libcpmtd.lib(xdebug.obj) : error LNK2019: símbolo externo __free_dbg sin resolver al que se hace referencia en la función "void __cdecl operator delete(void *,struct std::_DebugHeapTag_t const &,char *,int)" (??3@YAXPAXABU_DebugHeapTag_t@std@@PADH@Z)
1>DebugDark GDK - Game2.exe : fatal error LNK1120: 2 externos sin resolver
*/
Is there a solution? I hope it will be yes.
Greetings. (translate by Google Translator)