Here is the updated code. Note": I removed the text on how to create the iso tiles, also you need to have a cursor.bmp file in this version.
Rem Project: IsoHexDemo
Rem Created: 4/9/2003 7:25:35 PM
remstart
*******************************************************************************************
* Isometric Tile Engine for DarkBasic Pro *
* *
* Translated by [Zenassem] Edward Jomisko *
* Adapted from the book: "Isometric Game Programming With DirectX 7.0" by Ernest Pazera *
* *
* Note: The original code was written in C++ *
* This work is an attempt to port the code to the DarkBasic Programming language *
*******************************************************************************************
Isometric [Diamond Type] Engine will contain the following components
TilePlotter: Converts actual array indexes into Screen coordinates
MouseMap : Converts Screen Coordiates into actual array indexes
TileWalker :
***** Tiles ******
Tiles are created as follows:
size: 64x32 (0-63x0-31)
transparent pixels are represented as: 0
textured pixels are represented as: 1
remend
Rem ***** Main Source File *****
rem ////////////////////////////////////////////////////////////////////////////////////////
rem ***** I N I T I Al I Z A T I O N *****
ink 0,0
sync rate 0
sync on
hide mouse
rem ***** Game Flags *****
FL_GameDone=0
rem ***** Load Cursor *****
load bitmap "cursor.bmp",1
get image 100,0,0,11,17
delete bitmap 1
rem ***** May try to use types need to find out if they can be passed to functions !!!!!e rect
rem ***** Load World Tiles *****
load image "land.bmp", 1
load image "dessert.bmp",2
load image "water.bmp",3
load image "forrest.bmp",4
load image "roadse.bmp",5
load image "roadsw.bmp",6
load image "road4.bmp",7
load image "road6.bmp",8
load image "rightpanel.bmp",200
rem ***** Initialize World Constants *****
global TileWidth=64
global TileHeight=32
global WorldSizeX=40
global WorldSizeY=40
global offsetx=0
global offsety=0
global cursorx=20
global cursory=20
global wx=480
global wy=416
global dim Ar_World(WorldSizeX,WorldSizeY)
rem ***** Initialize World Map *****
restore worlddata
for MapY=0 to WorldSizeY-1
for MapX=0 to WorldSizeX-1
read ImageNumber
Ar_World(MapX,MapY) = ImageNumber
next MapX
next MapY
goto main
rem ////////////////////////////////////////////////////////////////////////////////////////
rem ***** F U N C T I O N S *****
rem ******* Tile_Plotter()
function Tile_Plotter()
for MapY=0 to WorldSizeY-1
for MapX=0 to WorldSizeX-1
ImageNumber = Ar_World(MapX,MapY)
ptMapX=MapX
ptMapY=MapY
ptScreenX=(ptMapX-ptMapY)*TileWidth/2
ptScreenY=(ptMapX+ptMapY)*TileHeight/2
if ptScreenX+offsetx < wx and ptScreenY+offsetY< wy
paste image ImageNumber , ptScreenX+offsetX, ptScreenY+offsety, 1
endif
next MapX
next MapY
endfunction
rem ////////////////////////////////////////////////////////////////////////////////////////
rem ***** M A I N G A M E L O O P *****
main:
sprite 1,320,240,100
while FL_GameDone<>1
cls 1
Tile_Plotter()
if escapekey()=1 then FL_GameDone=1
if rightkey()=1 then offsetx=offsetx-32
if leftkey()=1 then offsetx=offsetx+32
if downkey()=1 then offsety=offsety-32
if upkey()=1 then offsety=offsety+32
gosub handle_mouse
box 480,0,639,479
box 0,416,481,479
paste image 200,482,0
sync
endwhile
rem ***** E N D O F M A I N L O O P ******
rem ////////////////////////////////////////////////////////////////////////////////////////
handle_mouse:
cursorx=mousex()
cursory=mousey()
paste sprite 1,cursorx,cursory
rem ***** Scroll East *****
if cursorx>630 and cursory>60 and cursory<420
offsetx=offsetx-8
endif
rem ***** Scroll West *****
if cursorx<10 and cursory>60 and cursory<420
offsetx=offsetx+8
endif
rem ***** Scroll North *****
if cursory<10 and cursorx>60 and cursorx<590
offsety=offsety+8
endif
rem ***** Scroll South *****
if cursory>470 and cursorx>60 and cursorx<590
offsety=offsety-8
endif
rem ***** Scroll N.E. *****
if cursorx>630 and cursory<60
offsetx=offsetx-8
offsety=offsety+8
endif
rem ***** Scroll S.E. *****
if cursorx>630 and cursory>420
offsetx=offsetx-8
offsety=offsety-8
endif
rem ***** Scroll N.W. *****
if cursorx<10 and cursory<60
offsetx=offsetx+8
offsety=offsety+8
endif
rem ***** Scroll S.W. *****
if cursorx<10 and cursory>420
offsetx=offsetx+8
offsety=offsety-8
endif
return
rem ////////////////////////////////////////////////////////////////////////////////////////
rem ***** D A T A *****
worlddata:
rem ****** Change these values to create different maps
data 4,4,4,4,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