1
00:00:00,009 --> 00:00:02,008
- [Instructor] Welcome to the
third section of this course

2
00:00:02,008 --> 00:00:06,002
Building Playable Levels
and Collision Detection.

3
00:00:06,002 --> 00:00:10,000
We'll start this section by
designing levels in a text file.

4
00:00:10,000 --> 00:00:12,006
We would then build a levelManager Class

5
00:00:12,006 --> 00:00:14,004
that will load levels from a text file,

6
00:00:14,004 --> 00:00:16,006
convert them into data our game can use,

7
00:00:16,006 --> 00:00:19,000
and keep track of the level details

8
00:00:19,000 --> 00:00:21,003
such as spawn position, current level,

9
00:00:21,003 --> 00:00:22,009
and allowed time limit.

10
00:00:22,009 --> 00:00:26,002
Then, we'll update the game
engine to use levelManager.

11
00:00:26,002 --> 00:00:28,009
And lastly, we'll code
a polymorphic function

12
00:00:28,009 --> 00:00:33,005
to handle the collision detection
for both Bob and Thomas.

13
00:00:33,005 --> 00:00:35,009
Now we start with the
first video of this section

14
00:00:35,009 --> 00:00:38,004
Designing Some Levels.

15
00:00:38,004 --> 00:00:40,006
In this video, we are going to take a look

16
00:00:40,006 --> 00:00:43,001
at the code and images for level designs.

17
00:00:43,001 --> 00:00:47,000
Remember our Sprite sheet that
we introduced in section one

18
00:00:47,000 --> 00:00:49,002
abstraction and code management?

19
00:00:49,002 --> 00:00:50,005
Here it is again.

20
00:00:50,005 --> 00:00:52,009
Annotated with numbers
that represent each tile

21
00:00:52,009 --> 00:00:55,002
that we will build our levels from.

22
00:00:55,002 --> 00:00:57,008
I placed the screenshot
on a gray background

23
00:00:57,008 --> 00:00:59,006
so you could see clearly
the different details

24
00:00:59,006 --> 00:01:01,001
of the Sprite sheet.

25
00:01:01,001 --> 00:01:02,004
The checkered background

26
00:01:02,004 --> 00:01:04,001
represents the level of transparency,

27
00:01:04,001 --> 00:01:06,008
so all of the tiles except for number one

28
00:01:06,008 --> 00:01:10,006
will reveal at least a little
of the background behind them.

29
00:01:10,006 --> 00:01:13,006
Tile zero is completely
transparent and will be used

30
00:01:13,006 --> 00:01:16,009
to fill in the gaps where
there aren't any other tiles.

31
00:01:16,009 --> 00:01:18,007
Tile one is for the platforms

32
00:01:18,007 --> 00:01:20,008
that Thomas and Bob will walk on.

33
00:01:20,008 --> 00:01:24,002
Tile two is for fire tiles, and tile three

34
00:01:24,002 --> 00:01:26,004
is for water tiles.

35
00:01:26,004 --> 00:01:29,005
Tile four, you might need to
look quite closely to see.

36
00:01:29,005 --> 00:01:31,008
It has a white square outline.

37
00:01:31,008 --> 00:01:34,006
This is the goal of the
level where Thomas and Bob

38
00:01:34,006 --> 00:01:36,005
must get to together.

39
00:01:36,005 --> 00:01:40,004
Keep this image in mind as we
discuss designing the levels.

40
00:01:40,004 --> 00:01:42,008
We will enter combinations
of these tile numbers

41
00:01:42,008 --> 00:01:45,008
into text files to design the layouts.

42
00:01:45,008 --> 00:01:47,009
Here's an example that will help.

43
00:01:47,009 --> 00:01:51,000
This code translates to the
level layout shown here.

44
00:01:51,000 --> 00:01:53,003
Note that to get the view shown,

45
00:01:53,003 --> 00:01:56,007
I had to zoom out the view,
also the image is cropped.

46
00:01:56,007 --> 00:02:00,003
The actual start of the
level would look like this.

47
00:02:00,003 --> 00:02:03,002
The first point of showing
you these images is twofold.

48
00:02:03,002 --> 00:02:05,008
Firstly, you can see how
you can quickly construct

49
00:02:05,008 --> 00:02:09,009
level designs using a
simple and free text editor.

50
00:02:09,009 --> 00:02:12,003
Secondly, it demonstrates the game play

51
00:02:12,003 --> 00:02:14,003
aspects of the design.

52
00:02:14,003 --> 00:02:16,002
From left to right in the level,

53
00:02:16,002 --> 00:02:18,006
Thomas and Bob first need
to jump a small hole,

54
00:02:18,006 --> 00:02:21,007
or they'll fall to their deaths.

55
00:02:21,007 --> 00:02:25,006
Then, they have a large
expanse of fire to traverse.

56
00:02:25,006 --> 00:02:28,007
It is actually impossible for
Bob to jump that many tiles.

57
00:02:28,007 --> 00:02:32,001
The players will need to work
together for the solution.

58
00:02:32,001 --> 00:02:35,000
The only way that Bob
will clear fire tiles

59
00:02:35,000 --> 00:02:38,004
is by standing on Thomas'
head and jumping from there.

60
00:02:38,004 --> 00:02:40,009
As you can see here,
it is then quite simple

61
00:02:40,009 --> 00:02:44,002
to get to the goal and
move on to the next level.

62
00:02:44,002 --> 00:02:46,001
I strongly encourage you
to complete this section,

63
00:02:46,001 --> 00:02:49,008
and then spend some time
designing your own levels.

64
00:02:49,008 --> 00:02:52,009
I've included a few level
designs to get you started.

65
00:02:52,009 --> 00:02:55,008
They are in the levels folder
that we added to the project

66
00:02:55,008 --> 00:02:59,004
back in section one abstraction
and code management.

67
00:02:59,004 --> 00:03:01,003
You can see them here.

68
00:03:01,003 --> 00:03:03,008
Let's see some zoomed
out views of the game

69
00:03:03,008 --> 00:03:06,002
along with the code of the level design.

70
00:03:06,002 --> 00:03:08,004
The code is probably more
useful than reproducing

71
00:03:08,004 --> 00:03:10,007
the actual textual content.

72
00:03:10,007 --> 00:03:12,008
If you do want to see the code,

73
00:03:12,008 --> 00:03:15,005
just open up the files
in the levels folder.

74
00:03:15,005 --> 00:03:18,001
This is the levels folder.

75
00:03:18,001 --> 00:03:20,007
This is what the code looks like.

76
00:03:20,007 --> 00:03:22,006
See this is level layout

77
00:03:22,006 --> 00:03:24,008
that the previous code will produce.

78
00:03:24,008 --> 00:03:26,005
Look at this image.

79
00:03:26,005 --> 00:03:28,008
This level is the leap of faith, level I,

80
00:03:28,008 --> 00:03:31,007
referred to in section one.

81
00:03:31,007 --> 00:03:32,009
I have highlighted the platforms

82
00:03:32,009 --> 00:03:36,006
as they are not very clear
in the zoomed out image.

83
00:03:36,006 --> 00:03:38,002
The provided designs are simple.

84
00:03:38,002 --> 00:03:40,002
The game engine will be able

85
00:03:40,002 --> 00:03:42,007
to handle very large designs however.

86
00:03:42,007 --> 00:03:45,002
You have the freedom
to use your imagination

87
00:03:45,002 --> 00:03:48,005
and build some really big
and hard to complete levels.

88
00:03:48,005 --> 00:03:51,002
Of course, these designs
won't actually do anything

89
00:03:51,002 --> 00:03:53,006
until we learn to load them and convert

90
00:03:53,006 --> 00:03:55,006
the text into a playable level.

91
00:03:55,006 --> 00:03:57,003
Additionally, it won't be possible

92
00:03:57,003 --> 00:03:58,007
to stand on any platforms

93
00:03:58,007 --> 00:04:01,005
until we have implemented
collision detection.

94
00:04:01,005 --> 00:04:04,008
We'll move to loading the level designs.

95
00:04:04,008 --> 00:04:07,007
In this video, we have designed levels.

96
00:04:07,007 --> 00:04:08,005
Great!

97
00:04:08,005 --> 00:04:10,003
In the next video, we'll
take a look at building

98
00:04:10,003 --> 00:04:12,002
the levelManager Class.

