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 / Got a few problems

Author
Message
Lee Stevens
17
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Deep in code...
Posted: 11th Sep 2010 05:11 Edited at: 11th Sep 2010 05:11
1)
When the health bar reaches the very left end I want my player to die (In the actually code, The players ID Number thing is 2)

2) My player walks up to a NPC (non playable Charactor) Presses (A) and they start talking he gives you 2 options
-Advice on a mission (only an example)
-Opens up the ingame store window (with various upgrades)

I'm guessing for a store window to open I would have to use a sprite/Image/Bitmap?

3) My goals by the end of the weekend are
Quote: "+Create Player : POSITION CAMERA : Control Player
+Add Health : Money : and Current XP
-Add Scene : INCLUDING Platforms and gaps"
( the + means ive done it, the - means i need to do it)
Basically i need help with the scenary, I made a test level in Cartography shop and my charactor walked straight through the walls. So any Advice/Tips/Pointers on scenary/levels is needed please

If There Is A Problem, Find The Question.
Lee Stevens 1st September 2007
Lee Stevens
17
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Deep in code...
Posted: 11th Sep 2010 05:16
Sorry for double posting guys but I forgot to press the
Quote: "Receive email to your MailBack address each time someone replies?"
I do this because TGC send an email to my email account and my email account sends the emails directly to my phone its so I know if/when I get a reply

If There Is A Problem, Find The Question.
Lee Stevens 1st September 2007
luskos
17
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 11th Sep 2010 08:05 Edited at: 11th Sep 2010 08:07


The above code snippet have the health bar as it should be.In your version when health goes down past 10 the box is drawed beyond the start point where it originally begins.I added BoxX and BoxY variables for BoxX start position and BoxY start position.BoxX is used for offset value from the begining of the screen so when the health drops to 0 the box is 0 lenght not -10 from it original start.I hope this make sense to you.Else just try the code and see what i mean.There should be better way to do this more advanced and so on, but i see that your code is very basic so i keep it simple for you to understand.

Also your 1) isn't easy to answer.We don't really know what is your character representing the player in your virtual world.It can be a sprite image or 3d object.If it's sprite then you may want to check when health is 0 if this is the case you play sprite death animation if we assume that you are using animated sprite, else if the case is 3d object for the character then you play object death animation.After this you may call a function to restart the level or take a life and respawn the player at given coordinates.It really depends of the game, there are so much various scenarios.You need to code it yourself!There is no absolute answer to this question unless you show more code or tell more about your game.What you need to do is imagine what you want to happend when your player die in details then write it in pseudo code, try to write it in real code.If you fail, welcome here with pseudo code.

2) Looking at first question answer(i'm afraid long one) i need to say in short that you need to hardcode it there isn't easy way for stuff like this.There isn't comand that can make this happend automaticly or something like that.That's fun about programing.To code it yourself.There are various tutorials and snippets here on the forums that can help you to clear this.It may look simple but it can be a struggle with your nervs when you code it.

About 3) http://www.youtube.com/watch?v=ysjporqwnis

This video should be enough for convincing you that you are gonna need Sparky's Collision DLL.Search the forum for it, it's free plugin.In short you are gonna forget about this problem.Collision is in very core of any modern 3d game, your problem comes from that dbpro did not make it automaticly for you.That's because you need to define whatever object is gonna be affected by collision and which isn't.There could be object that ignore collision with other objects like particless, projectiles and dummy units/objects.Again everithing is about coding and setup.It must be hard or there is no pleasure at the end.No pain no game!

Good luck with the game!

Coding is My Kung Fu!
And My Kung Fu is better than Yours!
Wysardry
14
Years of Service
User Offline
Joined: 10th Jun 2010
Location: Yew Kay
Posted: 11th Sep 2010 11:01
Instead of :-


You could use :-


Or :-
luskos
17
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 11th Sep 2010 12:43
Why actually post this Wizardry?I believe his code wasn't real deal anyway and the asking wasn't for various methods to decrease health.I believe it's about everithing after the health reach 0.How to code death of the character and so.

Coding is My Kung Fu!
And My Kung Fu is better than Yours!
Wysardry
14
Years of Service
User Offline
Joined: 10th Jun 2010
Location: Yew Kay
Posted: 11th Sep 2010 16:44
As this is the newcomer's forum, I believed it could be helpful to show a more efficient way of incrementing and decrementing the health variable.

In my examples, checking whether the value is within the required range is done before it is modified, rather than the value being modified then checked and then potentially changed back again.

Not only is the code I showed shorter and more efficient, it could also allow a word or even byte to be used for health instead of an integer, which would save a lot of memory if there were many NPCs in the game.

Login to post a reply

Server time is: 2024-09-28 22:37:08
Your offset time is: 2024-09-28 22:37:08