WEBVTT

00:00.210 --> 00:05.490
Hello again! In this video, we are going to conclude our game project. And it is also the last video of

00:05.490 --> 00:06.210
the course.

00:07.320 --> 00:12.240
So what we achieved in our project. We have implemented this gain, which has quite a few features,

00:12.480 --> 00:15.240
but we have used less than 700 lines of code.

00:15.720 --> 00:17.610
That is not counting comments.

00:17.610 --> 00:22.590
And I have commented to the code in quite a lot of detail. So I hope that will help you understand it.

00:23.700 --> 00:30.540
The code is modular. So if we want to change something we just need to go to one defined place.

00:30.840 --> 00:35.910
We do not need to scroll around one big file, trying to find something that might be relevant.

00:37.430 --> 00:39.560
Most of the code is easy to understand.

00:39.680 --> 00:42.320
Admittedly, the entity manager is a bit of a brain stretcher.

00:42.410 --> 00:46.670
But once you get that working, there is no need to go back to that code.

00:47.720 --> 00:50.210
If you want to add a new entity type to the game.

00:50.210 --> 00:51.560
That's straightforward.

00:51.890 --> 00:55.460
You start off by deriving a class. Either from entity,

00:55.490 --> 01:01.670
if it is not moving or moving_entity, if it does move around. You load up the image file in the

01:01.670 --> 01:05.870
class constructor, you override the update() member function.

01:06.050 --> 01:10.940
So if the entity changes between frames, that is where you make those changes.

01:11.510 --> 01:15.560
And of course, you will need data members and member functions, to give it the behaviour that you

01:15.560 --> 01:16.040
want.

01:17.030 --> 01:22.910
Then you go to the reset() member function of the game manager, and you get the entity manager to

01:22.910 --> 01:25.310
create and register the object for you.

01:26.120 --> 01:31.760
And finally, if your entity is going to collide with other entities in the game, then you would write

01:31.760 --> 01:35.240
the code for handling those collisions, and put that in the game loop.

01:37.770 --> 01:39.330
So how would you improve this code?

01:39.360 --> 01:41.220
Well, there is quite a few things you can do.

01:41.580 --> 01:43.280
You could refactor the code.

01:43.290 --> 01:47.400
There is still some duplicated code, in some things, that could be tidied up.

01:48.360 --> 01:53.100
Bug fixing. There is one bug that I know about, and possibly some that I do not know about!

01:53.190 --> 01:56.100
It is possible for the ball to get trapped under the paddle.

01:56.130 --> 01:57.750
But I decided to leave that.

01:57.840 --> 02:01.920
So if you want, you can exercise your bug-fixing skills on that!

02:03.810 --> 02:08.640
An obvious improvements is to add more levels, with increasing difficulty. So the ball can go faster,

02:08.670 --> 02:12.240
the bricks can be tougher, there can be more layers of bricks and so on.

02:13.320 --> 02:18.840
You could also make the bricks appear to crack when the ball hits them. So you can just draw some lines

02:18.840 --> 02:21.750
on the surface of the brick, to represent cracks.

02:23.030 --> 02:28.940
And if it is all a bit too predictable, you can use random numbers to introduce a bit of uncertainty.

02:29.030 --> 02:30.650
So you can make some bricks

02:30.680 --> 02:34.670
unusually strong or unusually weak. You can change the reflection angle,

02:34.670 --> 02:36.500
so it is not 90 degrees all the time.

02:37.130 --> 02:39.590
And of course, you can add sound effects.

02:41.380 --> 02:45.980
So, how good is this code as a game development environment?

02:46.000 --> 02:52.810
So for writing simple games like this one, it's pretty good, I think. And it is also good for prototyping,

02:52.810 --> 02:54.030
rapid development.

02:54.040 --> 02:59.530
So if you have some ideas for a game, then you can just use this to build something and get started

02:59.530 --> 03:00.340
fairly quickly.

03:01.510 --> 03:06.730
On the other hand, if you want to write a really big, complicated game, which pushes the hardware to

03:06.730 --> 03:09.400
its limits, then this is probably not suitable.

03:10.360 --> 03:12.430
There are too many slow operations.

03:13.550 --> 03:17.930
Another problem is that inheritance does not really work with very large, complicated programs.

03:18.920 --> 03:24.980
You start off with a nice, clean, encapsulated tree, and then you start finding that some objects

03:24.980 --> 03:27.320
need to reference state in other objects.

03:27.320 --> 03:32.990
So the encapsulation starts leaking away. And then you find you need to create complicated objects.

03:32.990 --> 03:40.010
So for example, MoonbaseOccupant, who is also a Shopkeeper, who is also a Hobbit. So you tend to

03:40.010 --> 03:43.250
end up with all sorts of criss-cross lines going across your tree.

03:43.400 --> 03:47.990
So it looks more like a tangled bush or a hedge than a nice clean tree.

03:49.310 --> 03:54.710
So, professionals tend to use an architecture called Entity Component System. And if you are really serious

03:54.710 --> 03:57.710
about games, that is something you should investigate.

03:58.010 --> 04:02.690
Or alternatively, you can use one of the game frameworks which are available, which are built around

04:02.690 --> 04:03.140
that.

04:03.710 --> 04:06.800
I think Unreal Engine is one of those and there are others as well.

04:07.250 --> 04:09.740
Okay, so that is it for this video, and for the course.

04:10.340 --> 04:12.860
I hope you enjoyed it and found it is useful.

04:14.240 --> 04:15.350
That is all from me.

04:15.680 --> 04:18.470
I wish you good luck with your studies and your career.

04:18.980 --> 04:22.580
So that is all for this video, but maybe I will see you in one of my other courses.

04:22.790 --> 04:23.840
But goodbye for now.
