Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Problem with IF Statements after upgrade

Author
Message
The Guardian
16
Years of Service
User Offline
Joined: 13th Sep 2009
Location:
Posted: 2nd Apr 2010 08:30
Okay, here's my dilemma...

When I discovered my DB Pro wasn't working with Windows 7, I upgraded it, and it seemed to work okay when working with IF statements. However, I also upgraded it to 7.4 shortly afterward.

Now, my IF Statements don't seem to work. I was watching a tutorial on Health Bars by the people who made DarkPRINCIPLES, and my code wont decrease or increase like it's supposed to. Below I have my code and a link to said tutorial. I'd appreciate any help that can be provided to me.



Health Bar Tutorial
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 2nd Apr 2010 13:45
Some slight adjustments to try, not sure if these will work but its worth a go...



Things that pop, are that you haven't used SYNC ON, you sync'd the start of your code instead, so changed that. I always specify the value when INCrementing or DECrementing, so added a ,1. I also set inkey$() to a variable, and made it capitalize, so just check the capital, like "W", then it won't care if caps lock is on. I added a health text to show the actual value - if that is there, and there's still no BOX, then it must be an issue with the box drawing. Unlikely, but it should serve as a good test.

The main one I think would be the SYNC ON thing though.


Health, Ammo, and bacon and eggs!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd Apr 2010 14:51 Edited at: 2nd Apr 2010 14:53
The problem is that you need "sync on" not "sync" at the start of your code - and cls at the start of the loop. Then everything is fine.



Without the cls the screen is not being cleared so the original bar still shows - all you are doing otherwise is overwriting part of the white with white so you don't see the change.

Without the sync on you get an annoying flicker.

Edit: The cls isn't needed if you have 3D objects in the scene as the screen is automatically cleared each sync in that case.
The Guardian
16
Years of Service
User Offline
Joined: 13th Sep 2009
Location:
Posted: 2nd Apr 2010 19:23 Edited at: 3rd Apr 2010 05:54
Thanks a lot to the both of you. Hopefully I'll be able to catch things like that better in the future.

EDIT: Okay, there is another problem.

In the second part of the tutorial, it talks about using a black box to cover up the health bar so that when a gradient is applied to the box, then the colors wont be balanced. I.E. if it goes from dark red to light blue, then instead of both colors being balanced no matter the width, the lower the health got, you'd see less and less of the blue. Here is my code as it is now.

Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 7th Apr 2010 17:05
I'm not sure what you are trying to accomplish with that code but, I think you are going to have a problem with the black box being in the way. Aside form that, what is your question?

You could use something like this for your health bar:


The fastest code is the code never written.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 7th Apr 2010 17:28
Is this what you're trying to do?



(I used red and green.)
The Guardian
16
Years of Service
User Offline
Joined: 13th Sep 2009
Location:
Posted: 15th Apr 2010 01:14
Green Gandalf, that is exactly what I'm trying to do. Thank you so much.

Login to post a reply

Server time is: 2026-07-26 15:30:31
Your offset time is: 2026-07-26 15:30:31