Debugging C++ Video Lectures 6 and 7 Are Done

Debugging C++ Video Lectures 6 and 7 Are Done

After a long vacation working on my WWII game design, I’ve finally got the next two video lectures on debugging C++ done. They are up on YouTube.

The free source code and videos are also available on the free links page here.

Enjoy, but do let me know what other kinds of debugging situations you would like to see covered.

Vic

 

Share Button

Debugging C++ Video Lecture 5

Debugging C++ Video Lecture 5

I’ve just uploaded the next lecture in debugging C++. This time, I spend some time going over the generic double linked list class because this sample will be the basis for several subsequent lectures.

In this debugging lecture, I present the debugger’s Memory Watch window. It allows you to examine any memory location in both hex and ASCII formats. Sometimes, locating the source of the memory leak can lead directly to the location of the coding error that is creating wild results. This example is one of these. By trying to locating the memory leak, we are led directly to the error.

This sample has been added to the site’s free download section along with the others.

Here’s the fast link to the video:
Debugging Lecture 05

Share Button

The Free Debugging C++ Lectures Are Available

Free Debugging C++ Lectures

By popular demand, I am making available all the original “bugged” programs, along with the fixed versions and the video that illustrates the debugging steps. Download them and see if you can replicate my debugging steps. Also, I’ve included the various documents shown in the videos so you can have those tips as well.

Some of the samples are simple C++ programs, some involve C++ classes, and some are Windows MFC examples. Expect a wide variety of “bugging” examples.

Have fun with these. Here’s the direct link:

Free Debugging C++ lectures and samples used in the demos.

Vic

Share Button

The Fourth Debugging C++ Video Is Up on YouTube

The Fourth Debugging C++ Video Is Up on YouTube

Hi All,

I’ve just uploaded he fourth lecture on Debugging C++ to YouTube. This time, I present the 8 Steps to Effective Debugging. Failure to follow these makes debugging a nightmare. Following them makes your task easier and more productive. I also provide four key definitions that people often are a bit shaky on and also the Four Classes of bugs.

This is the starting point for our examination of more difficult debugging examples as well. However, in this video, I’ve chosen a simple Windows application that illustrates a hard crash as well as a memory leak. You don’t need to know Windows programming to follow the debug session, though.

In the near future, all of these debugging programs will be available as a free download on this website. That way, you can experiment with them directly.

Have fun with this one,

Vic

Share Button

The Third Video in the How to Debug C++ Programs Is On YouTube

How to Debug C++ Programs Lecture 03

The third video in this series is now up on YouYube. In this video, I show you how to use the Call Stack feature of the debugger to help locate the errors in programs. In this session, the Dice class is discussed with two hard crash errors as well as a minor incorrect output. At the end of the video, I’ve added a Take Away list of the key points from these first three beginning lectures.

See how to more effectively and rapidly find the errors in your C++ programs. Watch the video. Subscribe to the channel to get automatic updates when subsequent videos in the series are released.

You can also comment on them and I am open to your suggestions on what other topics you would like to see hints and tip on – just let me know.

Here’s the fast link to the video:
Debugging Lecture 03

Vic

Share Button

Updates to Windows MFC Programming II Ebook

Hi

I’ve updated the Windows MFC Programming II ebook samples to VC.NET 2010 and fixed a few problems that appeared when running the newer compiler and Windows 7. The changes are minor. To download them, go to the Windows MFC Programming II page and scroll to the bottom. There you will find two new links. One retrieves a zip file with a list of changes and the 2010 set of project folders. The other link is just to the small txt file of the changes.

Have fun,

Vic

Share Button

Downloads of Free Sample C++ Programs from the Ebooks

Hi Everyone,

I’ve now got some free sample C++ programs download of key items from a number of computer programming ebooks now available.

The data structures zip file includes key and highly useful basic classes, including the growable array, double linked list, stack, queue, and a binary tree. They are presented in full detail in the two data structures ebooks.

Plus games. Ah, games. I’ve included some key production version games from the Programming Non-graphical Games in C++ as well as the complete coding for most of them. This way, you can see the many different kinds of game engines that you can learn to program.

Also I’ve included key free sample C++ programs from the Games Programming Theory in C++ so you can see the many different aspects of realism that can easily be added into your game to make it more exciting for your players. All you need to do next is add in a fancy graphical interface which you will be able to do once you’ve been through the two MFC Programming ebooks.

I’ve included some relevant and sometimes fancy samples from the two Windows MFC (Microsoft Foundation Classes) ebooks. Here is where you can learn to make good looking graphical interfaces to your applications.

So have at the free sample C++ programs. Download them and experiment with them. See what you could learn to program yourself!

Yes, I have copyrighted the the free sample C++ programs, but you are free to use them in your applications, that is, they are open source, but I would like an acknowledgement if you do so.

Vic

Share Button

The Second Video in the How to Debug C++ Programs Is On YouTube

How to Debug C++ Programs Lecture 02

The second video in this series is now up on YouYube. In this video, I show you how to use the basic features of the debugger to find the errors in programs. Step Into and Step Over are explained along with Continue and how to set and remove breakpoints at key locations. The Watch window, Auto, and Local windows are used effectively to keep track of variable contents.

See how to use these in combination to more effectively and rapidly find the errors in your C++ programs. Watch the video. Subscribe to the channel to get automatic updates when subsequent videos in the series are released.

You can also comment on them and I am open to your suggestions on what other topics you would like to see hints and tip on – just let me know.

Here’s the fast link to the video:
Debugging Lecture 02

Share Button

The First Debugging C++ Programs Video Is Up on YouTube

Debugging C++ Programs Video Series

I’ve begun a series of videos on Debugging C++ Programs . Debugging: is it an art or science? When I’m helping my students with theirs, some claim that it could well be a magical art ! This series is intended to illustrate many methods for locating run time errors in many kinds of C++ programs. Perhaps, it is a bit of both. This series will help you learn more about the tools that are available to you, how to use them to track down errors, and something about the “art” as well.

The first step is “an ounce of prevention.” In this video on debugging C++ programs, I show you positive steps that you can take in your coding practices to keep bugs minimized. Of course, if you love to debug, then ignore and skip this video and just look at the ones to follow. In this video, I show you two excellent methods to prevent run time errors, including using the C++ error handler (i.e. try-catch logic).

Link to video

Let me know what you think of this series. Also, I’m open to suggestions for further “how to” videos that you’d like to see. Let me know your ideas and we can make a fun project of learning.

Vic

Share Button

Adding Realism to Your Game Programming in C++

Adding Realism to Your Game Programming in C++

Making the motions of objects in your game realistic and believable is one of the keys to a good, well-designed game that others will enjoy playing. Fast moving cars that instantly turn a corner, weapons whose projectiles always hit the target no matter what, avatars that jump across wide chasms defying gravity — you’ve seen them and probably like me say something like, “Now that’s impossible!” And we’re right. An alien space ship flying a thousand miles and hour instantly does a ninety degree turn to come after you — oh no! The g-forces on the crew are gargantuan (if you don’t know that word, look it up).

Realism in gaming is all about following the known laws of motion, the physics at work in our universe, the universe we all know on a daily basis. Granted, the physics and math levels needed to fully understand and develop such real-world solutions can be very challenging, perhaps mind-boggling to those who have had little exposure to basic physics and calculus. However, in my book, Game Theory Programming in C++, I do all that work, giving you more or less canned implementations that you can tweak and use in your games to add higher levels of realism. Let’s look at what I’m talking about.

Suppose that we were driving down the Interstate at sixty miles per hour. We drive at this constant rate for an hour (thanks to cruise control). How far will we have gone? If you answer sixty miles, you are correct. That is one of the basic laws of motion at work.
Distance traveled = velocity times time

We can refine it a bit further. If we are initially at location X, then after that hour of driving, our new location is at X + 60 miles.

Notice here that I used the word velocity and not speed. What’s the difference? Speed is just a number, 60 mph. It does not have any direction associated with it. Where would we be, distance wise, if during that hour of driving, I drove around in a large circle, such as the Interstate loops around large cities? My final location could well be right back where I started from. A vector is both a speed and a direction, that is, we say it has a magnitude plus a direction. Physics of motion is heavily involved with vectors.

So our first key equation gives us our new position:
new position = original position + amount of time * (velocity)

Newton’s Third Law of Motion is: For every action there is an equal, but opposite reaction. For every force acting on a body, there is an equal and opposite reacting force. Suppose you are standing in line to buy a ticket for a show and someone comes up behind you and gives your back a push (force). Which way does your body tend to go? Forward. Suppose someone on your right gives you a shove (force), your body tends to go to the left. Now suppose you are simultaneously shoved both from behind and from the right? You tend to go off at an angle, to the left and forward. Vectors at work here.

This vitally important relationship is summed up as: (* indicates multiplication)
Force = Mass * Acceleration
though it is usually written as: F = m * a.

Of course, the acceleration is a vector, a magnitude with a direction, as is the force being applied. But just what is this acceleration anyway? It is the rate of change of velocity over time, enter calculus. It is usually written this way.
a = dv / dt, where dv is the change in velocity and dt is the interval of time.

For example, your car is going sixty miles per hour and you run into a brick wall. Your velocity goes to zero during a duration of let’s say a second. What’s the result? The acceleration on your body is terrific! Splat! Forget about air bags this time.

So where does all this get us? To create realism in an object’s motion, we must take into account all of the forces acting on the object, such as friction, air resistance, and so on. This gives us one of the fundamental principles:
Principle 6: The resultant force is the vector sum of each individual force acting on the object.
This is written: m * a = sum of all F
or rewriting it:
a = sum of all F / m

Okay, okay, so where does this get us? How does this help us to make realistic motions of our game objects? We resort to a calculus principle. To find the overall result, we integrate the equations of motion over time. Huh? It’s okay if you haven’t had calculus. I take care of the details for you. The principle is simple. Take the overall time span and divide it into tiny, infinitesimal units, called delta t. For each tiny interval of time, we know or can estimate the total forces acting upon an object at that point. Given the forces, we can find the resulting acceleration: a = sum of all F / m. Now knowing the acceleration during that infinitesimal bit of time, we can then find the velocity and distance traveled during that small period of time from:    a = dv / dt, rewritten as dv = a * dt
From dv, we get the new position:  new position = original position + dt * dv

This is saying that we can accurately plot the path that an object will take through time, viola realistic motion!

Just how small does this infinitesimal unit of time need to be? Ah, this is an adjustable parameter. If you are doing a fast action type of game, then the time interval might be quite small. The smaller, the more accurate the simulation, but the more calculations needed to determine the series of successive locations for the object and thus the more calculation time needed, which can slow down the entire game. One adjusts the actual amount of time to meet the needs of playability of the game.

Keeping it simple, the overall process is then as follows:
1. Calculate the object’s mass properties.
2. Find and codify all forces that are acting upon the object at this instant in time.
3. Vector sum all forces.
4. Solve the equation of motion for acceleration.
5. Integrate with respect to our small unit of time to find the velocity.
6. Integrate with respect to our small unit of time to find the new position.
7. Check for and handle any collisions, if this has meaning in your game.
8. Display or use the new position in some manner.

In my book, Game Theory Programming in C++, I handle the physics and math for a wide range of objects and situations, both in 2-d and in 3-d simulations. Yes, the physics and math can get pretty involved, but I’m taking care of those details for you, presenting you with easy to use, complete coding that you can cannibalize and use in your own games.

Above all, have fun developing your game.

Vic

Share Button