Hi,
Yesterday, i started making small game like "DiamondMine" as the following screen shot..
created 8 x 8 map and array contains tiles 32x32, i can't test the game because the compiler gave me errors, i can't fix it..!!!
DrawMap.h
#pragma once
void DrawMap( void );
extern const int MAP_WIDTH;
extern const int MAP_HEIGHT;
extern int n;
extern int m;
Game.h
#pragma once
void Game( void );
DrawMap.cpp
#include "DarkGDK.h"
#include "DrawMap.h"
#include "Game.h"
void DrawMap()
{
dbLoadImage( "../Misc/Tile1.bmp", 1);
dbLoadImage( "../Misc/Tile2.bmp", 2);
dbLoadImage( "../Misc/Grass1.bmp", 3);
dbLoadImage( "../Misc/Man.bmp", 4);
int n;
int m;
for(int y = 0; y < MAP_HEIGHT; y++)
{
for(int x = 0; x < MAP_WIDTH; x++, n++, m++)
{
if( TestMap[y][x] == 1 )
{
dbSprite( n, (15 * x), (15 * y), 1 );
dbSetSpritePriority ( n, 1 );
if( TestMap[y-1][x] != 1 )
{
dbSprite( m, (15 * x), (15 * y) - 15, 3 );
dbSetSpritePriority ( m, 5 );
}
}
if( TestMap[y][x] == 2 )
{
dbSprite( n, (15 * x), (15 * y), 2 );
dbSetSpritePriority ( n, 1 );
//struct posofblock
//{
// int XPos;
// int YPos;
//} Block[n];
}
}
}
}
Game.cpp
#include "DarkGDK.h"
#include "DrawMap.h"
#include "Game.h"
// make size of the map 8 element x 8 element
const int MAP_WIDTH = 8;
const int MAP_HEIGHT = 8;
int TestMap[MAP_HEIGHT][MAP_WIDTH]=
{
{1,1,1,1,1,1,1,1},
{1,2,2,2,2,2,2,2},
{1,2,2,2,2,2,2,2},
{1,2,2,2,2,2,2,2},
{1,1,1,1,1,1,1,2},
{1,1,1,1,1,1,1,2},
{1,2,2,2,2,2,2,2},
{1,2,2,2,2,2,2,2}
};
int TestMapEnt[MAP_HEIGHT][MAP_WIDTH]=
{
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0}
};
struct Client
{
int XPos;
int YPos;
};
// create 2d array for matching
//int tileArray [2][2] =
//{
//{0,1},
//{1,0}
//};
Main.cpp
// whenever using Dark GDK you must ensure you include the header file
#include "DarkGDK.h"
#include "DrawMap.h"
#include "Game.h"
// the main entry point for the application is this function
void DarkGDK ( void )
{
//turning the sync rate on, maximum sync rate to 60
dbSyncOn ( );
dbSyncRate ( 60 );
// include main functions
DrawMap();
Game();
// now we come to our main loop, we call LoopGDK so some internal
// work can be carried out by the GDK
while ( LoopGDK ( ) )
{
// here we make a call to update the contents of the screen
dbSync ( );
}
// delete all the sprites
for ( int i = 1; i < 30; i++ )
dbDeleteSprite ( i );
// delete the backdrop image
dbDeleteImage ( 1 );
// and now everything is ready to return back to Windows
return;
}
output report
------ Build started: Project: Dark GDK - 2D Game1, Configuration: Debug Win32 ------
Compiling...
DrawMap.cpp
f:\gameon®\matching_game\dark gdk - 2d game1\drawmap.cpp(20) : error C2065: 'TestMap' : undeclared identifier
f:\gameon®\matching_game\dark gdk - 2d game1\drawmap.cpp(25) : error C2065: 'TestMap' : undeclared identifier
f:\gameon®\matching_game\dark gdk - 2d game1\drawmap.cpp(31) : error C2065: 'TestMap' : undeclared identifier
Game.cpp
Generating Code...
Build log was saved at "file://f:\GameOn®\Matching_Game\Dark GDK - 2D Game1\Debug\BuildLog.htm"
Dark GDK - 2D Game1 - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========