I am trying to convert the principles in "Isometric Game Programming with DirectX 7.0" to DBpro.
Just in case there is anyone interested... figured I would post some code examples as I go. I'll update as I go along, but not making too many promises as I never seem to finish things.
Anyways, Just place my horrible-NON-seamless ground tile (which actually helps in illustrating this example
) in a project folder with the following even More-Horrible code. Then press the [Space Bar] to flip between Diamond and Staggered map plotting. It also overlays the x,y Map-coordinates so you can see the different directions of the X and Y planes.
EDIT:changed to .png file as photobucket seems to autuomatically convert .bmp to .jpg
Rem Project: IsoCraft
Rem ***** Main Source File *****
//Some Globals
global MapWidth=14 //# of tiles in width
global MapHeight=14 //# of tiles in height
global TileWidth=64 //# Width of tile graphic
global TileHeight=32 //# Height of tile graphic
global MapX=0 //# TileMap X location
global MapY=0 //# TIleMap Y location
global PlotX //Screen Pixel X location
global Ploty //Screen Pixel Y location
global maptype as boolean //Selectd either Diamond or Staggered Map (true/false)
maptype=1
// A WorldMap Array for later use in loading maps
//dim TileMap(MapWidth,MapHeight)
//for x=0 to MapWidth
//for y=0 to MapHeigth
// TileMap(MapWidth,MapHeight)=10
//next y
//next x
//
//Some Simple Display setup
sync on
sync rate 60
Set Display Mode 1024,768,32
//Load Some Simple Iso Tiles
load image "grass01-1.png",1
paste image 1,0,0,1
get image 10,0,0,TileWidth,TileHeight,1
delete image 1
//Load image "water01.bmp",1
//paste image 1,0,0,1
//get image 100,0,0,TileWidth,TileHeight,1
//delete image 1
//Load image "dirt01.bmp",1
//paste image 1,0,0,1
//get image 150,0,0,TileWidth,TileHeight,1
//delete image 1
//Need to catch whether key has been released
spacerel=1 //Assume it is released at start
cls 0
sync
// MAIN LOOP
do
if spacekey()
if spacerel=1
spacerel=0
maptype=not maptype
cls
sync
endif
else spacerel=1
endif
DrawMap()
sync
loop
//Some Functions
function DrawMap()
for y=0 to MapHeight
for x=0 to MapWidth
ptX=x
ptY=y
if maptype=1
DiamondMap_TilePlotter(ptX,ptY,TileWidth,TileHeight)
else
StagMap_TilePlotter(ptX,ptY,TileWidth,TileHeight)
endif
paste image 10,PlotX,PlotY,1
text PlotX+15,PlotY+8,str$(x)+","+str$(y)
next x
next y
endfunction
//Plot Function to create A Diamond Map
function DiamondMap_TilePlotter(px,py,tw,th)
text 300,600,"This is an example of an ISOMETRIC DIAMOND MAP"
text 400,620,"eg. AoE,Sim City 2000"
PlotX=px*tw/2-py*tw/2
PlotY=px*th/2+py*th/2
endfunction
//Plot Function to create A Staggered Map
function StagMap_TilePlotter(px,py,tw,th)
text 300,600,"This is an example of an ISOMETRIC STAGGERED MAP"
text 350,620,"eg. Civilization II, Alpha Centauri"
PlotX=px*tw+(py and 1) *(tw/2)
PlotY=py*(th/2)
endfunction