1
00:00:08,640 --> 00:00:12,070
So, we're halfway through module 11.

2
00:00:12,070 --> 00:00:15,980
Continuing along, here are the learning
objectives for the module.

3
00:00:18,850 --> 00:00:22,550
Last time we finished up with our console
dye

4
00:00:22,550 --> 00:00:26,550
class and so it's time for us to move
forward

5
00:00:26,550 --> 00:00:29,620
and to develop a class that is designed
specifically for

6
00:00:29,620 --> 00:00:33,990
use in XNA game rather than in a console
application.

7
00:00:33,990 --> 00:00:38,990
So, in this lecture we will be designing
that class and we'll

8
00:00:38,990 --> 00:00:44,170
be implementing the fields and properties,
so the state, again in

9
00:00:44,170 --> 00:00:45,500
that class.

10
00:00:45,500 --> 00:00:48,510
Before we do, you should go take an
in-lecture quiz.

11
00:00:54,290 --> 00:00:58,910
Now I know we've discussed using a rubber
chicken as a weapon before, way back

12
00:00:58,910 --> 00:01:03,590
in module four.
I have cut back a little bit on the scope

13
00:01:03,590 --> 00:01:11,040
of that weapon so it can't be used for, as
melee weapon, it's only a ranged weapon.

14
00:01:11,040 --> 00:01:15,750
So we'll use it as a ranged weapon and
we're going to focus today,

15
00:01:15,750 --> 00:01:19,970
well, we'll do all the design but we'll
focus on implementing the state stuff.

16
00:01:19,970 --> 00:01:23,870
So here are the things that we really need
to keep track of for the state.

17
00:01:24,950 --> 00:01:29,390
We need to keep track of whether or not
the rubber chicken is active.

18
00:01:29,390 --> 00:01:35,470
Because we're going to use it as a weapon,
essentially a projectile, and so when the

19
00:01:35,470 --> 00:01:39,950
projectile destroys something we should
probably destroy the projectile as well.

20
00:01:39,950 --> 00:01:45,220
So we're going to deactivate the rubber
chicken just as we deactivated teddy bears

21
00:01:45,220 --> 00:01:47,160
when they got destroyed.

22
00:01:47,160 --> 00:01:50,220
We're also going to need other two things
here.

23
00:01:50,220 --> 00:01:53,540
We're going to need both a sprite so we
can draw

24
00:01:53,540 --> 00:01:58,140
the rubber chicken in our XNA game and a
draw rectangle.

25
00:01:58,140 --> 00:02:00,390
Now, as I've mentioned in passing before,
there

26
00:02:00,390 --> 00:02:03,320
are actually lots of ways to draw sprites.

27
00:02:03,320 --> 00:02:07,030
The Sprite Batch draw method has lots of
overloads.

28
00:02:07,030 --> 00:02:09,295
We're going to continue using a draw
rectangle roll.

29
00:02:09,295 --> 00:02:10,315
And I said draw

30
00:02:10,315 --> 00:02:14,990
slash collision rectangle because inside
the class we'll think

31
00:02:14,990 --> 00:02:18,440
of it and refer to it as the draw
rectangle.

32
00:02:18,440 --> 00:02:22,120
But again, just as with the teddy bear,
we're going to consider

33
00:02:22,120 --> 00:02:26,670
consumers of the class will think about
that rectangle as a collision rectangle.

34
00:02:26,670 --> 00:02:30,010
So we'll handle that when it's time to
build the appropriate property.

35
00:02:32,340 --> 00:02:34,610
Rubber chickens that are used as ranged
weapons

36
00:02:34,610 --> 00:02:37,650
will have a velocity once they are
launched and

37
00:02:37,650 --> 00:02:39,850
so we need that velocity so we can

38
00:02:39,850 --> 00:02:43,220
update the rubber chicken's position, or
location, over time.

39
00:02:44,310 --> 00:02:48,620
And then finally, the amount of damage
that the rubber chicken inflicts.

40
00:02:48,620 --> 00:02:51,600
So when we hit something with the rubber,
when we hit something with the

41
00:02:51,600 --> 00:02:55,270
rubber chicken it causes some damage and

42
00:02:55,270 --> 00:02:57,630
maybe some rubber chickens are more
powerful

43
00:02:57,630 --> 00:03:02,160
than others and so we'll keep track of the
damage that we can apply as well.

44
00:03:06,450 --> 00:03:09,620
Because, we're going to look at the UML
for the fields in a

45
00:03:09,620 --> 00:03:15,150
moment, but because we're going to save
all this state information inside the

46
00:03:15,150 --> 00:03:19,710
object as fields you should go do an
in-lecture quiz telling me

47
00:03:19,710 --> 00:03:24,920
that you understand our conversation about
fields when we did the console class.

48
00:03:29,660 --> 00:03:31,430
So here's the UML.

49
00:03:31,430 --> 00:03:38,490
And it should come as no surprise to you
that we have five different fields here

50
00:03:38,490 --> 00:03:43,260
that are going to store the five pieces of
state that we talked about before.

51
00:03:43,260 --> 00:03:46,380
The additional detail that's included in
here is the

52
00:03:46,380 --> 00:03:49,500
data types for each of those pieces of
state.

53
00:03:49,500 --> 00:03:53,740
So active will be a bool, true or false,
right?

54
00:03:53,740 --> 00:03:54,490
That makes sense.

55
00:03:54,490 --> 00:03:54,870
It's either

56
00:03:54,870 --> 00:03:58,770
active or it isn't.
The damage will be an integer amount.

57
00:03:58,770 --> 00:04:01,590
We won't need the granularity that says it

58
00:04:01,590 --> 00:04:04,350
does, you know, 48.2 or anything like
that.

59
00:04:05,388 --> 00:04:07,050
The draw rectangle will be just as we've

60
00:04:07,050 --> 00:04:09,340
been doing before, it will be a rectangle
object.

61
00:04:10,520 --> 00:04:13,560
The sprite will be a Texture2D, as we're
used to

62
00:04:13,560 --> 00:04:17,940
in XNA games, and the velocity will be a
Vector2.

63
00:04:17,940 --> 00:04:20,910
So as a reminder, a vector2 has

64
00:04:20,910 --> 00:04:24,530
two components, or two properties that we
can access.

65
00:04:24,530 --> 00:04:26,850
It has an X, and it has a Y.

66
00:04:26,850 --> 00:04:29,334
So if we have this two dimensional vector
is

67
00:04:29,334 --> 00:04:32,025
really what it is then it will tell us,
what's

68
00:04:32,025 --> 00:04:35,544
the velocity in the x direction, positive
or negative, and

69
00:04:35,544 --> 00:04:40,100
what's the velocity in the y direction,
positive or negative.

70
00:04:40,100 --> 00:04:42,900
So those are, in addition to the field

71
00:04:42,900 --> 00:04:46,000
names, we now have captured the data types
we're

72
00:04:46,000 --> 00:04:50,340
going to use for those fields which helps
us when we get to the implementation part.

73
00:04:53,820 --> 00:04:56,438
So I'm going to actually start a new
project.

74
00:04:56,438 --> 00:05:00,882
So I've double-clicked the, my, my
shortcut and

75
00:05:00,882 --> 00:05:04,550
now I'm going to create this new project.

76
00:05:04,550 --> 00:05:11,300
So I say new project, it is an XNA game
studio game, it is a Windows game.

77
00:05:11,300 --> 00:05:14,910
I'm going to browse to the place where I
want to save it.

78
00:05:14,910 --> 00:05:17,600
So I'll cut here and be back momentarily.

79
00:05:17,600 --> 00:05:18,990
Okay, I have saved

80
00:05:18,990 --> 00:05:21,820
it and we have the code here.

81
00:05:21,820 --> 00:05:27,620
And I'll zoom in even though we're going
to immediately go and create a new class.

82
00:05:27,620 --> 00:05:32,200
And so we do this exactly the same way
that we did it in the console application.

83
00:05:32,200 --> 00:05:33,480
You need to be a little careful.

84
00:05:33,480 --> 00:05:37,650
Make sure you don't create the class down
here in the content area.

85
00:05:37,650 --> 00:05:40,060
That's for content not code.

86
00:05:40,060 --> 00:05:41,452
You want to create a big class up

87
00:05:41,452 --> 00:05:44,140
here where we're storing all of our source
code.

88
00:05:44,140 --> 00:05:48,160
All of our C sharp files.
So we right click, I've

89
00:05:48,160 --> 00:05:52,180
named this namespace rubber chicken by the
way, I right click it.

90
00:05:52,180 --> 00:06:01,145
I say that I wants to add a class and my
class is going to be a rubber chicken.

91
00:06:01,145 --> 00:06:09,760
[SOUND]

92
00:06:09,760 --> 00:06:13,765
I'll zoom in immediately and put the class
comment.

93
00:06:13,765 --> 00:06:15,940
[SOUND]

94
00:06:15,940 --> 00:06:16,440
And

95
00:06:19,000 --> 00:06:20,515
I'll add a region for Fields.

96
00:06:20,515 --> 00:06:21,320
[SOUND]

97
00:06:21,320 --> 00:06:25,989
And I'm going to sort of group these

98
00:06:25,989 --> 00:06:31,302
together as we go along for, you know,

99
00:06:31,302 --> 00:06:36,454
drawing support and movement support

100
00:06:36,454 --> 00:06:41,606
and so on but you can put these fields in

101
00:06:41,606 --> 00:06:46,960
any order you want really.
And,

102
00:06:46,960 --> 00:06:48,300
and some I won't even comment.

103
00:06:48,300 --> 00:06:52,840
So typically I comment the drawing support
fields even though there's only

104
00:06:52,840 --> 00:06:58,950
two of them but I don't necessarily
comment the active field, for example.

105
00:06:58,950 --> 00:07:02,540
So, I actually will put that active field,
remember we decided it was

106
00:07:02,540 --> 00:07:07,490
going to be a Bool and to this one we can
just initialize to true.

107
00:07:07,490 --> 00:07:12,100
Just like at the end of the lecture last
time we had

108
00:07:12,100 --> 00:07:15,650
a random number generator that we made a
field

109
00:07:15,650 --> 00:07:17,790
in the die class instead of just using a

110
00:07:17,790 --> 00:07:21,320
local variable, that's what a variable
that's declared inside

111
00:07:21,320 --> 00:07:24,980
a method is called, because it's local to
the method.

112
00:07:24,980 --> 00:07:27,150
Instead of using a local variable we used
a

113
00:07:27,150 --> 00:07:31,010
field and we initialized it when we
declared it.

114
00:07:31,010 --> 00:07:34,290
And so that's a perfectly valid approach
to use

115
00:07:34,290 --> 00:07:37,200
and so I'm setting active to true here
because rubber

116
00:07:37,200 --> 00:07:43,440
chickens should always start as active.
Okay, I'll add some drawing support.

117
00:07:45,370 --> 00:07:50,460
So I need a Texture2D and I know that it's
hard to see and there's no way for me to

118
00:07:50,460 --> 00:07:57,360
zoom in on the intellesense but Texture2D
is not showing up as one of my choices.

119
00:07:57,360 --> 00:08:02,770
What that means is that I am not, I do not
currently have direct

120
00:08:02,770 --> 00:08:07,660
access to that class.
Well, we, we have seen

121
00:08:07,660 --> 00:08:13,650
this in the programming assignments where
you needed to add a using statement

122
00:08:13,650 --> 00:08:19,090
and so we need to add a using statement to
get at Texture2D.

123
00:08:19,090 --> 00:08:23,340
So we need to type in using whatever the
name space Texture2D appears

124
00:08:23,340 --> 00:08:28,140
in and you may not have memorized yet what
name space that's in.

125
00:08:28,140 --> 00:08:32,225
Good news is we can go to help and we can
search on

126
00:08:32,225 --> 00:08:40,210
Texture2D, and we will sort of click
around for awhile until

127
00:08:40,210 --> 00:08:45,250
we get to where we need to be but the
Texture2D class,

128
00:08:45,250 --> 00:08:50,160
it says right up here at the top, which
namespace it appears in.

129
00:08:50,160 --> 00:08:53,631
And so the Texture2D is found in the
Microsoft

130
00:08:53,631 --> 00:08:57,013
dot xna dot framework dot graphics
namespace

131
00:08:57,013 --> 00:09:00,110
so that's the namespace we need to add.

132
00:09:01,610 --> 00:09:08,280
So Microsoft and Intellisense will help us
a little bit here, graphics.

133
00:09:09,520 --> 00:09:13,159
Now that I've added that namespace, when I
come back here, I

134
00:09:13,159 --> 00:09:18,540
hit Ctrl Space, by the way, to make
Intellisense pop back up.

135
00:09:18,540 --> 00:09:21,400
Now all those textures show up, which is
good.

136
00:09:22,470 --> 00:09:26,880
So, I'll need a sprite and I'll also need
a rectangle for

137
00:09:26,880 --> 00:09:31,980
the draw rectangle and we say well, that
one's not showing up either.

138
00:09:31,980 --> 00:09:36,705
So unless you've memorized which namespace
rectangle appears in, back we go to Help.

139
00:09:36,705 --> 00:09:37,200
[SOUND]

140
00:09:37,200 --> 00:09:37,700
And

141
00:09:41,050 --> 00:09:43,230
I can click on any of these until I can
click on

142
00:09:43,230 --> 00:09:48,380
the Rectangle Structure and this one is
found in the Framework namespace.

143
00:09:48,380 --> 00:09:52,320
Not Microsoft dot XNA dot Framework dot
Graphics.

144
00:09:52,320 --> 00:09:55,750
Just Microsoft dot XNA dot framework.

145
00:09:55,750 --> 00:10:01,804
So back to the code again.
Another using statement.

146
00:10:01,804 --> 00:10:04,274
[SOUND]

147
00:10:04,274 --> 00:10:10,620
And now again, control space

148
00:10:10,620 --> 00:10:16,410
and rectangle is the only one that fits so
it automatically filled it in for me and

149
00:10:16,410 --> 00:10:21,490
we now have our draw rectangle.
So, that's good.

150
00:10:21,490 --> 00:10:24,690
We have three of the fields taken care of
already.

151
00:10:24,690 --> 00:10:27,940
We still need to handle damage and
velocity.

152
00:10:27,940 --> 00:10:30,058
So let's take care of

153
00:10:30,058 --> 00:10:31,758
[SOUND]

154
00:10:31,758 --> 00:10:37,170
damage first.
And again, your order doesn't matter.

155
00:10:37,170 --> 00:10:41,190
I'm just sort of grouping them in a way
that seems intuitive to me.

156
00:10:42,890 --> 00:10:45,670
So we'll say there's some damage field
we're going to have.

157
00:10:46,790 --> 00:10:51,450
And I'll even change this comment to say
drawing and moving support so I can just

158
00:10:51,450 --> 00:10:56,880
put the vector two that I need for my
velocity right here as well.

159
00:11:00,930 --> 00:11:07,260
And that's it for the fields.
We need an active field, that's a Boolean.

160
00:11:07,260 --> 00:11:10,432
Damage, that's an INT.
Sprite is a Texture2D.

161
00:11:10,432 --> 00:11:12,650
Draw rectangle is a rectangle and velocity
is

162
00:11:12,650 --> 00:11:15,760
that two dimensional vector that we talked
about.

163
00:11:15,760 --> 00:11:20,070
So now it's time to actually start adding
the properties.

164
00:11:21,170 --> 00:11:24,860
So first, go do an in-lecture quiz about
properties.

165
00:11:28,710 --> 00:11:35,150
And now that you're back you can see that
I've added properties here to the UML.

166
00:11:35,150 --> 00:11:38,270
So these are the three properties that we
need.

167
00:11:38,270 --> 00:11:39,330
We need active.

168
00:11:42,160 --> 00:11:45,430
And we talked about properties last time.

169
00:11:45,430 --> 00:11:48,960
By the way, properties can be read, they
can be write, or they can

170
00:11:48,960 --> 00:11:51,900
be read-write depending on the combination
of

171
00:11:51,900 --> 00:11:55,930
get accessors and set accessors that we
provide.

172
00:11:55,930 --> 00:12:00,590
And so in this particular case, for the
Active property,

173
00:12:00,590 --> 00:12:04,600
we've said it's going to be Active with a
capital A.

174
00:12:04,600 --> 00:12:07,000
We're going to provide both a get
accessor,

175
00:12:07,000 --> 00:12:09,600
so the game can determine whether or not
the

176
00:12:09,600 --> 00:12:13,640
rubber chicken is active, and a set
accessor, so

177
00:12:13,640 --> 00:12:15,800
that the game that's using the rubber
chicken can

178
00:12:15,800 --> 00:12:19,000
deactivate the rubber chicken when it
should be destroyed.

179
00:12:20,310 --> 00:12:24,270
And finally that last little piece right
here says

180
00:12:24,270 --> 00:12:27,300
that it is in fact going to be a bool
property.

181
00:12:27,300 --> 00:12:28,240
Which makes sense right?

182
00:12:28,240 --> 00:12:32,197
Because the active field is a Boolean, it
can either be true or

183
00:12:32,197 --> 00:12:34,670
false, it makes sense that the property is
a Boolean as well.

184
00:12:35,880 --> 00:12:39,030
Our second property, the collision
rectangle.

185
00:12:39,030 --> 00:12:43,620
Remember, I have renamed what we're
calling draw rectangle in our

186
00:12:43,620 --> 00:12:48,240
field to be collision rectangle for the
property because the consumer of

187
00:12:48,240 --> 00:12:51,670
the property is really thinking of it as
something to be used

188
00:12:51,670 --> 00:12:57,420
for collision detection not something to
be used for drawing the sprite.

189
00:12:57,420 --> 00:13:02,110
Because that's internal to the class so a
consumer of the class doesn't care.

190
00:13:02,110 --> 00:13:04,910
It is a get accesser only.

191
00:13:04,910 --> 00:13:07,450
It makes no sense for the game to be

192
00:13:07,450 --> 00:13:10,560
able to change the collision rectangle for
this thing.

193
00:13:10,560 --> 00:13:13,410
It's based on the sprite and I'll, well,
it's based on the

194
00:13:13,410 --> 00:13:20,170
sprite and the draw rectangle so only read
access for this particular property.

195
00:13:20,170 --> 00:13:22,660
And then finally we have the damage
property

196
00:13:25,110 --> 00:13:28,030
and integer as, as we'd expect.

197
00:13:28,030 --> 00:13:34,660
Only a get accessor so only a read, read
access for this property as well.

198
00:13:34,660 --> 00:13:39,730
So there are no power ups that will make
the rubber chicken inflict more damage.

199
00:13:39,730 --> 00:13:43,520
This will be a really basic rubber
chicker, chicken game.

200
00:13:43,520 --> 00:13:47,490
Not the deep play experience that you
might have been expecting.

201
00:13:47,490 --> 00:13:51,230
Alright, so back to the code, I am adding

202
00:13:51,230 --> 00:13:53,690
a region for those properties that we were
juts

203
00:13:53,690 --> 00:13:56,742
talking about, and I'll add them one at a
time.

204
00:13:56,742 --> 00:13:58,650
So, we'll make them public.

205
00:13:58,650 --> 00:13:59,950
Remember the access modifier.

206
00:14:01,120 --> 00:14:03,930
This particular property, I'm doing active
first, so

207
00:14:03,930 --> 00:14:07,370
it's a bool and Active with a capital A.

208
00:14:08,740 --> 00:14:12,640
And I said that we were going to provide
both get and set accessors.

209
00:14:14,690 --> 00:14:16,930
And I'll add the comment now before I
forget.

210
00:14:18,870 --> 00:14:25,762
Gets and sets whether the rubber chicken
is active.

211
00:14:25,762 --> 00:14:32,790
So re, recall from the other properties
that we have

212
00:14:32,790 --> 00:14:40,410
done so far that we're going to end up
returning the value of the active field.

213
00:14:40,410 --> 00:14:43,180
And to return things we type return.

214
00:14:45,290 --> 00:14:49,060
The set accessor, which we looked at
before and I showed you an

215
00:14:49,060 --> 00:14:53,850
example and then got rid of, looks similar
to the example I showed you.

216
00:14:53,850 --> 00:15:00,080
We're going to be setting the active field
equal to whatever value is provided

217
00:15:01,410 --> 00:15:07,350
when the game accesses this property, this
set accessor for the property.

218
00:15:07,350 --> 00:15:10,770
Remember, it will say something like
rubber chicken

219
00:15:10,770 --> 00:15:16,252
zero dot active equals false.
And so inside here, inside the

220
00:15:16,252 --> 00:15:21,980
set accessor, that false is value.
Alright, so that's the first property.

221
00:15:23,310 --> 00:15:25,520
The second property is collision
rectangle.

222
00:15:25,520 --> 00:15:27,430
So, public again.

223
00:15:27,430 --> 00:15:28,805
This time it's a rectangle.

224
00:15:28,805 --> 00:15:33,850
[SOUND]

225
00:15:33,850 --> 00:15:38,055
And recall, this one we're only providing
a get accessor for.

226
00:15:38,055 --> 00:15:39,660
[SOUND]

227
00:15:39,660 --> 00:15:45,740
And here's where using properties rather
than just giving consumers of

228
00:15:45,740 --> 00:15:49,330
the class direct access to the field is
useful because we

229
00:15:49,330 --> 00:15:53,980
can rename this to Collision Rectangle
instead of Draw Rectangle based

230
00:15:53,980 --> 00:15:58,160
on how the consumer of the class thinks
about this property.

231
00:15:58,160 --> 00:16:03,550
Gets the collision rectangle for the
rubber chicken,

232
00:16:06,210 --> 00:16:11,930
and finally, we had one more property in
our UML, and that property was Damage.

233
00:16:11,930 --> 00:16:14,205
So it's public int Damage.

234
00:16:14,205 --> 00:16:15,035
[SOUND]

235
00:16:15,035 --> 00:16:18,190
Get access here only.

236
00:16:21,630 --> 00:16:27,255
Gets the damage rubber chicken

237
00:16:27,255 --> 00:16:32,340
inflicts.
And get works exactly like the

238
00:16:32,340 --> 00:16:37,850
other get accessors we've been doing.
We just return damage.

239
00:16:41,250 --> 00:16:47,900
So now we have the properties included
inside our implementation.

240
00:16:47,900 --> 00:16:50,980
we, just as with the dye class after

241
00:16:50,980 --> 00:16:53,050
we did fields and properties, we couldn't
do any

242
00:16:53,050 --> 00:16:55,240
testing on it yet, and we can't here

243
00:16:55,240 --> 00:16:59,570
either because we can't construct any
rubber chickens yet.

244
00:16:59,570 --> 00:17:02,340
But we'll be able to do that next lecture
and we'll implement the

245
00:17:02,340 --> 00:17:05,780
constructor and then we can construct and
make sure they work and so on.

246
00:17:05,780 --> 00:17:06,230
So,

247
00:17:06,230 --> 00:17:09,120
we'll get there, we're just not there
quite yet.

248
00:17:10,340 --> 00:17:10,890
Okay.

249
00:17:10,890 --> 00:17:12,450
So back to the slides.

250
00:17:12,450 --> 00:17:15,290
The last piece of the design, I know I
sort of

251
00:17:15,290 --> 00:17:19,610
snuck in some implementation during the
design, and that's okay too.

252
00:17:19,610 --> 00:17:24,850
We, it is very rare to do all your design
and then all your implementation.

253
00:17:24,850 --> 00:17:26,740
This is a really iterative thing.

254
00:17:26,740 --> 00:17:29,710
We design some, we implement some, we
design some, we implement some.

255
00:17:29,710 --> 00:17:31,260
And sometimes we go

256
00:17:31,260 --> 00:17:33,760
back after starting to implement and say
wow our

257
00:17:33,760 --> 00:17:36,250
design was not correct and we need to fix
it.

258
00:17:36,250 --> 00:17:39,930
And so this going back and forth is a
really common thing.

259
00:17:39,930 --> 00:17:41,300
Nothing wrong with it.

260
00:17:41,300 --> 00:17:43,510
But now that we're back here on the slides
talking

261
00:17:43,510 --> 00:17:47,220
about design we have behavior for the
rubber chicken too.

262
00:17:47,220 --> 00:17:50,520
And I have simplified that behavior as
well, I, we,

263
00:17:50,520 --> 00:17:53,790
talked back in module four about playing
animations and so on.

264
00:17:53,790 --> 00:17:55,310
We won't do that here.

265
00:17:55,310 --> 00:17:56,810
What we'll do instead is

266
00:17:56,810 --> 00:17:58,530
we will do two things.

267
00:17:58,530 --> 00:18:02,410
We will update the rubber chicke, and this
one will be a fairly interesting and

268
00:18:02,410 --> 00:18:07,090
reasonably complicated thing because we'll
move it along

269
00:18:07,090 --> 00:18:10,260
its velocity vector based on the elapsed
time.

270
00:18:10,260 --> 00:18:12,640
That's not the complicated part.

271
00:18:12,640 --> 00:18:15,630
And we will also process mouse input.

272
00:18:15,630 --> 00:18:18,700
So the way we're going to launch rubber
chickens, I mean, you, you,

273
00:18:18,700 --> 00:18:21,940
I think we'd have rubber chicken cannons
or something like that because it's really

274
00:18:21,940 --> 00:18:24,490
a projectile.
But we're not going to have that.

275
00:18:24,490 --> 00:18:28,440
We're, in fact, going to launch the rubber
chicken by clicking on it.

276
00:18:28,440 --> 00:18:30,750
Now this is a very stupid rubber chicken.

277
00:18:30,750 --> 00:18:33,490
It's not a homing rubber chicken or
anything.

278
00:18:33,490 --> 00:18:35,290
When we click on it it's just going to go

279
00:18:35,290 --> 00:18:37,980
straight up is how this rubber chicken
will work.

280
00:18:39,240 --> 00:18:41,610
If you wanted to, you could of

281
00:18:41,610 --> 00:18:47,730
course implement far more complicated
schemes where you

282
00:18:47,730 --> 00:18:50,410
click a rubber chicken to activate it and
then click somewhere on

283
00:18:50,410 --> 00:18:53,620
the screen and that's where it's going to
launch itself toward and so on.

284
00:18:53,620 --> 00:18:55,758
You know, send it, send the rubber chicken
over there.

285
00:18:55,758 --> 00:18:56,101
Right?

286
00:18:56,101 --> 00:18:58,700
And th, and that's a perfectly reasonable
thing to do

287
00:18:58,700 --> 00:19:01,530
that obviously people have figured out how
to do in games.

288
00:19:01,530 --> 00:19:05,530
We're just not going to do it here today.
We're not going to do it at all.

289
00:19:05,530 --> 00:19:10,770
But we'll do a really simplified rubber
chicken goes up when we launch it.

290
00:19:10,770 --> 00:19:13,190
So that's this part.

291
00:19:13,190 --> 00:19:15,050
So we're going to have to detect a mouse
click,

292
00:19:15,050 --> 00:19:17,860
not a mouse press, a mouse click on the
chicken.

293
00:19:17,860 --> 00:19:23,570
And we've learned how to do that already
when we were processing mouse buttons

294
00:19:23,570 --> 00:19:28,230
in the X and A input lectures.

295
00:19:28,230 --> 00:19:30,490
And the other behavior we're going to have
is

296
00:19:30,490 --> 00:19:33,340
we're going to have the rubber chicken
draw itself.

297
00:19:33,340 --> 00:19:37,070
And that one's going to be a really easy
one to do.

298
00:19:37,070 --> 00:19:38,418
So if we look at

299
00:19:38,418 --> 00:19:43,820
the final UML for our diagram from today's
lecture

300
00:19:43,820 --> 00:19:47,570
we see that we've added these methods down
here.

301
00:19:49,110 --> 00:19:53,650
And so we also have identified the fact
that to be able

302
00:19:53,650 --> 00:19:57,270
to draw we're going to need a sprite batch
to get passed in.

303
00:19:57,270 --> 00:20:00,640
So we can call the sprite batch dot draw
method.

304
00:20:00,640 --> 00:20:03,580
And to update, because there's

305
00:20:03,580 --> 00:20:06,310
both the velocity which needs the elapsed
game

306
00:20:06,310 --> 00:20:11,290
time and the click processing which needs
the mouse,

307
00:20:13,440 --> 00:20:19,250
we'll need both of those things.
Just like our roll method had a return

308
00:20:19,250 --> 00:20:25,880
type of void both of these methods also
have a return type of void.

309
00:20:25,880 --> 00:20:28,420
So we're not writing any methods in this
class

310
00:20:28,420 --> 00:20:31,910
that will actually return a value when we
call it.

311
00:20:34,060 --> 00:20:36,450
And that's all we're going to do for
today.

312
00:20:36,450 --> 00:20:38,810
We did all of our design work and we

313
00:20:38,810 --> 00:20:42,230
did our implementation work for the fields
and properties

314
00:20:42,230 --> 00:20:47,590
so we've got off to a great start on our
rubber chicken for the X and A game.

315
00:20:47,590 --> 00:20:53,180
And next time, we'll actually implement
both the constructor and the

316
00:20:53,180 --> 00:20:56,580
two methods that we need for the behaviors
of the rubber chicken.