Hello again! In this video, we are going to conclude our game project. And it is also the last video of
the course.
So what we achieved in our project. We have implemented this gain, which has quite a few features,
but we have used less than 700 lines of code.
That is not counting comments.
And I have commented to the code in quite a lot of detail. So I hope that will help you understand it.
The code is modular. So if we want to change something we just need to go to one defined place.
We do not need to scroll around one big file, trying to find something that might be relevant.
Most of the code is easy to understand.
Admittedly, the entity manager is a bit of a brain stretcher.
But once you get that working, there is no need to go back to that code.
If you want to add a new entity type to the game.
That's straightforward.
You start off by deriving a class. Either from entity,
if it is not moving or moving_entity, if it does move around. You load up the image file in the
class constructor, you override the update() member function.
So if the entity changes between frames, that is where you make those changes.
And of course, you will need data members and member functions, to give it the behaviour that you
want.
Then you go to the reset() member function of the game manager, and you get the entity manager to
create and register the object for you.
And finally, if your entity is going to collide with other entities in the game, then you would write
the code for handling those collisions, and put that in the game loop.
So how would you improve this code?
Well, there is quite a few things you can do.
You could refactor the code.
There is still some duplicated code, in some things, that could be tidied up.
Bug fixing. There is one bug that I know about, and possibly some that I do not know about!
It is possible for the ball to get trapped under the paddle.
But I decided to leave that.
So if you want, you can exercise your bug-fixing skills on that!
An obvious improvements is to add more levels, with increasing difficulty. So the ball can go faster,
the bricks can be tougher, there can be more layers of bricks and so on.
You could also make the bricks appear to crack when the ball hits them. So you can just draw some lines
on the surface of the brick, to represent cracks.
And if it is all a bit too predictable, you can use random numbers to introduce a bit of uncertainty.
So you can make some bricks
unusually strong or unusually weak. You can change the reflection angle,
so it is not 90 degrees all the time.
And of course, you can add sound effects.
So, how good is this code as a game development environment?
So for writing simple games like this one, it's pretty good, I think. And it is also good for prototyping,
rapid development.
So if you have some ideas for a game, then you can just use this to build something and get started
fairly quickly.
On the other hand, if you want to write a really big, complicated game, which pushes the hardware to
its limits, then this is probably not suitable.
There are too many slow operations.
Another problem is that inheritance does not really work with very large, complicated programs.
You start off with a nice, clean, encapsulated tree, and then you start finding that some objects
need to reference state in other objects.
So the encapsulation starts leaking away. And then you find you need to create complicated objects.
So for example, MoonbaseOccupant, who is also a Shopkeeper, who is also a Hobbit. So you tend to
end up with all sorts of criss-cross lines going across your tree.
So it looks more like a tangled bush or a hedge than a nice clean tree.
So, professionals tend to use an architecture called Entity Component System. And if you are really serious
about games, that is something you should investigate.
Or alternatively, you can use one of the game frameworks which are available, which are built around
that.
I think Unreal Engine is one of those and there are others as well.
Okay, so that is it for this video, and for the course.
I hope you enjoyed it and found it is useful.
That is all from me.
I wish you good luck with your studies and your career.
So that is all for this video, but maybe I will see you in one of my other courses.
But goodbye for now.