View.Set ("offscreenonly, graphics:640;480")
Text.ColourBack (23)
Mouse.ButtonChoose ("multibutton")
var swordmanx, swordmany, swordmanhp, swgotox, swgotoy, swmode, arrowx, arrowy, argotox, argotoy : flexible array 1 .. 1 of int
var eneswx, eneswy, eneswhp, eneswmode : flexible array 1 .. 0 of int
var builderx, buildery, builderhp, bdgotox, bdgotoy, brgotox, brgotoy : flexible array 1 .. 1 of int
var barracksx, barracksy, bdbuilding, swbuilding : flexible array 1 .. 0 of int
var swselected, bdselected, brselected, brbuildsl, brbuild, bdbuild, swbuild, arfired : flexible array 1 .. 0 of boolean
var x, y, button : int
var boxx, boxy, boxx2, boxy2 : int := 0
var boxcreate : boolean := false
var eneswdelete, timer : int := 0
%SWORDMAN MODE IS AS FOLLOWS - 1 = SWORD, 2 = BOW
new bdselected, upper (bdselected) + 1
new brbuildsl, upper (brbuildsl) + 1
new brbuild, upper (brbuild) + 1
new swselected, upper (swselected) + 1
new arfired, upper (arfired) + 1
swordmanx (1) := 150
swordmany (1) := 220
swordmanhp (1) := 150
arfired (1) := false
swmode (1) := 2
arrowx (1) := swordmanx (1)
arrowy (1) := swordmany (1)
argotox (1) := swordmanx (1)
argotoy (1) := swordmany (1)
swgotox (1) := swordmanx (1)
swgotoy (1) := swordmany (1)
swselected (1) := false
brgotox (1) := 0
brgotoy (1) := 0
brbuildsl (1) := false
brbuild (1) := false
builderx (1) := 100
buildery (1) := 200
builderhp (1) := 50
bdselected (1) := false
bdgotox (1) := builderx (1)
bdgotoy (1) := buildery (1)
loop
for ctrloop : 1 .. 20
mousewhere (x, y, button)
View.Update
delay (20)
cls
drawfillbox (0, 0, maxx, maxy, 27)
%BOTTOM STATUS BAR
drawfillbox (0, 0, maxx, 100, 23)
%TOP STATUS BAR
drawfillbox (0, maxy, maxx, maxy - 20, 23)
put upper (swordmanx)
put upper (eneswx)
%DRAWING THE BARRACKS
for i : 1 .. upper (barracksx)
drawfillbox (barracksx (i) - 40, barracksy (i) - 40, barracksx (i) + 40, barracksy (i) + 40, 9)
end for
%DRAWING THE SWORDSMAN
for i : 1 .. upper (swordmanx)
drawfilloval (swordmanx (i), swordmany (i), 4, 4, 1)
if swselected (i) then
drawfillbox (swordmanx (i) - 4, swordmany (i) + 8, swordmanx (i) + 4, swordmany (i) + 9, 12)
drawfillbox (swordmanx (i) - 4, swordmany (i) + 8, swordmanx (i) - 4 + swordmanhp (i) div 18, swordmany (i) + 9, 10)
drawoval (swordmanx (i), swordmany (i), 5, 5, 14)
end if
end for
%DRAWING THE BUILDER
for i : 1 .. upper (builderx)
drawfilloval (builderx (i), buildery (i), 4, 4, 9)
if bdselected (i) = true then
drawfillbox (builderx (i) - 4, buildery (i) + 8, builderx (i) + 4, buildery (i) + 9, 12)
drawfillbox (builderx (i) - 4, buildery (i) + 8, builderx (i) - 4 + builderhp (i) div 6, buildery (i) + 9, 10)
drawoval (builderx (i), buildery (i), 5, 5, 14)
end if
end for
%DRAWING THE ENEMY
for i : 1 .. upper (eneswx)
drawfilloval (eneswx (i), eneswy (i), 4, 4, 12)
end for
%PROPERTIES OF BUILDER
for i : 1 .. upper (builderx)
if button = 1 and boxcreate = false then
bdselected (i) := false
end if
if x > builderx (i) - 4 and x < builderx (i) + 4 and y > buildery (i) - 4 and y < buildery (i) + 4 and button = 1 then
bdselected (i) := true
end if
if bdselected (i) = true and button = 100 then
bdgotox (i) := x
bdgotoy (i) := y
brbuild (i) := false
end if
%BUILDER MOVEMENT
for pp : 1 .. 2
if brbuild (i) = false then
if bdgotox (i) > builderx (i) and whatdotcolour (builderx (i) + 6, buildery (i)) = 27 then
builderx (i) += 1
elsif bdgotox (i) < builderx (i) and whatdotcolour (builderx (i) - 6, buildery (i)) = 27 then
builderx (i) -= 1
end if
if bdgotoy (i) > buildery (i) and whatdotcolour (builderx (i), buildery (i) + 6) = 27 then
buildery (i) += 1
elsif bdgotoy (i) < buildery (i) and whatdotcolour (builderx (i), buildery (i) - 6) = 27 then
buildery (i) -= 1
end if
end if
end for
end for
if button not= 1 then
boxx := x
boxy := y
boxcreate := false
end if
%ENEMY IS CREATED
if timer > 4 and upper (eneswx) < 20 then
new eneswx, upper (eneswx) + 1
new eneswy, upper (eneswy) + 1
new eneswhp, upper (eneswhp) + 1
new eneswmode, upper (eneswmode) + 1
randint (eneswx (upper (eneswx)), 10, 50)
randint (eneswy (upper (eneswy)), 110, maxy - 40)
eneswhp (upper (eneswhp)) := 150
eneswmode (upper (eneswmode)) := 1
end if
%PROPERTIES OF ENEMY SWORDSMAN
%ENEMY IS DELETED
for i : 1 .. upper (eneswx) - 1
%ENEMY IS DELETED HERE ALSO
if eneswhp (i) <= 0 then
eneswdelete := i
end if
if eneswdelete > 0 then
for pp : eneswdelete + 1 .. upper (eneswx) - 1
eneswx (pp - 1) := eneswx (pp)
eneswy (pp - 1) := eneswy (pp)
eneswhp (pp - 1) := eneswhp (pp)
eneswmode (pp - 1) := eneswmode (pp)
end for
eneswdelete := 0
new eneswx, upper (eneswx) - 1
new eneswy, upper (eneswy) - 1
new eneswhp, upper (eneswhp) - 1
new eneswmode, upper (eneswmode) - 1
end if
for pp : 1 .. upper (swordmanx) - 1
if ctrloop >= 5 then
if swordmanx (pp) > eneswx (i) and whatdotcolour (eneswx (i) + 6, eneswy (i)) = 27 then
eneswx (i) += 1
elsif swordmanx (pp) < eneswx (i) and whatdotcolour (eneswx (i) - 6, eneswy (i)) = 27 then
eneswx (i) -= 1
end if
if swordmany (pp) > eneswy (i) and whatdotcolour (eneswx (i), eneswy (i) + 6) = 27 then
eneswy (i) += 1
elsif swordmany (pp) < eneswy (i) and whatdotcolour (eneswx (i), eneswy (i) - 6) = 27 then
eneswy (i) -= 1
end if
end if
end for
end for
%PROPERTIES OF SWORDSMAN
for i : 1 .. upper (swordmanx)
if button = 1 then
swselected (i) := false
end if
if x > swordmanx (i) - 4 and x < swordmanx (i) + 4 and y > swordmany (i) - 4 and y < swordmany (i) + 4 and button = 1 then
swselected (i) := true
end if
if swselected (i) and button = 100 then
swgotox (i) := x
swgotoy (i) := y
end if
if arfired (i) = false and swmode (i) = 2 then
arrowx (i) := swordmanx (i)
arrowy (i) := swordmany (i)
argotox (i) := swordmanx (i)
argotoy (i) := swordmany (i)
end if
if swmode (i) = 2 and arfired (i) = true then
for pp : 1 .. 5
if argotox (i) > arrowx (i) then
arrowx (i) += 1
elsif argotox (i) < arrowx (i) then
arrowx (i) -= 1
end if
if argotoy (i) > arrowy (i) then
arrowy (i) += 1
elsif argotoy (i) < arrowy (i) then
arrowy (i) -= 1
end if
end for
drawline (arrowx (i), arrowy (i), arrowx (i) + 4, arrowy (i) + 4, 7)
end if
for pp : 1 .. upper (eneswx)
if eneswx (pp) > swordmanx (i) - 100 and eneswx (pp) < swordmanx (i) + 100 and eneswy (pp) > swordmany (i) - 100 and eneswy (pp) < swordmany (i) + 100 and arfired (i) = false and
ctrloop = 1 then
arfired (i) := true
argotox (i) := eneswx (pp)
argotoy (i) := eneswy (pp)
end if
if arfired (i) = true and arrowx (i) = eneswx (pp) and arrowy (i) = eneswy (pp) then
eneswhp (pp) -= 30
end if
if arrowx (i) = argotox (i) and arrowy (i) = argotoy (i) and arfired (i) = true then
arfired (i) := false
arrowx (i) := swordmanx (i)
arrowy (i) := swordmany (i)
argotox (i) := swordmanx (i)
argotoy (i) := swordmany (i)
end if
end for
for pp : 1 .. 2
if swgotox (i) > swordmanx (i) and whatdotcolour (swordmanx (i) + 6, swordmany (i)) = 27 then
swordmanx (i) += 1
elsif swgotox (i) < swordmanx (i) and whatdotcolour (swordmanx (i) - 6, swordmany (i)) = 27 then
swordmanx (i) -= 1
end if
if swgotoy (i) > swordmany (i) and whatdotcolour (swordmanx (i), swordmany (i) + 6) = 27 then
swordmany (i) += 1
elsif swgotoy (i) < swordmany (i) and whatdotcolour (swordmanx (i), swordmany (i) - 6) = 27 then
swordmany (i) -= 1
end if
end for
end for
%PROPERTIES OF BARRACKS
for i : 1 .. upper (barracksx)
if button = 1 and y > 100 and y < maxy - 20 then
brselected (i) := false
end if
if x > barracksx (i) - 40 and x < barracksx (i) + 40 and y > barracksy (i) - 40 and y < barracksy (i) + 40 and button = 1 then
brselected (i) := true
end if
if brselected (i) then
drawbox (barracksx (i) - 45, barracksy (i) - 45, barracksx (i) + 45, barracksy (i) + 45, 14)
end if
end for
%%%%% BOX CREATION %%%%%
if button = 1 then
if boxx not= boxx2 or boxy not= boxy2 then
boxcreate := true
end if
boxx2 := x
boxy2 := y
drawbox (boxx, boxy, boxx2, boxy2, 12)
%BOX FOR BUILDER
for i : 1 .. upper (builderx)
%BOX SHAPE 1
if boxx < boxx2 and boxy < boxy2 then
if boxx < builderx (i) - 2 and boxx2 > builderx (i) + 2 and boxy < buildery (i) - 2 and boxy2 > buildery (i) + 2 then
bdselected (i) := true
elsif boxcreate = true then
bdselected (i) := false
end if
end if
%BOX SHAPE 2
if boxx > boxx2 and boxy < boxy2 then
if boxx > builderx (i) - 2 and boxx2 < builderx (i) + 2 and boxy < buildery (i) - 2 and boxy2 > buildery (i) + 2 then
bdselected (i) := true
elsif boxcreate = true then
bdselected (i) := false
end if
end if
%BOX SHAPE 3
if boxx > boxx2 and boxy > boxy2 then
if boxx > builderx (i) - 2 and boxx2 < builderx (i) + 2 and boxy > buildery (i) - 2 and boxy2 < buildery (i) + 2 then
bdselected (i) := true
elsif boxcreate = true then
bdselected (i) := false
end if
end if
%BOX SHAPE 4
if boxx < boxx2 and boxy > boxy2 then
if boxx < builderx (i) - 2 and boxx2 > builderx (i) + 2 and boxy > buildery (i) - 2 and boxy2 < buildery (i) + 2 then
bdselected (i) := true
elsif boxcreate = true then
bdselected (i) := false
end if
end if
end for
%BOX FOR SWORDSMAN
for i : 1 .. upper (swordmanx)
%BOX SHAPE 1
if boxx < boxx2 and boxy < boxy2 then
if boxx < swordmanx (i) - 2 and boxx2 > swordmanx (i) + 2 and boxy < swordmany (i) - 2 and boxy2 > swordmany (i) + 2 then
swselected (i) := true
elsif boxcreate = true then
swselected (i) := false
end if
end if
%BOX SHAPE 2
if boxx > boxx2 and boxy < boxy2 then
if boxx > swordmanx (i) - 2 and boxx2 < swordmanx (i) + 2 and boxy < swordmany (i) - 2 and boxy2 > swordmany (i) + 2 then
swselected (i) := true
elsif boxcreate = true then
swselected (i) := false
end if
end if
%BOX SHAPE 3
if boxx > boxx2 and boxy > boxy2 then
if boxx > swordmanx (i) - 2 and boxx2 < swordmanx (i) + 2 and boxy > swordmany (i) - 2 and boxy2 < swordmany (i) + 2 then
swselected (i) := true
elsif boxcreate = true then
swselected (i) := false
end if
end if
%BOX SHAPE 4
if boxx < boxx2 and boxy > boxy2 then
if boxx < swordmanx (i) - 2 and boxx2 > swordmanx (i) + 2 and boxy > swordmany (i) - 2 and boxy2 < swordmany (i) + 2 then
swselected (i) := true
elsif boxcreate = true then
swselected (i) := false
end if
end if
end for
end if
%%%% END OF BOX CREATION %%%%
for i : 1 .. upper (builderx)
mousewhere (x, y, button)
if bdselected (i) = true then
Text.Colour (0)
Text.ColourBack (23)
locate (maxrow - 5, 2)
put "Build Barracks"
if x > 6 and x < 121 and y > 81 and y < 94 and button = 1 then
brbuildsl (i) := true
end if
end if
if brbuildsl (i) = true then
if button = 100 and whatdotcolour (x - 50, y - 50) = 27 and whatdotcolour (x + 50, y + 80) = 27 and whatdotcolour (x + 50, y - 50) = 27 and whatdotcolour (x - 50, y + 80) = 27
and whatdotcolour (x - 50, y) = 27 and whatdotcolour (x + 50, y) = 27 and whatdotcolour (x, y + 80) = 27 and whatdotcolour (x, y - 50) = 27 then
brgotox (i) := x - 40
brgotoy (i) := y - 40
bdgotox (i) := x - 40
bdgotoy (i) := y - 40
brbuildsl (i) := false
brbuild (i) := true
end if
drawfillbox (x - 50, y - 50, x + 50, y + 80, 12)
drawfillbox (x - 40, y - 40, x + 40, y + 40, 9)
end if
if brbuild (i) = true then
for pp : 1 .. 2
if brgotox (i) > builderx (i) and whatdotcolour (builderx (i) + 10, buildery (i)) = 27 then
builderx (i) += 1
elsif brgotox (i) < builderx (i) and whatdotcolour (builderx (i) - 10, buildery (i)) = 27 then
builderx (i) -= 1
end if
if brgotoy (i) > buildery (i) and whatdotcolour (builderx (i), buildery (i) + 10) = 27 then
buildery (i) += 1
elsif brgotoy (i) < buildery (i) and whatdotcolour (builderx (i), buildery (i) - 10) = 27 then
buildery (i) -= 1
end if
end for
end if
if builderx (i) = brgotox (i) and buildery (i) = brgotoy (i) and brbuild (i) = true then
new barracksx, upper (barracksx) + 1
new barracksy, upper (barracksy) + 1
new brselected, upper (brselected) + 1
new bdbuilding, upper (bdbuilding) + 1
new bdbuild, upper (bdbuild) + 1
new swbuilding, upper (swbuilding) + 1
new swbuild, upper (swbuild) + 1
barracksx (upper (barracksx)) := brgotox (i) + 45
barracksy (upper (barracksy)) := brgotoy (i) + 45
brselected (upper (brselected)) := false
bdbuild (upper (bdbuild)) := false
swbuild (upper (swbuild)) := false
brbuild (i) := false
end if
end for
for i : 1 .. upper (barracksx)
mousewhere (x, y, button)
if brselected (i) then
locate (maxrow - 5, 2)
put "Hire Builder"
locate (maxrow - 4, 2)
put "Hire Elvish Warrior"
if bdbuild (i) then
locate (maxrow - 3, 2)
put bdbuilding (i)
end if
if swbuild (i) then
locate (maxrow - 3, 2)
put swbuilding (i)
end if
if x > 6 and x < 105 and y > 80 and y < 96 and button = 1 then
bdbuilding (i) := 0
bdbuild (i) := true
end if
if x > 6 and x < 161 and y > 65 and y < 78 and button = 1 then
swbuilding (i) := 0
swbuild (i) := true
end if
end if
if swbuild (i) then
if ctrloop > 13 then
swbuilding (i) += 1
end if
if swbuilding (i) >= 100 then
swbuild (i) := false
new swordmanx, upper (swordmanx) + 1
new swordmany, upper (swordmany) + 1
new swordmanhp, upper (swordmanhp) + 1
new swgotox, upper (swgotox) + 1
new swgotoy, upper (swgotoy) + 1
new swselected, upper (swselected) + 1
new arrowx, upper (arrowx) + 1
new arrowy, upper (arrowy) + 1
new argotox, upper (argotox) + 1
new argotoy, upper (argotoy) + 1
new swmode, upper (swmode) + 1
new arfired, upper (arfired) + 1
swordmanx (upper (swordmanx)) := barracksx (i)
swordmany (upper (swordmany)) := barracksy (i) + 50
swordmanhp (upper (swordmanhp)) := 150
swgotox (upper (swgotox)) := swordmanx (upper (swordmanx))
swgotoy (upper (swgotoy)) := swordmany (upper (swordmany))
swselected (upper (swselected)) := false
arrowx (upper (arrowx)) := swordmanx (upper (swordmanx))
arrowy (upper (arrowy)) := swordmany (upper (swordmany))
argotox (upper (argotox)) := swordmanx (upper (swordmanx))
argotoy (upper (argotoy)) := swordmanx (upper (swordmanx))
swmode (upper (swmode)) := 2
arfired (upper (arfired)) := false
end if
end if
if bdbuild (i) then
if ctrloop > 7 then
bdbuilding (i) += 1
end if
if bdbuilding (i) >= 100 then
bdbuild (i) := false
new builderx, upper (builderx) + 1
new buildery, upper (buildery) + 1
new builderhp, upper (builderhp) + 1
new bdgotox, upper (bdgotox) + 1
new bdgotoy, upper (bdgotoy) + 1
new brgotox, upper (brgotox) + 1
new brgotoy, upper (brgotoy) + 1
new bdselected, upper (bdselected) + 1
new brbuildsl, upper (brbuildsl) + 1
new brbuild, upper (brbuild) + 1
builderx (upper (builderx)) := barracksx (i) - 20
buildery (upper (buildery)) := barracksy (i) - 55
builderhp (upper (builderhp)) := 50
bdgotox (upper (bdgotox)) := builderx (upper (builderx))
bdgotoy (upper (bdgotoy)) := buildery (upper (buildery))
brgotox (upper (brgotox)) := 0
brgotoy (upper (brgotoy)) := 0
bdselected (upper (bdselected)) := false
brbuildsl (upper (brbuildsl)) := false
brbuild (upper (brbuild)) := false
end if
end if
end for
timer += 1
end for
end loop
|