Or what I call text "poppers"! (cause I didn't know what else to call the array)
Ever played a game where every hit you land (or take) shows the amount of damage pop up over the character's head? Yeah, that's what this snippet does.
Rem Project: Dark Basic Pro Project
Rem Created: Saturday, September 22, 2012
Rem Author: Phaelax
Rem ***** Main Source File *****
Type Popper
x as integer
y as integer
msg as string
alpha as integer
timestamp as dword
EndType
dim poppers(0) as Popper
sync on
`sync rate 60
do
box 0, 0, 640, 480, rgb(255,0,0), rgb(255,255,0), rgb(0,255,0), rgb(0,0,255)
if mouseclick() = 1 and mFlag = 0
mFlag = 1
addPopper(mousex(), mousey(), str$(rnd(1200)))
endif
if mouseclick() = 0 then mFlag = 0
doPoppers()
ink 0,0
set cursor 0,0
print screen fps()
sync
loop
function doPoppers()
t = timer()
for i = 1 to array count(poppers())
ink argb(poppers(i).alpha,255,255,0), 0
center text poppers(i).x, poppers(i).y, poppers(i).msg
if poppers(i).timestamp+10 < t
dec poppers(i).alpha, 8
dec poppers(i).y, 2
poppers(i).timestamp = timer()
if poppers(i).alpha <= 0 then removePopper() : i = i - 1
endif
next i
endfunction
function removePopper()
remove from queue poppers()
endfunction
function addPopper(x, y, msg$)
add to queue poppers()
poppers().x = x
poppers().y = y
poppers().msg = msg$
poppers().alpha = 255
poppers().timestamp = timer()
endfunction
function argb(a, r, g, b)
c as dword
c = (a*16777216)+(r*65536)+(g*256)+b
endfunction c
"You're not going crazy. You're going sane in a crazy world!" ~Tick