1
00:00:08,590 --> 00:00:13,500
Here we are in the last lecture for module
four about classes and objects.

2
00:00:13,500 --> 00:00:16,850
And as a reminder here are the module
learning objectives.

3
00:00:16,850 --> 00:00:18,722
And we've finally gotten to the one we're

4
00:00:18,722 --> 00:00:20,930
go, we're going to design a new class
together.

5
00:00:24,290 --> 00:00:25,954
So at this point in the module,

6
00:00:25,954 --> 00:00:29,154
we've discussed the foundational ideas
behind the object

7
00:00:29,154 --> 00:00:31,778
oriented paradigm here and we've discussed
how

8
00:00:31,778 --> 00:00:34,900
to use those ideas in a C-sharp program.

9
00:00:34,900 --> 00:00:37,195
Now were going to step back from the

10
00:00:37,195 --> 00:00:41,330
programming and do a higher level design
activity.

11
00:00:41,330 --> 00:00:42,360
To design a class.

12
00:00:43,540 --> 00:00:47,040
Before we actually do that, you should
take this in-lecture quiz.

13
00:00:52,990 --> 00:00:55,270
So, before we can design our rubber

14
00:00:55,270 --> 00:00:58,158
chicken class, we have to think deeply
about

15
00:00:58,158 --> 00:01:01,046
our game design, and really decide what
role

16
00:01:01,046 --> 00:01:04,460
does the rubber chicken play in our game.

17
00:01:04,460 --> 00:01:08,660
Now you might think That the player avatar
would

18
00:01:08,660 --> 00:01:13,530
be an awesome thing to use the rubber
chicken for.

19
00:01:13,530 --> 00:01:17,880
Sadly, not this time.

20
00:01:17,880 --> 00:01:22,890
This time we're going to design the rubber
chicken as a weapon.

21
00:01:22,890 --> 00:01:25,860
So it won't be a very limited weapon, of
course, because

22
00:01:25,860 --> 00:01:29,320
rubber chickens are pretty flexible now I
hope you got that.

23
00:01:30,340 --> 00:01:35,185
rubber chickens can be either melee
weapons as you can might, as you

24
00:01:35,185 --> 00:01:40,410
might be able to imagine and they can be
ranged weapons as well.

25
00:01:40,410 --> 00:01:42,889
So, the way we're going to approach this
is

26
00:01:42,889 --> 00:01:45,320
first we're going to think about the
state.

27
00:01:48,050 --> 00:01:50,499
What kind of information do we need to

28
00:01:50,499 --> 00:01:55,530
store to capture the characteristics of
the rubber chicken?

29
00:01:55,530 --> 00:01:57,560
And then we'll move on to behavior.

30
00:01:59,660 --> 00:02:04,220
Now it's important for you to realize that
as we design real classes for

31
00:02:04,220 --> 00:02:09,280
real games we end up iterating between
state and behavior as we go along.

32
00:02:09,280 --> 00:02:13,260
We might discover we need some new
behavior as we're developing our game.

33
00:02:13,260 --> 00:02:17,900
At which point we probably need to go back
and add some more state as well.

34
00:02:17,900 --> 00:02:20,823
So this is sort of a a-typical small
example

35
00:02:20,823 --> 00:02:25,300
well we'll cover state and then we'll
cover behavior.

36
00:02:25,300 --> 00:02:28,600
So you should now go to the in lecture
quiz, which really has

37
00:02:28,600 --> 00:02:33,330
you pause and think about the state of the
rubber chicken for a while.

38
00:02:33,330 --> 00:02:35,230
And then come back and we'll talk about
it.

39
00:02:39,570 --> 00:02:44,114
Okay, so there is some reasonable state
information that we might store for

40
00:02:44,114 --> 00:02:48,830
a rubber chicken that we''re going to use
as a weapon in our game.

41
00:02:48,830 --> 00:02:52,214
First of all, we're going to need location
we need to know

42
00:02:52,214 --> 00:02:56,790
where the rubber chicken is, so that we
can do collision detection.

43
00:02:56,790 --> 00:03:00,944
Especially if you're good at using your
rubber chicken weapon, you're

44
00:03:00,944 --> 00:03:04,696
going to actually collide that rubber
chicken with other stuff and

45
00:03:04,696 --> 00:03:07,644
the way we actually figure out that that's
happened

46
00:03:07,644 --> 00:03:10,330
is by using the location of the rubber
chicken.

47
00:03:11,410 --> 00:03:13,706
Rubber chickens also have velocity,
especilly

48
00:03:13,706 --> 00:03:16,140
when they're used as a ranged weapon.

49
00:03:16,140 --> 00:03:20,940
So if were to throw the rubber chicken, it
has a particular velocity.

50
00:03:20,940 --> 00:03:23,316
And so we're going to need that velocity
so

51
00:03:23,316 --> 00:03:26,770
that we can change the rubber chicken's
location over time.

52
00:03:28,060 --> 00:03:29,908
We also have a range for the

53
00:03:29,908 --> 00:03:35,210
rubber chicken.
How far can you throw it, for example.

54
00:03:35,210 --> 00:03:38,602
And so, you know, you get upgrades, you
get rubber chicken upgrades as you

55
00:03:38,602 --> 00:03:43,780
work your way through this Fictional game
that hopefully no one will ever build.

56
00:03:43,780 --> 00:03:46,942
So you get these upgrades to your rubber
chicken and so you can

57
00:03:46,942 --> 00:03:52,450
fling your rubber chicken further if you
increase the range through those upgrades.

58
00:03:52,450 --> 00:03:55,159
Accuracy, you also have accuracy with your
rubber

59
00:03:55,159 --> 00:03:57,868
chicken, you can't just fling it in any
direction

60
00:03:57,868 --> 00:04:00,136
and then expect it to hit stuff, you need
to

61
00:04:00,136 --> 00:04:03,223
actually be good at aiming your rubber
chicken, wow there

62
00:04:03,223 --> 00:04:06,940
are some weird things I'm saying today but
that's okay.

63
00:04:06,940 --> 00:04:09,325
You have to be able to aim your rubber
chicken with some

64
00:04:09,325 --> 00:04:12,440
level of accuracy and again you might be
able to upgrade that stuff.

65
00:04:13,650 --> 00:04:15,820
Rubber chickens, when we do get that

66
00:04:15,820 --> 00:04:20,270
collision with something, rubber chickens
inflict damage.

67
00:04:20,270 --> 00:04:23,294
Now that damage could be variable right,
it could

68
00:04:23,294 --> 00:04:26,630
be based on how far away the rubber
chicken was.

69
00:04:26,630 --> 00:04:29,619
Its velocity when it strikes whatever it
hits, because if

70
00:04:29,619 --> 00:04:32,364
you use it as a range weapon towards
something close,

71
00:04:32,364 --> 00:04:34,682
it will probably do more damage than if
you use

72
00:04:34,682 --> 00:04:37,570
it as a range weapon and you throw it far
away.

73
00:04:37,570 --> 00:04:40,719
So, there's some damage that's probably
variable,

74
00:04:40,719 --> 00:04:44,180
unless we stuff our rubber chicken with
C4.

75
00:04:44,180 --> 00:04:45,608
In which case it probably

76
00:04:45,608 --> 00:04:47,920
always inflicts about the same amount of

77
00:04:47,920 --> 00:04:51,520
damage when it hits something and
explodes.

78
00:04:51,520 --> 00:04:54,832
The last thing we probably want to store
which you may not

79
00:04:54,832 --> 00:04:58,260
of thought of is who is the owner of this
rubber chicken.

80
00:04:58,260 --> 00:04:59,748
And it's not because we need you know

81
00:04:59,748 --> 00:05:02,310
somebody to feed and care for this rubber
chicken.

82
00:05:02,310 --> 00:05:06,836
It's because usually what happens,
especially in games with weapons,

83
00:05:06,836 --> 00:05:10,924
especially in games with ranged weapons,
is if you inflict damage

84
00:05:10,924 --> 00:05:15,450
by throwing your rubber chicken towards
something and the rubber chicken

85
00:05:15,450 --> 00:05:20,341
hits and destroys, oh, I don't know,
something, imagine something, hits

86
00:05:20,341 --> 00:05:25,086
and destroys something usually the owner
of that particular projectile, in

87
00:05:25,086 --> 00:05:30,030
this case, will end up getting points or
upgrades or something.

88
00:05:30,030 --> 00:05:32,918
Right so you actually need to keep track
of who

89
00:05:32,918 --> 00:05:36,186
is the owner of the rubber chicken, so
that we could

90
00:05:36,186 --> 00:05:42,440
allocate to those benefits to whoever
damaged something with the rubber chicken.

91
00:05:42,440 --> 00:05:46,720
Okay, so if that hasn't been disturbing
enough to you.

92
00:05:46,720 --> 00:05:48,290
That's great.
Hang with me.

93
00:05:48,290 --> 00:05:50,660
We'll see how much more damage we can do.

94
00:05:50,660 --> 00:05:54,110
So you should now go do another in lecture
quiz.

95
00:05:54,110 --> 00:05:58,500
We really think about what kind of
behaviors should this rubber chicken have.

96
00:05:58,500 --> 00:06:01,030
And then click continue, and we'll move on
together.

97
00:06:05,210 --> 00:06:06,150
Okay.

98
00:06:06,150 --> 00:06:07,919
So there are a number of reasonable

99
00:06:07,919 --> 00:06:10,970
behaviors that this rubber chicken could
have.

100
00:06:10,970 --> 00:06:14,290
For example, we're going to want to update
this rubber chicken.

101
00:06:14,290 --> 00:06:17,707
Remember we talked, sorry, we haven't
talked yet, but we

102
00:06:17,707 --> 00:06:20,454
will talk soon about a game loop where we
update to

103
00:06:20,454 --> 00:06:23,201
the game world so that we sort of update
the status

104
00:06:23,201 --> 00:06:26,750
of everything in our game world and then
we draw it.

105
00:06:26,750 --> 00:06:31,600
So we will want to update the rubber
chicken periodically.

106
00:06:31,600 --> 00:06:34,150
Every frame in our game, in general.

107
00:06:34,150 --> 00:06:37,980
So that the location changes based on the
velocity.

108
00:06:37,980 --> 00:06:42,070
So we definitely want to the rubber
chicken to expose an update behavior.

109
00:06:42,070 --> 00:06:45,600
So that we can change its location as we
go along.

110
00:06:45,600 --> 00:06:48,330
We might also want our rubber chicken to
exhibit an

111
00:06:48,330 --> 00:06:51,900
explode behavior, so we could call a
method telling the.

112
00:06:51,900 --> 00:06:53,780
Rubber chicken to explode.

113
00:06:53,780 --> 00:06:56,660
That really only applies if we're using
the whole C4

114
00:06:56,660 --> 00:07:00,210
rubber chicken approach.
But, you know, it's worth thinking about.

115
00:07:01,740 --> 00:07:04,120
We also may, if we have a more interesting

116
00:07:04,120 --> 00:07:07,900
game, we may have the rubber chicken play
an animation.

117
00:07:07,900 --> 00:07:10,000
It can play one animation as it flies

118
00:07:10,000 --> 00:07:13,385
through the air Another animation right
before it realizes

119
00:07:13,385 --> 00:07:15,695
it is going to explode because rubber
chickens are

120
00:07:15,695 --> 00:07:18,330
pretty self aware and they know that's
going to happen.

121
00:07:19,834 --> 00:07:21,682
and a variety of other animations

122
00:07:21,682 --> 00:07:23,100
just for humor.

123
00:07:23,100 --> 00:07:25,557
If you're building a game with rubber
chicken

124
00:07:25,557 --> 00:07:28,890
weapons, you probably are keying into the
humor idea.

125
00:07:28,890 --> 00:07:32,160
So playing some animations might be
interesting.

126
00:07:32,160 --> 00:07:37,230
I have in fact done this class design
exercise in a sort of normal.

127
00:07:37,230 --> 00:07:39,302
Well not a normal classroom, a classroom
of

128
00:07:39,302 --> 00:07:42,500
my game development students, let's put it
that way.

129
00:07:42,500 --> 00:07:46,724
And so I felt compelled to tell you that
there is one unreasonable behavior,

130
00:07:46,724 --> 00:07:49,080
at least for the rubber chicken.

131
00:07:49,080 --> 00:07:53,970
And most rubber chickens are not going to
in fact turn into a live chicken.

132
00:07:53,970 --> 00:07:55,380
Sometime in the game.

133
00:07:55,380 --> 00:07:57,290
That would just be wrong.

134
00:07:57,290 --> 00:08:01,550
This is not Pinocchio with rubber
chickens, so we we're probably

135
00:08:01,550 --> 00:08:06,070
not going to convert our rubber chicken
into a live chicken.

136
00:08:06,070 --> 00:08:11,790
Okay, so that was sort of a short and
sweet what thought process do

137
00:08:11,790 --> 00:08:17,290
we go through to actually design the
classes in our game.

138
00:08:17,290 --> 00:08:20,878
And that's probably enough for sort of the
informal figuring

139
00:08:20,878 --> 00:08:23,928
out what you need as you build classes in
your games.

140
00:08:23,928 --> 00:08:28,328
More advanced object-oriented analysis and
design has,

141
00:08:28,328 --> 00:08:31,760
uses much more formal tools to actually
figure

142
00:08:31,760 --> 00:08:36,952
out state and behavior and so on, and so
in later classes that I teach at

143
00:08:36,952 --> 00:08:41,090
UCCS, we actually cover those kinds of
things.

144
00:08:41,090 --> 00:08:43,718
But this sort of informal thinking about
it

145
00:08:43,718 --> 00:08:47,806
kind of process, including understanding
that you're probably

146
00:08:47,806 --> 00:08:50,799
going to iterate in practice, is, is a
reasonable

147
00:08:50,799 --> 00:08:54,890
first taste towards how we actually design
stuff.

148
00:08:54,890 --> 00:08:58,240
So, that's the end of module four.

149
00:08:58,240 --> 00:09:02,141
Next time, we'll actually move on to
talking about the

150
00:09:02,141 --> 00:09:03,320
XNA framework.