lately ive been having trouble figuring out why my world management is so slow in vb
basically what im trying to accomplish is loading tiles (which is a class) into an array. Ive tried single dimension array, 2 dimensional array, and 3 dimensional array (first 2 for x and y, the 3rd is for multiple maps, or effectively the "Z" layer)
the problem anyway is that its WAY too slow, its so slow its horrible, times like 10 minutes to 20 minutes, and my code isnt that bad, its just setting variables!!!
look at this
the world class
private atoms() as ffatom
public sub AddAtom(name as string,bmpname as string)
redim preserve atoms(ubound(atoms)+1)
set atoms(ubound(atoms))= new ffatom
atoms(ubound(atoms)).create name,ubound(atoms),bmpname
end sub
public function getatom(name as string) as ffatom
dim i as long
for i = 1 to ubound(atoms)
if atoms(i).name = name then
set getatom = atoms(i)
exit for
end if
next
end function
public sub removeatom(name as string)
dim i as long
dim del as long
for i = 1 to ubound(atoms)
if atoms(i).name = name then
del = i
exit for
end if
next
set atoms(del) = nothing
for i = del to ubound(atoms)-1
set atoms(i) = atoms(i+1)
next
set atoms(ubound(Atoms)) = nothing
redim preserve atoms(ubound(Atoms)-1)
end sub
the create function for the atom is something simple like this
the atom class create function
public sub Create(xname as string,xid as long,xbmpname as long)
name = xname
id = xid
bmpname = xbmpname
end sub
everything works, there is nothing wrong with my code thats basically how you handle the resizing of arrays. the only thing i cant figure out is the fact that is just way too slow. i dont know why it is too slow, its just setting a few variables. ive tried loading a 500x500 map in a multidimension array, it was way too slow, i tried loading 500 x 500 as 500*500 = 250000 single dimension array, and GOD it was slower than you will EVER know. and we arent even to the point where we draw!
any help will be greatly appreciated, i hope i can get this world management down.
--Fireking
Owner/Leader
Genetics 3rd Dimension Development
--FirekingOwner/LeaderFiregames Development &Blackdragon Studios