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.

Newcomers DBPro Corner / How Do i Do this?

Author
Message
Newbie Brogo
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: In a Pool of Cats
Posted: 12th Jul 2003 18:39
How can i make health, like if one guy hits the other, his health goes down, how i do that?
Halozane Future Owner.
Dave J
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 12th Jul 2003 18:49
By using a Health variable, sorry but if you're asking this question you need to learn more first. Try reading some tutorials and stuff found on the main site.

"Computers are useless they can only give you answers."
Philip
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 12th Jul 2003 19:30
Thats a very basic question I'm afraid. I say this because even I, muggins extraordinarie, can answer it. I'd suggest you buy "the Beginners Guide to DarkBasic Game Programming" and read that. Alternatively, have a look at Marc Fleury's website. Its not complete, but you'd find it useful.

Anyway, to address your question, you need to define yourself a health variable. This could be, say:

health = 100

That'd be your maximum health assuming your character starts at maximum health at the beginning of the game.

Then during the game you could reduce it when your character is hit by an enemy and damaged, i.e.
[/code]
if (hit = 1) AND (health > damage)

health = health - damage

endif

The reason that snippet is checking to see if health is greater than damage, is that if it isn't, your character is dead (assuming death occurs at health <= 0).

Also, the health could be increased when nice things happen, such as when your character eats an apple:

if (apple_eaten = 1) AND (health < 100)

if (health > 90)

health = 100

else

health = health + 10

endif

endif
[code]
Thats all very over-simplistic. I imagine you'll want to use types and arrays to store all your characters' stuff in one central place. Health might be part of an array or a type, for example.

Phil

What do you mean, bears aren't supposed to wear hats and a tie?
Philip
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 12th Jul 2003 19:31
Man, thats annoying. The tags didn't work. Let me repost and try again.

Thats a very basic question I'm afraid. I say this because even I, muggins extraordinarie, can answer it. I'd suggest you buy "the Beginners Guide to DarkBasic Game Programming" and read that. Alternatively, have a look at Marc Fleury's website. Its not complete, but you'd find it useful.

Anyway, to address your question, you need to define yourself a health variable. This could be, say:

health = 100

That'd be your maximum health assuming your character starts at maximum health at the beginning of the game.

Then during the game you could reduce it when your character is hit by an enemy and damaged, i.e.

The reason that snippet is checking to see if health is greater than damage, is that if it isn't, your character is dead (assuming death occurs at health <= 0).

Also, the health could be increased when nice things happen, such as when your character eats an apple:

Thats all very over-simplistic. I imagine you'll want to use types and arrays to store all your characters' stuff in one central place. Health might be part of an array or a type, for example.

Phil

What do you mean, bears aren't supposed to wear hats and a tie?
Guyon
21
Years of Service
User Offline
Joined: 6th Jun 2003
Location: United States
Posted: 12th Jul 2003 21:26
Was Newbie Brogo looking for just changing a variable, or more of a graphical bar change in health?
Newbie Brogo
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: In a Pool of Cats
Posted: 12th Jul 2003 22:09


Halozane Future Owner.
John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 12th Jul 2003 22:21
Newbie before makeing your next post please read the rules at the top of the forum regarding your thread title.

RPGamer

Current Project: Eternal Destiny
Questions? Comments? Suggestions? Go to the Eternal Destiny Forum!

Login to post a reply

Server time is: 2024-11-24 22:27:48
Your offset time is: 2024-11-24 22:27:48