Advertisement

collision sprite

Started by November 16, 2018 10:13 PM
33 comments, last by Rutin 6 years ago

I already told you how to do it. :) What did you try, and what isn't working since the last time?

Programmer and 3D Artist

well I put screen = 0.0f into my drawcollsion_one function and it draws a static collision sprite but for some reason I cant get it to animate the collision sprite. I think my glutTimerFunc function is not working properly.

Advertisement
14 minutes ago, phil67rpg said:

well I put screen = 0.0f into my drawcollsion_one function and it draws a static collision sprite but for some reason I cant get it to animate the collision sprite. I think my glutTimerFunc function is not working properly.

I already answered that question prior on what you need to do in order to get it working. Based on your code you haven't tried any of the steps I outlined.

If you want to solve this problem using your own method and not something that actually works then you're going to continue to have issues because you don't understand the logic behind what needs to be done.

Simply put, if you unable to solve this problem on paper with pseudocode, you're not going to solve the same problem using C++.

Programmer and 3D Artist

ok I will pseudo code this problem, also how do I solve a problem like this one, how do I work through this problem logically I want to be a better programmer.

54 minutes ago, phil67rpg said:

ok I will pseudo code this problem, also how do I solve a problem like this one, how do I work through this problem logically I want to be a better programmer.

I might be wrong but the main trend and problem I'm seeing just by observing your various posts is that you struggle to break down problems and build solutions logically. I've also noticed that when you're given input it appears you almost completely disregard that advice and continue to approach your problem the same way prior to getting advice.

In order to be a good programmer you need to be good at problem solving and you must have a logical mind. If you cannot break things down and come up with solutions logically, then you're going to have a very hard time progressing in this field.

In order to not repeat myself in the same detail, you can see the prior posts I made about how to approach this problem.

Summary:

Bullet hits your plane.

(assuming you're doing it at the object level and not using an animation manager for everything)

For plane a explosion animation:

Upon collision your plane toggles a variable that indicates it needs to start the animation. Once you hit your logic step again you would check to see if the plane is able to animate or not. If true, then it would take the current time as the start time and when checking you can do: elapsed time - start time to get actual time passed if you cannot setup a custom timer. Then you can set frames based on what frame is supposed to be active in relation to where you are in time. When the animation is started you would need to set a variable to indicate the animation is running so you're not resetting the initial setup variables above. In your draw step you would simply pick the appropriate part of the texture based on what frame is active. Once your animation hits the max amount of time you would then toggle the animation related variables and reset or kill the object if that is what you want to do.

The above can apply to bullet animation on impact and the actual plane blowing up when hit with a bullet and the plane's health is equal to 0.

Your job is to take a concept like what I wrote above for example and use your knowledge in C++ and openGL to make something happen.

There is nothing more I can add to this without giving you the code to solve the problem, but that won't help you grow as a programmer and is of no benefit to you.

Best of luck.

Programmer and 3D Artist

check for collision

execute collision function

set screen variable

draw collision sprite

animate collision sprite

well I am not very good at pseudocode so here is my best shot. let me know if I can improve on it. do you of any tutorials on pseudocode

 

 

Advertisement

You can read up on it:

https://en.wikipedia.org/wiki/Pseudocode

If you google the topic you'll find a lot of information on what it is and how you can utilize it.

On the topic of Logic and Problem Solving, I have no idea how to give advice on how to improve. Maybe someone else here can assist with that.

Programmer and 3D Artist

does anyone else want to comment on my pseudocode or my problem?

well I have a odd problem. when I set the screen variable to 0.0f I only get a static collision sprite. However when I set the screen variable to 0.0001f I get the animated sprite to work in the display function but I still get only the static collision sprite when I execute the collision detection function.

You've been told over and over to stop using GLUT.  It was last updated in 1998, 20 years ago.  Even FreeGLUT has not been updated in almost 4 years.  Even though these forums are quite friendly we all eventually grow tired of beating a dead horse.  You often just post code saying you're having a problem.  Not what that problem is, what you've tried, what your thoughts the problem might be, etc.  Then as @Rutin pointed out, when given advise like he has multiple times in this thread, you just flat out ignore it like you have with his.  He actually has given you very sound advise too.  If you're unsure what he meant with something, ask specific questions.

Also some of your comments seem fairly pointless.  You have a comment in one function for collision that says, "//draw bullet" but it's collision detection code, it should not nor does it look like it draws a bullet.  It's also just calculating the position of the bullet anyways, so it's a completely useless and misleading comment which might throw you off later down the line.

"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety." --Benjamin Franklin

This topic is closed to new replies.

Advertisement