Advertisement

collision

Started by January 07, 2017 11:51 PM
77 comments, last by jpetrie 7 years, 8 months ago
You might check out this thread from 2013. I feel it contains some relevant information to the problem at hand.

could I get a opinion about my pseudocode

Advertisement
Sure. Your pseudocode is terrible.

Pseudocode is supposed to accurately represent the actual flow of program execution. Yours does not. Ideally, you should be able to translate pseudocode into actual code with no confusion or question, and have the algorithm function correctly. Let's take a look at yours, shall we?

set bullet to starting position
Okay, sounds good.

move bullet up the screen
Alright.

if bullet hits lower brick then turn off brick
What? But we just moved the bullet up the screen, now you're wanting to check for a collision somewhere further down the screen? (Guess maybe you should specify how far to move the bullet?)

reset bullet to starting position
Ummm... okay.

move bullet up the screen
Again? Alright.

if bullet hits mid brick then turn off brick
But we just moved the bullet up the screen again. Now, you want to test collision further down the screen?

reset bullet to starting position
Sure, why not.

move bullet up the screen
Here we go again.

if bullet hits upper brick  then turn off brick
Sigh.

reset bullet to starting position
Might as well.

Taken at face value, this pseudocode represents code that does exactly nothing of value. Even outside its ambiguity (when you say move the bullet up the screen, you never specify how far), it just doesn't represent actual program flow.

Now, I thought about actually writing some pseudocode here to show how it should be done, but you know what? Screw it. I can't say anything that hasn't been said in your numerous other threads over the last 13 years or so. In that amount of time you should have learned something that is of use to you right now, but that apparently isn't the case. Just how much energy and time do you really expect the members of this forum to spend on you, if you just won't listen?

like I said this is my first time at pseudocode, I am trying to learn something new to me. I think you are too quick to condemn me and my efforts. well I have finished reading the OpenGL Programming Guide 7th Ed. and going to read and do the exercises in the back of the chapters, I working with the C++ Primer 5th ED. Hopefully this will help me to learn c++ from the ground up. As I have said before that I am doing programming stuff only for fun, I have also found out is that I learn at a very slow pace and I also seem to forget programming skills unless I practice c++ algorithms many times.

well I know I suck at programming, however I still like to do it just for fun, If anybody cares I have managed to get my get my breakout ball to hit a brick and make it disappear, then reset the ball and then move up the screen and then hit the mid brick and then finally hit the upper brick.

well one thing I have noticed over the years is that if I shelve a project for a while and then go back to it later I can usually solve the problem I was working on. this problem is no exception. I maybe slow but I usually manage to solve the problem I am working on.

Advertisement

Good to hear that you got your collisions to work to your liking. You'll probably find that as you work on other projects you'll need to make changes to the way that you're handling collisions. I've found that while there's a few standard approaches to dealing with collision detection, it's going to come down to what your specific needs are. And that detecting the collision and properly responding to it are two different things.

Good luck with your projects.

well I finally got my collision detection algorithm to work properly, all in need to do now is to get the collision detection to work with all the bricks, I am so happy that I got this problem solved.

well I finally got my collision detection algorithm to work properly, all in need to do now is to get the collision detection to work with all the bricks, I am so happy that I got this problem solved.

If it's working with some bricks but not others, then the algorithm isn't working properly. Are you still using a conditional statement for each brick, or have you abstracted the collision yet so that a single check will work on any brick anywhere?

well I have finally finished getting the ball to hit the bricks and make them disappear. I have done this for all the bricks. I am happy that I have finally solved this problem.

This topic is closed to new replies.

Advertisement