Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Kosh

DirectX Mysteries

This topic is 6638 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi everyone. I would like to know if anyone had come across this problem before? I have a structure, that holds details for a sprite, its position, frame of animation, etc, etc. Well, I tried to add functionality for the sprite to animate, also, along with that, it would have a separate damage animation, that it would also use along with the current animation, for example. think about a ship that you are flying. The ship is ok to start with, but when it''s hit by enemies, it starts taking damage. Then, to give the impression that it''s damaged, you start to judder that ship, left, right, shaking it in it''s animation. So, I wanted to periodically play an animation that would do this. So, I put in two variables into the structure, that would allow the sprite to play this animation a number of gameframes. Hence. int Gameframes_per_damage_animation; int Gameframes_damagecounter; therefore, damagecounter would start at zero, then when the damage animation function would execute, it would test to see if Gameframes_damagecounter was higher than the number setup in Gameframes_per_damage_animation, which would previously be set to something like 6 frames. So the damage animation would only play, every 6 frames, if it was less, it would increase the count and return. then the next time, compare, if greater/equal, play the animation, reset the counter to zero and return, you get the picture. I would appreciate any feedback on this method, if you have a better idea, come on, lets hear it well, upon adding these two vars to the structure, when run, it crashed, nothing special, just blackscreened and then went back to windows. Take them out, compile, everything works. I got the problem down to these variables, to the extent that their mere presence would stop the game from running. Comment them out, everything is ok, uncomment them, game wouldnt work. well this is odd, does anyone else know about this, perhaps an explanation as to why this happens? anyway, i''ll leave it there, I know I have been around the bushes and stuff in explaining this, but it was to give you a better idea of what the situation really was. kosh

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
When you have problems adding variables to structs, the two most common crash problems are caused by struct misalignment and heap allocation problems. Do a heap check after your code creates one of the structs, and print the return value to the screen. I''ll bet it''s probably a HEAP_BADNODE caused by struct misalignment.

Share this post


Link to post
Share on other sites
hi everyone,

anonymous, can you tell me, how to do that ? cause I know what you mean, but I dont know enough about compilers and VC to do that sorta thing, thanks

Share this post


Link to post
Share on other sites
I think i understand what you mean.

so you have a loop for the frames:
damage(){
dframe = 0;
while(numdframes > dframe){
dframe++
render();
}
}

right?
maybe your render function is the problem...
try changing your structs to classes to see if that clears up the problem because I have HUGE sprite combined with dx and animation routines and have never had to worry about alignment.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!