Isometric Demo By Jim Shaw
Originally posted at Home Brew Forums.
Not sure what I'm going to do with this but here goes.
The sprites are available here:
Mediaunpack them into the same folder as you saved the source to.
Jim
;
; Isometric Tile Demo
; By Jim Shaw 10/5/2003
;
Graphics 640,480,32,2
SetBuffer BackBuffer()
Global ISO_WIDTH=32
Global ISO_HEIGHT=32
Global xp=0
Global yp=0
Global tx=256
Global ty=256
Dim map(512,512)
initmap()
Dim tiles(10)
loadgraphics()
Repeat
Cls
draw()
man()
;debug()
Flip
controls()
Until KeyDown(1)
End
Function debug()
Color 255,0,0
Text 10,30,tx
Text 10,40,ty
tilex = xp And 63
tiley = yp And 31
tiley = tiley * 2
tiley = tiley - 32
tilex = tilex - 32
Text 10,50,tilex
Text 10,60,tiley
tilex = -tilex / 64
tiley = -tiley / 64
If tilex > tiley Then
tiley=tiley+1
Else If -tilex < tiley Then
tiley=tiley-1
End If
If tilex < -tiley Then
tilex=tilex+1
Else If tilex > -tiley Then
tilex=tilex-1
End If
map(tx+tilex,ty+tiley)=Rand(0,9)
End Function
Function man()
Color 255,0,0
Rect 320-2,240-2,5,5
End Function
Function controls()
yp = yp - KeyDown(200) + KeyDown(208)
xp = xp + 2*KeyDown(205) - 2*KeyDown(203)
If KeyDown(57)
tx=256
ty=256
xp=0
yp=0
End If
; Repeat
; Until (Not KeyDown(200)) And (Not KeyDown(208)) And (Not KeyDown(205)) And (Not KeyDown(203))
End Function
Function loadgraphics()
For x=0 To 9
file$ = "tile"+Str$(x)+".bmp"
tiles(x) = LoadImage(file$)
MaskImage tiles(x),246,119,56
Next
End Function
Function draw()
tx = 256 + ((xp-16)/32)
ty = 256 + ((yp-16)/32)
xo = ((xp-16) And 31)
yo = ((yp-16) And 31)
For y=-8 To 8
For x=-11 To 10
sx = 320-xo + x * ISO_WIDTH
sy = 240-yo + y * ISO_HEIGHT + ((tx + x) And 1) * ISO_HEIGHT/2
DrawImage tiles(map(tx+x,ty+y)),sx,sy
Next
Next
End Function
Function initmap()
For y=0 To 512
For x=0 To 512
map(x,y)=Rand(0,9)
Next
Next
End Function



