TGC Codebase Backup



PowerBar by Codger

28th Oct 2003 13:36
Summary

A simple Power Bar Function



Description

A flexible way to make a Power Bar use imputs the following

Sprite,Xpos,Ypos,Width,Height,TotalsBars,ActiveBars

This is only for horizontal Bars but could readily be modified to output Verticalbars



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    Rem Project: PowerBar
Rem Created: 10/28/2003 9:45:55 AM

Rem ***** Main Source File *****

PowerBar(1,10,10,100,30,10,5)
PowerBar(2,10,50,100,30,12,3)

wait key


Function PowerBar(SP,x,y,w,h,TotalBars,ActiveBars)

 If bitmap exist (1) then  delete bitmap 1
   Create Bitmap 1, w,h

 ink RGB(128,255,255),0
 Box 0,0,w,h

 BarSize = w/TotalBars
 ink RGB(255,0,128),0
 For i = 1 to ActiveBars
    Box (i-1)*Barsize,1,((i)*Barsize)-1,h
 Next I

 ink RGB(255,255,0),0
 For i = ActiveBars to TotalBars
     Box i*Barsize,1,((i+1)*Barsize)-1,h
 Next I

 Get Image SP, 0,0,w,h
 delete bitmap 1
 Sprite Sp,x,y,SP
EndFunction