Ok, ok, this is not the whole of what I am planning for my game, but...
This is the source code so far, and what I want to show you is: DBPro can move LOTS of sprites even if your computer is not a very powerful machine.
In the demo, 500 2d pixel spaceships are generated, their stats are rolled and they are drawn on screen, and then they are moved accordingly to their individual movement pattern "algorithm" - yeah, each ship has its own motion pattern.
Check it out:
global fc as integer
type shipdata
seed as integer
speed as integer
w as integer
h as integer
n as integer
c1 as dword
c2 as dword
hp as integer
program as string
psize as byte
weapons as byte
current_gun as byte
current_program as byte
elmt as byte
pdiv as dword
endtype
type weapondata
seed as integer
x as integer
y as integer
n as integer
w as integer
h as integer
c1 as dword
c2 as dword
elmt as byte
speed as integer
angle as integer
amount as byte
damage as integer
range as integer
endtype
dim ship(500) as shipdata
dim gun(500,10) as weapondata
dim element(500,10) as float
sync on
sync rate 60
set display mode 1366,768,32
maximize window
set window layout 0,0,0
do
cls
for n = 1 to 500
randomize timer()
s = rnd(2000000000)
ship(n).seed = s
prepareship(n,1,rnd(4))
resetcpu(n)
if sprite exist(n) = 1 then delete sprite n
sprite n,n*(screen width()/10),screen height(),n
set sprite n,1,1
size sprite n,image width(n)*10,sprite height(n)*10
offset sprite n,sprite width(1)/2,sprite height(1)/2
next
fc = 0
repeat
for n = 1 to 500
displace(n)
exec_prog(n)
move sprite n,ship(n).speed
next
sync
inc fc
until spacekey() = 1
loop
function drawship(n,w,h,c1,c2)
sz = w
dim grid(w,h) as byte
w2 = ceil(w/2)
y = rnd(h-1)+1
v = rnd(1)+1
grid(w2,y) = v
x = 0
left = w2 : right = w2
up = y : down = y
repeat
vx = rnd(1) - rnd(1)
vy = rnd(1) - rnd(1)
x = clamp(x + vx,0,w2-1)
y = clamp(y + vy,1,h)
x1 = w2 - x : x2 = w2 + x
if x1 < left then left = x1
if x2 > right then right = x2
if y < up then up = y
if y > down then down = y
if grid(x1,y) = 0
dec sz,1
v = wrap(v + rnd(1),1,2)
grid(x1,y) = v
grid(x2,y) = v
endif
UNTIL sz = 0
create bitmap n,w,h
lock pixels
for x = 0 to w-1
for y = 0 to h-1
if grid(x+1,y+1) > 0
v = grid(x+1,y+1)
if v = 1 then c = c1
if v = 2 then c = c2
dot x,y,c
endif
next
NEXT
unlock pixels
undim grid(0)
if image exist(n) = 1 then delete image n
get image n,left-1,up-1,right,down,1
delete bitmap n
endfunction
function makeshot(n,w,h,c1,c2)
dim grid(w,h) as byte
w2 = ceil(w/2)
for x = 0 to w2-1 step rnd(w2-1)+1
for y = 1 to h step rnd(1)+1
v = wrap(v+rnd(1),1,2)
grid(w2-x,y) = v
grid(w2+x,y) = v
next
NEXT
left = ceil(w/2)
right= ceil(w/2)
up = ceil(h/2)
down=ceil(h/2)
for x = 1 to w
for y = 1 to h
if grid(x,y) > 0
if x < left then left = x
if x > right then right = x
if y < up then up = y
if y > down then down = y
endif
next
NEXT
create bitmap n,w,h
lock pixels
for x = 0 to w-1
for y = 0 to h-1
if grid(x+1,y+1) > 0
v = grid(x+1,y+1)
if v = 1 then c = c1
if v = 2 then c = c2
dot x,y,c
endif
next
NEXT
unlock pixels
if image exist(n) = 1 then delete image n
get image n,left-1,up-1,right,down,1
delete bitmap n
undim grid(0)
endfunction
function prepareship(n,level,category)
randomize ship(n).seed
if category = 0 : w = 8 : h = 8 : wpns = rnd(2)+1 : endif
if category = 1 : w = 16 : h = 16 : wpns = rnd(2)+2 : endif
if category = 2 : w = 32 : h = 32 : wpns = rnd(3)+2 : endif
if category = 3 : w = 64 : h = 64 : wpns = rnd(4)+3 : endif
if category = 4 : w = 128 : h = 128 : wpns = rnd(6)+4 : endif
ship(n).speed = rnd(4)+1
ship(n).w = w
ship(n).h = h
ship(n).n = n
ship(n).c1 = rgb(rnd(254)+1,rnd(254)+1,rnd(254)+1)
ship(n).pdiv = 30 + rnd(210)
ship(n).c2 = rgb(rnd(254)+1,rnd(254)+1,rnd(254)+1)
ship(n).hp = (rnd(25)+5)*level
ship(n).elmt= rnd(9)
element_grid(n)
ship(n).psize = rnd(8)+2
ship(n).program = program(ship(n).psize)
ship(n).weapons = wpns
drawship(ship(n).n,ship(n).w,ship(n).h,ship(n).c1,ship(n).c2)
for w = 1 to ship(n).weapons : ship(n).seed = rnd(2000000000) : next
for w = 1 to ship(n).weapons
randomize gun(n,w).seed
gun(n,w).n = (ship(n).n * 100) + w
gun(n,w).w = rnd(30)+20
gun(n,w).h = rnd(30)+20
if rnd(99) > 80 then gun(n,w).elmt = rnd(9) else gun(n,w).elmt = ship(n,elmt)
gun(n,w).speed = rnd(gun(n,w).h-1)+1
guncolor(n,w)
gun(n,w).amount= rnd(9)+1
if gun(n,w).amount > 1 then gun(n,w).angle = rnd(359) else gun(n,w).angle = 0
gun(n,w).range = h + rnd(300)
gun(n,w).damage = (rnd(9)+1)*level
makeshot(gun(n,w).n,rnd(15)+5,rnd(15)+5,gun(n,w).c1,gun(n,w).c2)
NEXT
ENDFUNCTION
function guncolor(n,w)
e = gun(n,w).elmt
if e = 0 : c1 = rgb(255,255,255) : c2 = rgb(200,200,200) : endif
if e = 1 : c1 = rgb(1,1,1) : c2 = rgb(0,0,55) : endif
if e = 2 : c1 = rgb(255,0,0) : c2 = rgb(255,127,0) : endif
if e = 3 : c1 = rgb(0,127,255) : c2 = rgb(0,0,255) : endif
if e = 4 : c1 = rgb(255,255,0) : c2 = rgb(200,200,0) : endif
if e = 5 : c1 = rgb(0,200,0) : c2 = rgb(0,127,0) : endif
if e = 6 : c1 = rgb(127,127,0) : c2 = rgb(100,100,0) : endif
if e = 7 : c1 = rgb(127,127,127) : c2 = rgb(100,100,100) : endif
if e = 8 : c1 = rgb(255,0,255) : c2 = rgb(255,100,255) : endif
if e = 9 : c1 = rgb(100,255,255) : c2 = rgb(0,255,255) : endif
gun(n,w).c1 = c1
gun(n,w).c2 = c2
ENDFUNCTION
function program(psize)
p$ = ""
for p = 1 to psize
pt$ = str$(rnd(9))
p$ = p$ + pt$
NEXT
ENDFUNCTION p$
function element_grid(n)
for e = 1 to 10
element(n,e) = (rnd(7)+1)*0.25
if e = ship(n).elmt+1 then element(n,e) = 2
NEXT
ENDFUNCTION
function exec_prog(n)
if fc mod ship(n).pdiv = 0
ship(n).current_program = wrap(ship(n).current_program+1,1,ship(n).psize)
action(n)
ENDIF
ENDFUNCTION
function resetcpu(n)
ship(n).current_program = 1
ENDFUNCTION
function action(n)
a = val(mid$(ship(n).program,ship(n).current_program))
if a = 0 then angle = 0
if a = 1 then angle = 180
if a = 2 then angle = 90
if a = 3 then angle = -90
if a = 4 then angle = 45
if a = 5 then angle = -45
if a = 6 then angle = 15
if a = 7 then angle = -15
if a = 8 then angle = 30
if a = 9 then angle = -30
rotate sprite n,wrapvalue(sprite angle(n)+angle)
ENDFUNCTION
function displace(n)
if sprite x(n) < 0 then sprite n,screen width(),sprite y(n),n
if sprite x(n) > screen width() then sprite n,0,sprite y(n),n
if sprite y(n) < 0 then sprite n,sprite x(n),screen height(),n
if sprite y(n) > screen height() then sprite n,sprite x(n),0,n
ENDFUNCTION
Yeah, I'm not Italian, but there is a lot of spaghetti in my code, because I am too lazy to indent or comment stuff, but I believe it is easy enough to understand, and you guys are smart, so there will be no problem.
[size=+2]Forever and one[/size]