View.Set ("graphics:max,max") var verdana := Font.New ("verdana:10:bold") include "classes.t" var terrainTypes : array 1 .. 8 of int := init (42, 48, 2, 66, 15, 53, 55, 91) var infantry : array 1 .. 100 of pointer to Infantry var tank : array 1 .. 100 of pointer to Tank var artillery : array 1 .. 100 of pointer to Artillery var map : array 1 .. 100, 1 .. 100 of int var unitToAdd, infCount, tankCount, artyCount : int := 1 var scrollx, scrolly, mx, my, mb : int var mapLoadFlag : boolean := false var tS : int := 50 scrollx := 0 scrolly := 0 % Initialize the Unit Classes -> Josh for i : 1 .. 100 new Infantry, infantry (i) new Tank, tank (i) new Artillery, artillery (i) end for proc drawMap % -> Josh for i : 1 .. 40 for j : 1 .. 40 %drawfillbox (100 + i * tS, 100 + j * tS, 100 + i * tS + tS, 100 + j * tS + tS, terrainTypes (map (i, j))) drawfillbox (i * tS - 50 + (scrollx * tS), j * tS - 50 + (scrolly * tS), i * tS + tS - tS + (scrollx * tS)-5, j * tS + tS - tS + (scrolly * tS)-5, terrainTypes (map (i, j))) % SCALE DOWN FOR ROOM FOR THE INTERFACE end for end for end drawMap proc GUI drawfillbox (1000 - (scrollx * tS), 0, maxx, maxy, grey) end GUI function findSpaceInString (word : string) : int % -> Josh for i : 1 .. length (word) if word (i) = " " then result i end if end for result 0 end findSpaceInString proc loadMap var filename : string := "" var input : int var Char : string (1) var character : string var temp, temp2, unitX, unitY, side : int := 0 locate (1, 1) put "Enter a name: " .. get filename open : input, "maps\\" + filename + ".map", get if Error.Last = eNoError then for i : 1 .. 40 for j : 1 .. 40 get : input, Char if strintok (Char) = false and Char not= " " then put "Data file corrupted! Tile (", i, ",", j, ") returned to Default Type" elsif strintok (Char) then map (i, j) := strint (Char) end if end for end for drawMap loop exit when eof (input) get : input, character : * if length (character) > 6 then % Evil little region of code, took me 20min! side := strint (character (2)) temp := findSpaceInString (character) temp2 := temp + findSpaceInString (character (temp + 1 .. *)) unitX := strint (character (temp + 1 .. temp2 - 1)) unitY := strint (character (temp2 + 1 .. *)) end if if character (1) = "i" then infantry (infCount) -> load (unitX, unitY, side) infCount += 1 elsif character (1) = "t" then tank (tankCount) -> load (unitX, unitY, side) tankCount += 1 elsif character (1) = "a" then artillery (artyCount) -> load (unitX, unitY, side) artyCount += 1 end if end loop close : input else locate (1, 1) put "File not Found." end if end loadMap loop if mapLoadFlag = false then loadMap mapLoadFlag := true end if mousewhere (mx, my, mb) if mx >= maxx - tS and mb = 1 then if scrollx * -1 < 20 then scrollx -= 1 end if elsif mx < 0 + tS and mb = 1 then if scrollx < 0 then scrollx += 1 end if end if if my >= maxy - tS and mb = 1 then if scrolly * -1 < 24 then scrolly -= 1 end if elsif my < 0 + tS and mb = 1 then if scrolly < 0 then scrolly += 1 end if end if drawMap GUI View.Update %cls delay (10) locate (2, 1) put scrollx, " ", scrolly .. locate (2, 1) put mx, " ", my .. end loop