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 / loose health after animation after a frame number is over?

Author
Message
Daniel wright 2311
User Banned
Posted: 11th Oct 2009 01:16 Edited at: 11th Oct 2009 01:19
Like the title reads, I need to loose 1 point of health after his last frame number of the attack animation.or even at a certin frame number. any help would be apreshiated.

here is what i have



DSW
Daniel wright 2311
User Banned
Posted: 11th Oct 2009 09:34
no one?

DSW
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 11th Oct 2009 19:08 Edited at: 11th Oct 2009 19:21
try something like this, replacing line 3 in the code above:

first,
when you're intializing your objects, record the last animation frame number. ie:

LastFrame = total object frames (ObjectNum)
` and, adding a flag for later use:
hit = 0


then, in your loop:



not sure how you're handling various states, etc, but you get the idea. the LastFrame checks that you will only take damage on that particular frame (set it to whatever you want). the Hit flag is making sure that you only do/take damage once per animation loop incase your game loop displays the same animation frame more than once in a row. hope this helps

add, looking at how i set the Hit flag up, i suppose it can record a hit, skip a hit, then record a hit again before the animation actually loops IF your animation is playing so slow that it could be a series of the LastFrame being displayed. without knowing more of your code, i can't tell if it will work as expected for sure, so try it out and come back if it doesn't


Daniel wright 2311
User Banned
Posted: 11th Oct 2009 22:05
Right, I see this now, thank you for your help. this will do it, im shure.

DSW
Daniel wright 2311
User Banned
Posted: 11th Oct 2009 22:30
wait? ok, wait, I did not think of this but this only will work if my modle has one animation number

DSW
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 12th Oct 2009 01:15 Edited at: 12th Oct 2009 01:16
not sure what you mean by "one animation number" but you can set LastFrame to whatever you want, whenever you want. people "initialize" and handle their objects & data in different ways but, one method would be to utilize an array to hold pertinent data you could use to reference and compare. if you wanted to store "lastframes" for a number of objects, let's say 10 for now, your array (and "initialization") might be something like:



now you've stored each object's last animation frame and intialized their HIT flag to 0 (not hit).

then when you want to check for damage on a particular enemy, you'd use the array, blending it into the code example from above. ie, for object 3 in your example...


i can't really guess what your game is all about or how complex it might be but if you have multiple objects/entities/etc, you could use arrays like this to store all "entity" information including their current "states", health, last animation frames, HIT flags, etc.

make sense?


Daniel wright 2311
User Banned
Posted: 12th Oct 2009 02:28
right, this makes alot more sence, i now see the math. thanks, ill use this and add more to it latter.

DSW

Login to post a reply

Server time is: 2024-11-25 01:45:05
Your offset time is: 2024-11-25 01:45:05