1
00:00:01,005 --> 00:00:03,006
- [Instructor] Hi, this is the last video

2
00:00:03,006 --> 00:00:06,004
of this section, Coding the Main Function.

3
00:00:06,004 --> 00:00:08,000
In the previous video we looked at

4
00:00:08,000 --> 00:00:09,008
building the game engine.

5
00:00:09,008 --> 00:00:12,002
In this video, we will
code the main function

6
00:00:12,002 --> 00:00:14,006
to see the background of the game.

7
00:00:14,006 --> 00:00:18,009
Let's start with renaming
the HelloSFML.cpp file

8
00:00:18,009 --> 00:00:21,008
as main.cpp.

9
00:00:21,008 --> 00:00:25,002
First, right click on the HelloSFML file

10
00:00:25,002 --> 00:00:28,007
in the solution explorer
and select rename,

11
00:00:28,007 --> 00:00:32,008
and change the name to main.cpp.

12
00:00:32,008 --> 00:00:35,005
This will be the file that
contains our main function

13
00:00:35,005 --> 00:00:39,004
and the code that
instantiates the engine class.

14
00:00:39,004 --> 00:00:43,000
Add this highlighted code to main.cpp.

15
00:00:43,000 --> 00:00:45,000
First, we add an include directive

16
00:00:45,000 --> 00:00:47,003
for the engine class, then,

17
00:00:47,003 --> 00:00:49,007
inside the main function,
declare an instance

18
00:00:49,007 --> 00:00:52,009
of engine, then call its run function.

19
00:00:52,009 --> 00:00:55,002
Everything will be handled
by the engine class

20
00:00:55,002 --> 00:00:57,007
until the player quits
and the execution returns

21
00:00:57,007 --> 00:01:01,006
to main and the return zero statement.

22
00:01:01,006 --> 00:01:02,009
That was easy.

23
00:01:02,009 --> 00:01:04,002
Now we can run the game

24
00:01:04,002 --> 00:01:07,005
by clicking on local
windows debugger button

25
00:01:07,005 --> 00:01:10,002
and see the empty background
either full screen

26
00:01:10,002 --> 00:01:12,006
or split screen, which
will eventually contain

27
00:01:12,006 --> 00:01:13,008
all the action.

28
00:01:13,008 --> 00:01:16,006
Here's the game so far in full screen mode

29
00:01:16,006 --> 00:01:18,005
showing just the background.

30
00:01:18,005 --> 00:01:21,005
Now, tap the E key and
you'll be able to see

31
00:01:21,005 --> 00:01:24,006
the screen neatly
partitioned into two halves

32
00:01:24,006 --> 00:01:27,007
ready for split screen co-op gameplay.

33
00:01:27,007 --> 00:01:31,000
Take a look at the neatly
partitioned two halves.

34
00:01:31,000 --> 00:01:33,000
Awesome.

35
00:01:33,000 --> 00:01:35,009
Cool, that marks the end of this section.

36
00:01:35,009 --> 00:01:37,003
In this section we started off

37
00:01:37,003 --> 00:01:39,006
with an introduction to the final project,

38
00:01:39,006 --> 00:01:41,000
Thomas was late.

39
00:01:41,000 --> 00:01:42,003
We then moved on to structuring

40
00:01:42,003 --> 00:01:44,002
the Thomas was late code.

41
00:01:44,002 --> 00:01:46,001
In the later videos, we learned building

42
00:01:46,001 --> 00:01:48,009
the game engine and
coding the main function.

43
00:01:48,009 --> 00:01:50,003
That's amazing.

44
00:01:50,003 --> 00:01:52,000
In the next section, we'll be learning

45
00:01:52,000 --> 00:01:56,002
about advanced OOP,
inheritance, and polymorphism.

