Advertisement

collision

Started by January 07, 2017 11:51 PM
77 comments, last by jpetrie 7 years, 8 months ago

actually C++ Primer is only the 5th ed, the 6th ed. is called C++ Primer Plus which I heard was not very good.

I am going to stick with my Sam Teach Yourself C++ 8th ed. because it is very up to date, it covers c++ up to and including c++ 17, I have worked with this kind of text before and I like the way it explains things and has exercises in the backs of each chapter.

Advertisement

actually C++ Primer is only the 5th ed, the 6th ed. is called C++ Primer Plus which I heard was not very good.

Sorry, 6th was a typo - I meant 5th edition. C++ Primer Plus is not an updated version of the same book, it is an unrelated text which I would not recommend.

If you're happy with the book you've selected then stick with it, it should be fine for learning the basics. Make sure to do all the exercises - you can make new topics to ask for advice (NOT solutions!) in the forums here if you need help.

- Jason Astle-Adams

well I have ordered C++ primer 5th ed., I should get it by monday

well I have made several flowcharts as they apply to my collision detection algorithm, sometimes they do help.

Flow charts can be a good way to reason your way through an algorithm. You could also try writing out the steps as pseudocode (probably quite similar to your "stubbed out code") before writing actual code.

- Jason Astle-Adams

Advertisement

where is a good site to learn pseudocode?

where is a good site to learn pseudocode?

Pseudo code isn't something you learn. It's basically just a way of writing code-like structure, but using "normal" language.

As an example, let's say in my game I want to delete all bullets when they go off the screen. Some pseudo-code for this might look like:


For every bullet do this:

    check to see if bullet is still on screen:
        is bullet x position less than the left side of screen?
        is bullet x position greater than the right side of screen?
        is bullet y position less than the top side of screen?
        is bullet y position greater than the bottom side of screen?

    if bullet is off screen mark it for deletion.

Delete all marked bullets.

It gives you an idea of how to construct the logic for the code, but without worrying about the specifics yet.

ok , I got my new c++ primer book today, after I read my last 2 chapters about opengl I will start my new c++ book, I will also brush up on pseudocode.

well here is some pseudocode for my collision routine, I am new to using pseudocode, let me know what you think of my pseudocode.

For every bullet do this:

set bullet to starting position

move bullet up the screen

if bullet hits lower brick then turn off brick

reset bullet to starting position

move bullet up the screen

if bullet hits mid brick then turn off brick

reset bullet to starting position

move bullet up the screen

if bullet hits upper brick then turn off brick

reset bullet to starting position

This topic is closed to new replies.

Advertisement