I need help with my HP bar

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Albert
Coder
Posts: 14
Joined: Mon Jul 04, 2016 10:30 am

I need help with my HP bar

Postby Albert » Sat Jul 23, 2016 6:11 am

So I tried to make an HP bar. If I try to update it I must use CLS but I don't want the whole screeen to get cleared.
Is there any way to fix this or clear only a part of the screen?

Code: Select all

SCREEN _NEWIMAGE(800, 600, 32)

white& = _RGB(255, 255, 255)
green& = _RGB(0, 255, 0)

fhp = 100
hp = fhp

DO
    REM Health Bar
    'outter line
    ol_x = 797 - fhp
    LINE (ol_x, 0)-(799, 17), white&, B
    'hp
    hp_x = ol_x + 1
    hp_x1 = hp_x + hp
    LINE (hp_x, 1)-(hp_x1, 16), green&, BF
    _DELAY 1
    hp = hp - 10
    CLS
LOOP UNTIL INKEY$ = CHR$(27) OR hp = 0

User avatar
burger2227
Veteran
Posts: 2144
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Re: I need help with my HP bar

Postby burger2227 » Sat Jul 23, 2016 1:34 pm

Place a black box over the green end area and work it back to the start.
You can replace the white frame each loop or place the green box inside of it instead.
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : http://www.QB64.NET
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0

Albert
Coder
Posts: 14
Joined: Mon Jul 04, 2016 10:30 am

Re: I need help with my HP bar

Postby Albert » Sun Aug 21, 2016 2:32 pm

burger2227 wrote:Place a black box over the green end area and work it back to the start.
You can replace the white frame each loop or place the green box inside of it instead.


sorry because it took me so long to answer but thank you so much!!!


Return to “QBASIC and QB64 Questions & Answers”

Who is online

Users browsing this forum: No registered users and 6 guests

cron