View Full Version : How to get shot? And Health bar
fenderstrat0409
10-29-2009, 02:30 PM
Ok, So I have this game and I have two people with revolvers that shoot at you (Their arms move up and down and fire comes out)
Ok so how can I tell it to like
When shot at, Subtract so much health
How can I do that?
Also... How can I make like a health bar or something?
xxledzeppelin2x3
10-29-2009, 03:08 PM
wow that is one large task you are asking..... hopefully a senior member will have a pre made demo for that already :eek:.. you should post ur game on this thread so it can be tweaked with by another member testing solutions for the shoot and health bar.
good luck, Trevor
x2495iiii
10-29-2009, 09:29 PM
xxledzeppelin2x3 is right about it being a large task, but it can be done in a few ways.
First, are you using bullets? If you are, you can have the world check to see if the bullet hits the character and have the collision subtract health like this:
Loop infinity times:
if bullet is within [character's width] of character
world.health (a number variable you create) set value to world.health - 5.
If you're not using bullets (which is slightly harder but more accurate), you'd need to use the enemies' orientation to determine if they're aiming at your character. My Resident Penguin game has an example of this targeting method in the method called "gamestuff" (there's a comment over it which says it tests to see if the zombie is in front of the penguin).
By using your character and two objects as markers to determine where the target is relative to the character, you can determine whether the object is directly in front of the character or not (this is a little complex, I know, but I can always write a small demo if you'd like.)
As far as the health bar goes, depending on what kind you want, it could be easy or hard. For example, if you wanted one solid bar, it might be hard as you'd need a complex set of resizing methods to make it look like the bar is depleting. However, if you wanted a number counter or a series of small, identical rectangles or shapes as health, it would be easier, as all you'd need is a variable which tracks health, and a method which sets the objects' isShowing property to true or false based on that variable (or in the case of the counter, displays that number as a string.)
This is hard to understand at first, but once you learn Alice it gets easier and easier.
xxledzeppelin2x3
10-30-2009, 02:34 PM
wow thank you x2495iiii for all this info you post to forums, i have saved a microsoft word document on my desktop and copied and pasted many things you have said on these threads for my little quick guide! you are the greatest!
fenderstrat0409
10-30-2009, 09:42 PM
xxledzeppelin2x3 is right about it being a large task, but it can be done in a few ways.
First, are you using bullets? If you are, you can have the world check to see if the bullet hits the character and have the collision subtract health like this:
Loop infinity times:
if bullet is within [character's width] of character
world.health (a number variable you create) set value to world.health - 5.
If you're not using bullets (which is slightly harder but more accurate), you'd need to use the enemies' orientation to determine if they're aiming at your character. My Resident Penguin game has an example of this targeting method in the method called "gamestuff" (there's a comment over it which says it tests to see if the zombie is in front of the penguin).
By using your character and two objects as markers to determine where the target is relative to the character, you can determine whether the object is directly in front of the character or not (this is a little complex, I know, but I can always write a small demo if you'd like.)
As far as the health bar goes, depending on what kind you want, it could be easy or hard. For example, if you wanted one solid bar, it might be hard as you'd need a complex set of resizing methods to make it look like the bar is depleting. However, if you wanted a number counter or a series of small, identical rectangles or shapes as health, it would be easier, as all you'd need is a variable which tracks health, and a method which sets the objects to true or false based on that variable (or in the case of the counter, displays that number as a string.)
This is hard to understand at first, but once you learn Alice it gets easier and easier.
alright, Well I made the enemys now shoot bullets at you. And I told them that if they are within 1meter then your character dies.
K That is good. But Now, I do not understand variables very well... So.. How do I get them to work? I just want like a number counting health thing. Not a bar.
and I would also be like Bullet 1 meter from character (Subtract 5 hp) something like that.
How would I go about doing that?
x2495iiii
10-31-2009, 02:52 AM
I wrote a demonstration for you, hopefully that will help you to understand.
xxledzeppelin2x3
10-31-2009, 10:31 AM
WOW! that is by far the funnest demo i have ever played! haha, also very very very very helpful thank you!
fenderstrat0409
10-31-2009, 10:33 AM
I wrote a demonstration for you, hopefully that will help you to understand.
ok yeah I see what you're doing. I would upload my game to let you see it.. But it is too big. I have the number on the srceen and it is displayed as 100. Now All I have to do is turn it into a string and have it subrtact five when bullet is within 1 meter.
Correct?
I could perhaps send the game by email if you would want to see it.
x2495iiii
10-31-2009, 11:43 AM
Could you zip it and post it that way?
xxledzeppelin2x3
10-31-2009, 12:31 PM
yehh zip it and put it on because maybe now i will be able to help you because i kind of understand x2495iiii's demo , so zip it and attach it!
fenderstrat0409
10-31-2009, 07:42 PM
Could you zip it and post it that way?
Only compressed to 32 mbs. Still too big =/
x2495iiii
10-31-2009, 07:51 PM
Yeah then you'll have to post it to a file sending site. Try going here:
Wikisend (http://www.wikisend.com/)
Upload your file, then PM me the download link they give you. The site will hold a copy of your file for 7 days, and then delete it, so it's nice for quick, one-time file tranfers like these (and the file can be up to 100mb).
xxledzeppelin2x3
10-31-2009, 08:04 PM
you can also use megaupload.com
fenderstrat0409
10-31-2009, 09:21 PM
Yeah then you'll have to post it to a file sending site. Try going here:
Wikisend (http://www.wikisend.com/)
Upload your file, then PM me the download link they give you. The site will hold a copy of your file for 7 days, and then delete it, so it's nice for quick, one-time file tranfers like these (and the file can be up to 100mb).
alright here is the link
http://wikisend.com/download/856186/walkin 3rd person.a2w
k and i got this so far
(this is in Sherrif --> Methods --> Sherrif hit)
World.Health Set Value to 1 - 5
The problem I am having is that I cant drag the World.Health again to say
World.Health Set Value to World.Health - 5
Why wont it do it?
xxledzeppelin2x3
10-31-2009, 10:35 PM
wow nice game but there are more glitches then what you named :( when he runs its odd and a few other things, but very nice! unfortunantely i'm dumbfounded on how to answer ur question :(, sorry.
fenderstrat0409
11-01-2009, 09:26 AM
wow nice game but there are more glitches then what you named :( when he runs its odd and a few other things, but very nice! unfortunantely i'm dumbfounded on how to answer ur question :(, sorry.
Yeah there are a million glitches in it. More than I could try to name. but it is not bad for a game made in Alice. At least so far. I'm still editing it.
Also... Did music and sounds play for you? i didn't think they would.
xxledzeppelin2x3
11-01-2009, 11:17 AM
yehh the music actually did play for me! it fits it pretty well ;)
fenderstrat0409
11-01-2009, 04:08 PM
yehh the music actually did play for me! it fits it pretty well ;)
oh it did? Nice
also...
I got it to say
world.health set value to (world.health - 5) duriation = 0
But it still will not change... I cant figure our why...
here is the new link for http://wikisend.com/download/522320/Sheriff%20Game.rar
x2495iiii
11-01-2009, 04:19 PM
Did you have the counter set its text to "health as a string" when health changes?
fenderstrat0409
11-03-2009, 02:12 PM
Did you have the counter set its text to "health as a string" when health changes?
yeah I finally got it to work. I had to set the set text as string before the subtract 5. I couldn't do one at the begining of world and then subtract. They had to be in the same method.
Thanks a lot for the help though :D