06-20-2005, 02:30 AM
infantry.bas
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 (tileW as INTEGER, tileH as INTEGER)
'DIM NumUnits as Integer, NumArmies as integer, NumSoldiers as integer
DIM shared MapW as integer, MapH as integer
DIM Shared XMin as integer, Ymin 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 TerrainTile(0 to (TileW * TileH) / 2) as integer
DIM ObjTile(0 to (ObjW * ObjH) / 2) as integer
DIM TerrainBitmap(1) as integer
DIM UnitsBitmap(1) as integer
SCREEN 15
vid.xRes = 400
vid.yRes = 300
vid.GameXRes = 400
vid.GameYRes = 300
CALL bmpLoad (dataSource + bmpSource + "terrain.bmp", TerrainBitmap())
CALL bmpLoad (dataSource + bmpSource + "units.bmp", UnitsBitmap())
mapDraw (TileW, TileH)
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$)
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
end sub
SUB mapDraw (tileW, tileH)
'r1 = INT(vid.yMin / TileH) + 1
'r2 = y1 + (vid.yRes / tileH)
'c1 = INT(vid.xMin / TileW) + 1
'c2 = x1 + (vid.xRes / TileW)
'x = ((c1 * TileW) - TileW) - xMin
'y = ((r1 * TileH) - TileH) - yMin
for r = r1 to r2
for c = c1 to c2
'CALL bmpGetTile (TerrainBitmap(), 1, 1, TerrainTile(), 32, 32)
'PUT (x,y), TerrainTile(0)
x = x + 32
next
y = y + 32
next
end sub
size=9]"To announce that there must be no criticism of the president, or that we are to stand by the president, right or wrong, is not only unpatriotic and servile, but is morally treasonable to the American public." -- Theodore Roosevelt[/size]