setscreen ("graphics:780;450")
setscreen ("offscreenonly")
const PI := 3.14159
function isoTox (xpp, ypp, zpp : int) : int
result ceil (xpp * cos (45 * PI / 180) + zpp * sin (45 * PI / 180))
end isoTox
function isoToy (xpp, ypp, zpp : int) : int
result floor (ypp * cos (30 * PI / 180) - (zpp * cos (45 * PI / 180) - xpp * sin (45 * PI / 180)) * sin (30 * PI / 180))
end isoToy
var tempX : array 1 .. 4 of int
var tempY : array 1 .. 4 of int
procedure drawTile (size, height, c1, c2, c3 : int)
tempX (1) := isoTox (0, height, 0) + maxx div 2
tempY (1) := isoToy (0, height, 0) + maxy div 2
tempX (2) := isoTox (size, height, 0) + maxx div 2
tempY (2) := isoToy (size, height, 0) + maxy div 2
tempX (3) := isoTox (size, height, size) + maxx div 2
tempY (3) := isoToy (size, height, size) + maxy div 2
tempX (4) := isoTox (0, height, size) + maxx div 2
tempY (4) := isoToy (0, height, size) + maxy div 2
drawfillpolygon (tempX, tempY, 4, c1)
drawpolygon (tempX, tempY, 4, c3)
tempX (1) := isoTox (0, height, 0) + maxx div 2
tempY (1) := isoToy (0, height, 0) + maxy div 2
tempX (2) := isoTox (0, 0, 0) + maxx div 2
tempY (2) := isoToy (0, 0, 0) + maxy div 2
tempX (3) := isoTox (0, 0, size) + maxx div 2
tempY (3) := isoToy (0, 0, size) + maxy div 2
tempX (4) := isoTox (0, height, size) + maxx div 2
tempY (4) := isoToy (0, height, size) + maxy div 2
drawfillpolygon (tempX, tempY, 4, c2)
drawpolygon (tempX, tempY, 4, c3)
tempX (4) := isoTox (size, height, size) + maxx div 2
tempY (4) := isoToy (size, height, size) + maxy div 2
tempX (3) := isoTox (size, 0, size) + maxx div 2
tempY (3) := isoToy (size, 0, size) + maxy div 2
tempX (2) := isoTox (0, 0, size) + maxx div 2
tempY (2) := isoToy (0, 0, size) + maxy div 2
tempX (1) := isoTox (0, height, size) + maxx div 2
tempY (1) := isoToy (0, height, size) + maxy div 2
drawfillpolygon (tempX, tempY, 4, c3)
drawpolygon (tempX, tempY, 4, c3)
end drawTile
locatexy (maxx div 2 - 20, maxy div 2)
put "LOADING..."
View.Update
cls
var bw, bh, w : int
var h : array 1 .. * of int := init (5, 13, 21)
bw := 10
bh := 20
drawTile (bw, bh, 29, 28, 27)
var box := Pic.New (isoTox (0, bh, 0) + maxx div 2, isoToy (bw, bh, 0) + maxy div 2, isoTox (bw, bh, bw) + maxx div 2, isoToy (0, 0, bw) + maxy div 2)
cls
var tile : array 1 .. 5 of int
w := 30
drawTile (w, h (1), 43, 42, 41)
tile (1) := Pic.New (isoTox (0, h (1), 0) + maxx div 2, isoToy (w, h (1), 0) + maxy div 2, isoTox (w, h (1), w) + maxx div 2, isoToy (0, 0, w) + maxy div 2)
cls
drawTile (w, h (2), 53, 54, 55)
tile (2) := Pic.New (isoTox (0, h (2), 0) + maxx div 2, isoToy (w, h (2), 0) + maxy div 2, isoTox (w, h (2), w) + maxx div 2, isoToy (0, 0, w) + maxy div 2)
cls
drawTile (w, h (3), 45, 10, 2)
tile (3) := Pic.New (isoTox (0, h (3), 0) + maxx div 2, isoToy (w, h (3), 0) + maxy div 2, isoTox (w, h (3), w) + maxx div 2, isoToy (0, 0, w) + maxy div 2)
cls
const worldSize := 15
var tx : int := worldSize
var tz : int := 0
var tnz : int := 1
var tnx : int := worldSize
var tn : int := 1
var x : array 1 .. worldSize ** 2 of int
var z : array 1 .. worldSize ** 2 of int
var i : int := 1
loop
exit when tx = 1 and tz = worldSize
if tz < tnz then
tz += 1
end if
x (i) := tx
z (i) := tz
if tz = tnz then
if tx not= 1 and tnx not= 1 then
tnx -= 1
tx := tnx
else
tx := 1
end if
tz := 0
if tnz < worldSize then
tnz += 1
else
tz := tn
tn += 1
end if
else
tx += 1
end if
i += 1
end loop
i := 0
var randNum : int
const T2odds := 20
const T3odds := 5
var randMapTiles : array 1 .. worldSize ** 2 of int
procedure randMap
for cols : 1 .. worldSize
for rows : 1 .. worldSize
i += 1
if x (i) = 1 or z (i) = 1 or x (i) = worldSize or z (i) = worldSize then
randMapTiles (i) := 2
elsif x (i) = 2 or z (i) = 2 or x (i) = worldSize - 1 or z (i) = worldSize - 1 then
randMapTiles (i) := 1
else
randint (randNum, 1, 100)
if randNum < T3odds then
randMapTiles (i) := 3
elsif randNum > T3odds and randNum < T3odds + T2odds then
randMapTiles (i) := 2
else
randMapTiles (i) := 1
end if
end if
end for
end for
end randMap
randMap
const worldCX := 30
const worldCY := 190
var d : int := 1
var cd : int := 1
var depth : array 1 .. worldSize * 2 of int
var tnl : int
var direction : int
var draw : int := 0
for : 1 .. worldSize * 2 - 1
tn := 1
tnl := 1
i := 0
d := 1
direction := 1
for col : 1 .. worldSize
for row : 1 .. worldSize
if tn = worldSize then
direction := -1
end if
i += 1
if d = worldSize * 2 - (cd) then
draw := 1
end if
if draw = 1 then
Pic.Draw (tile (randMapTiles (i)), isoTox (x (i) * w, 0, z (i) * w) + worldCX, isoToy (x (i) * w, 0, z (i) * w) + worldCY, picMerge)
end if
if d = worldSize * 2 - (cd) - 1 then
cls
end if
if tn = tnl then
tn := 0
tnl += direction
if d = worldSize * 2 - 1 then
depth (cd) := Pic.New (0, 0, maxx, maxy)
end if
d += 1
end if
tn += 1
end for
end for
cd += 1
draw := 0
end for
cls
var bx, bz : int := w * 2
var bSpd : int := 6
var boxMove : array char of boolean
var boxDepth : int := worldSize - 1
var boxTX, boxTZ : int
function getTileNum (fx, fz : int) : int
i := 0
for col : 1 .. worldSize
for row : 1 .. worldSize
i += 1
exit when col = fx and row = fz
end for
end for
result i
end getTileNum
procedure moveUp
if randMapTiles (getTileNum (round (((bx + bSpd) - w / 2) / w), boxTZ)) = 1 then
bx += bSpd
end if
end moveUp
loop
Input.KeyDown (boxMove)
if boxMove (KEY_UP_ARROW) then
moveUp
elsif boxMove (KEY_DOWN_ARROW) then
bx += -bSpd
elsif boxMove (KEY_RIGHT_ARROW) then
bz += bSpd
elsif boxMove (KEY_LEFT_ARROW) then
bz += -bSpd
end if
boxTX := round ((bx - w / 2) / w)
boxTZ := round (((bz + 10) - w / 2) / w)
locate (1, 1)
boxDepth := boxTX + (worldSize - boxTZ - 1)
Pic.Draw (depth (worldSize * 2 - 1), 0, 0, picCopy)
Pic.Draw (box, isoTox (bx, h (2), bz) + worldCX, isoToy (bx, h (2), bz) + worldCY, picMerge)
Pic.Draw (depth (boxDepth), 0, 0, picMerge)
put boxTX, ", ", boxTZ
put randMapTiles (getTileNum (boxTX, boxTZ))
View.Update
cls
end loop
|