modified.
. Some stupid errors have been fixed as well (typos, putting x1 instead of c1, etc).
Code:
CONST dataSource = "data\"
CONST bmpSource = "bmp\"
CONST ClassGI = 1
CONST ClassLight = 2
CONST ClassRocket = 3
CONST ClassMortar = 4
CONST ClassDoctor = 5
CONST ClassSpy = 6
CONST WeaponBullet = 1
CONST WeaponRocket = 2
CONST WeaponMortar = 3
CONST TileW = 32
CONST TileH = 32
CONST ObjW = 16
CONST ObjH = 16
CONST NumUnits = 6
CONST NumArmies = 2
CONST NumSoldiers = 32
DECLARE SUB bmpLoad (file$, array() as INTEGER)
DECLARE SUB bmpGetTile (arrayIn() as INTEGER, r as INTEGER, c as INTEGER, arrayOut() as INTEGER, w as INTEGER, h as INTEGER)
DECLARE SUB mapLoad (file$)
DECLARE SUB mapDraw ()
DIM shared MapW as integer, MapH as integer
MapW = 16
MapH = 16
type vid
xMin as integer
yMin as integer
xRes as integer
yRes as integer
GameXRes as integer
GameYRes as integer
end type
type Weapon
x as integer
y as integer
alt as integer
Owner as integer
Firepower as integer
end type
type object
x as integer
y as integer
row as integer
col as integer
Label as string * 16
end type
type UnitClass
Firepower as integer
Armor as integer
Hitpoints as integer
ShootX as string * 8
ShootY as string * 8
BurstTime as integer
WaitTime as integer
Weapon as integer
Stealth as integer
Frames as integer 'Animation frames per direction. Usually 4 (3 to walk, 1 to fire)
end type
type Soldier
Object as object
Class as Integer
Hitpoints as integer
Army as integer
Team as integer
InFoxhole as integer
end type
type Army
IDColor as integer
SoldierGFX(NumUnits) as LONG
end Type
type Terrain
Tile as long
Overlay as long
Walkable as integer
InOrOutside as integer
end Type
DIM Units(NumUnits) as UnitClass
DIM Armies(NumArmies) as Army
DIM Soldiers(NumSoldiers) as Soldier
DIM SHARED vid as Vid
DIM SHARED Map(MapH, MapW) as integer
DIM SHARED MapOverlay(MapH, MapW) as integer
DIM SHARED TerrainTile(0 to (TileW * TileH) / 2) as integer
DIM SHARED ObjTile(0 to (ObjW * ObjH) / 2) as integer
DIM SHARED TerrainBitmap(0 to 1) as integer
DIM SHARED UnitsBitmap(0 to 1) as integer
SCREEN 14
vid.xMin = 0
vid.yMin = 0
vid.xRes = 320
vid.yRes = 240
vid.GameXRes = 320
vid.GameYRes = 480
bmpLoad (dataSource + bmpSource + "terrain.bmp", TerrainBitmap())
bmpGetTile (TerrainBitmap(), 1, 1, TerrainTile(), TileW, TileH)
PUT (0,0), TerrainTile(0), PSet
bmpLoad (dataSource + bmpSource + "units.bmp", UnitsBitmap())
bmpGetTile (UnitsBitmap(), 1, 1, ObjTile(), ObjW, ObjH)
PUT (0,0), ObjTile(0), PSet
Read MapW, MapH
REDIM Map(1 to MapW, 1 to MapH)
REDIM MapOverlay(1 to MapW, 1 to MapH)
vid.xMin = 0
vid.yMin = 0
for r = 1 to MapH
for c = 1 to MapW
Read Map(r, c)
next
next
'mapLoad ("")
'mapDraw ()
sleep
END
DATA 16, 16
' 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
DATA 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
DATA 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
DATA 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
DATA 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
DATA 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
DATA 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
DATA 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
DATA 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
DATA 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
DATA 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
DATA 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
DATA 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
DATA 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
DATA 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
DATA 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
DATA 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
SUB bmpLoad (file$, array() as INTEGER)
ff = FREEFILE
OPEN file$ for binary as #ff
size = LOF(ff)
CLOSE #ff
REDIM array(size - 7)
'print size
BLOAD file$, VARPTR(array(0))
'PUT (0,0), Array(0)
END SUB
SUB bmpGetTile (arrayIn(), r, c, arrayOut(), w, h)
x = (c - 1) * (w + 1)
y = (r - 1) * (h + 1)
GET arrayIn, (x,y)-(x + w - 1, y + h - 1), arrayOut(0)
END SUB
SUB mapLoad (file$)
end sub
SUB mapDraw ()
' r1 = INT(vid.yMin / TileH) + 1
' r2 = r1 + INT(vid.yRes / tileH)
' c1 = INT(vid.xMin / TileW) + 1
' c2 = c1 + INT(vid.xRes / TileW)
'x = (c1 - 1) * TileW - vid.xMin
'y = (r1 - 1) * TileH - vid.yMin
for r = r1 to r2
for c = c1 to c2
' bmpGetTile (TerrainBitmap(), 1, 1, TerrainTile(), 32, 32)
' PUT (x,y), TerrainTile(0)
x = x + 32
next
y = y + 32
next
end sub