REM ***********************************************
REM Title: Energy Meter 2
REM Author: Phaelax
REM Downloaded from: http://dbcc.zimnox.com/
REM ***********************************************
 
REM ********************************
REM * Title: Gradient Energy Meter *
REM * Author: Phaelax              *
REM * Date: Nov 22, 2009           *
REM ********************************
 
sync on
sync rate 60
 
Type Bar
	targetValue as float
	currentValue as float
EndType
 
barCount = 16
dim bars(barCount) as Bar
 
for i = 1 to barCount
	bars(i).targetValue = rnd(100)/100.0   
	bars(i).currentValue = bars(i).targetValue
next i
 
width = 12
height = 100
 
timestamp = timer()
 
do
	cls
 
 
	MX = mousex()
	MY = mousey()
 
	for i = 0 to barCount-1
		healthBar(MX+i*13, MY, width, height, bars(i+1).currentValue)
 
		if bars(i+1).currentValue <= bars(i+1).targetValue
			bars(i+1).currentValue = bars(i+1).currentValue + 0.025
			if bars(i+1).currentValue > bars(i+1).targetValue 
				bars(i+1).currentValue = bars(i+1).targetValue
				bars(i+1).targetValue = rnd(100)/100.0
			endif
		else
			if bars(i+1).currentValue > bars(i+1).targetValue
				bars(i+1).currentValue = bars(i+1).currentValue - 0.025
				if bars(i+1).currentValue < bars(i+1).targetValue 
					bars(i+1).currentValue = bars(i+1).targetValue
					bars(i+1).targetValue = rnd(100)/100.0
				endif
			endif
		endif
	next i   
 
	sync
loop
 
 
 
 
rem left-bottom, left-top, right-bottom, right-top
function healthBar(x, y, width, height, P#)
	rem gradient bar
	seg = height / 3
 
	box x, y-seg, x+width, y, rgb(0,255,0),rgb(255,255,0),rgb(0,255,0),rgb(255,255,0)
	box x, y-seg-seg, x+width, y-seg, rgb(255,255,0),rgb(255,128,0),rgb(255,255,0),rgb(255,128,0)
	box x, y-height, x+width, y-seg-seg, rgb(255,128,0),rgb(255,0,0),rgb(255,128,0),rgb(255,0,0)
 
	rem segment lines
	C = 0x22000000
	r = height / 5
	for i = 1 to r
		yy = y - i*5
		box x, yy, x+width, yy+1, C,C,C,C
	next i
 
	rem empty bit
	ink rgb(48,48,48),0
	box x, y-height, x+width+1, y-height*P#
 
	rem highlight
	c1 = 0xBBFFFFFF
	c2 = 0x00FFFFFF   
	box x, y-height*p#, x+width*0.6, y, c1,c1,c2,c2
endfunction