I can't think offhand of any tidy pointer stuff I made up recently.
The latest offering I think was a million boxes via ptr.
Badidea.
I think you can just utilise type without the hype in 90% of cases.
A million boxes:
Press any key for another million.
toggles empty and filled.
Code: Select all
dim shared as long lim=1000000
dim shared as long copy 'for the graphical destructor
copy=lim
dim as ulong black=rgb(0,0,0),white=rgb(255,255,255)
type box
as ulong ptr p =new ulong[6] 'all the spatial information
declare sub draw() 'drawing method
declare destructor 'Goodbye, thanks for the memory
end type
sub box.draw()
dim as ulong colour=rgba(cast(ubyte ptr,@p[4])[2],cast(ubyte ptr,@p[4])[1],cast(ubyte ptr,@p[4])[0],cast(ubyte ptr,@p[4])[3])
if p[5] then line(p[0],p[1])-(p[0]+p[2],p[1]+p[3]),colour,bf else _
line(p[0],p[1])-(p[0]+p[2],p[1]+p[3]),colour,b
end sub
destructor box
lim-=1
#define map(a,b,x,c,d) ((d)-(c))*((x)-(a))/((b)-(a))+(c)
var x=map(copy,0,lim,100,700)
var y=map(100,700,x,100,500)
circle(x,y),20,rgb(200,0,0),,,,f
circle(x,600-y),20,rgb(200,0,0),,,,f
delete [] p
end destructor
screen 19,32,,64
#define range(f,l) Int(Rnd*((l+1)-(f))+(f))
dim as byte q=1
dim as box b(1 to lim)
do
cls
q=-q
for n as long=1 to lim
with b(n)
.p[0]=range(100,700) 'x
.p[1]=range(100,500) 'y
.p[2]=rnd*20 'width
.p[3]=rnd*20 'height
.p[4]=rnd*range(black,white)
.p[5]=1+q 'filler
.draw
end with
next n
sleep
loop until inkey=chr(27)