Ofcourse!
This is the array that stores which tiles go where, also stores what kind of tower is where, too.
int a[LENGTH][WIDTH] = {
2,2,2,2,2,2,2,2,2,2,
2,3,3,3,3,3,3,3,3,2,
2,3,3,3,3,3,3,3,3,2,
3,3,3,3,3,3,3,3,3,3,
1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,
3,3,3,3,3,3,3,3,3,3,
2,3,3,3,3,3,3,3,3,2,
2,3,3,3,3,3,3,3,3,2,
2,2,2,2,2,2,2,2,2,2,
};
This is the function that draws the map, it's a pretty simple loop that draws a sprite depending on what number is in that spot in the above array. The variable SZ is the pixel size of the image, in this chase 48x48. This draws the map sideways, but I thought it looked better that way, so yeah.

Just switch the count and count2 around to fix it.
int drawmap(int a[10][10], int sz)
{
while (count2 < WIDTH)
{
while (count < LENGTH)
{
dbSprite(count3,sz*count,sz*count2,a[count][count2]);
count++;
count3++;
}
count2++;
count = 0;
}
return 0;
}
This checks which sprite is clicked, by looping through spriteID's 1-100 (10x10 tilemap), and checking if the cursor is inside the range of the image.
int SpriteCheck(int num)
{
int count = 0;
if (dbMouseClick())
{
while (count <= num)
{
if (dbMouseX() > dbSpriteX(count) &&
dbMouseY() > dbSpriteY(count) &&
dbMouseX() < dbSpriteX(count)+48 &&
dbMouseY() < dbSpriteY(count)+48)
{
return count;
}
count++;
}
}
}
This checks if the user clicked a (the only one for now) tower from the menu, and lets the user drag it around if he did.
int DrawToCursor(int check3)
{
if (check3 == 200 && holdingtower == 0)
{
holdingtower = 1;
}
if (holdingtower == 1)
{
dbSprite(299,dbMouseX()-24,dbMouseY()-24,21);
}
return 0;
if (holdingtower == 0)
{
dbDeleteSprite(299);
}
}
This draws a tower if the user clicks an avaliable tile, while dragging a tower.
int DrawTower(int check3, int holdingtower)
{
if (dbMouseClick() == 1)
{
if (clicked == 0)
{
if (holdingtower == 1 && cash >= 100)
{
if (a[dbSpriteX(check3)/48][dbSpriteY(check3)/48] == 3 && dbSpriteX(check3) < 480 && dbSpriteY(check3) < 480)
{
dbSprite(900+towers,dbSpriteX(check3),dbSpriteY(check3),21);
holdingtower = 0;
towers++;
clicked = 1;
cash-=100;
a[dbSpriteX(check3)/48][dbSpriteY(check3)/48] = 4;
maketextimage(1000,200,200,dbStr(cash));
}
}
}
}
else
{
clicked = 0;
}
return 0;
}
Sorry for the lack of //comments!
Edit: Oh and I also made this very nifty little function:
int maketextimage(int id, int len, int hig, char *text)
{
dbSetImageColorKey(0,0,0);
dbCreateBitmap(1,len,hig);
dbText(0,0,text);
dbGetImage(id,0,0,len,hig);
dbDeleteBitmap(1);
return 0;
}
That will make an image out of text, so that you can display the text above other sprites which you can't do with dbPrint or dbText(I think)!