﻿1
00:00:02,210 --> 00:00:06,569
hello everyone this is part one on how

2
00:00:05,009 --> 00:00:08,849
to make a tower defense game and scratch

3
00:00:06,569 --> 00:00:10,710
in this tutorial I'll be creating the

4
00:00:08,849 --> 00:00:12,630
enemies as well as the paths for the

5
00:00:10,710 --> 00:00:14,280
enemies to follow now before we get

6
00:00:12,630 --> 00:00:16,320
started I just want to say that this

7
00:00:14,280 --> 00:00:17,910
tutorial series is a bit more on the

8
00:00:16,320 --> 00:00:20,010
advanced side because there will be

9
00:00:17,910 --> 00:00:22,020
cloning and lists involved but I will

10
00:00:20,010 --> 00:00:23,609
try to make it as simple as possible so

11
00:00:22,020 --> 00:00:25,230
that is not too difficult to follow and

12
00:00:23,609 --> 00:00:27,420
hopefully by the end of the series

13
00:00:25,230 --> 00:00:29,519
you'll better understand how this in

14
00:00:27,420 --> 00:00:32,099
cloning works and of course have a tower

15
00:00:29,519 --> 00:00:34,469
defense game anyways let's get started

16
00:00:32,099 --> 00:00:36,329
so first of course we need a path for

17
00:00:34,469 --> 00:00:37,890
the enemies to follow so I'm going to

18
00:00:36,329 --> 00:00:41,129
create one by first going to the stage

19
00:00:37,890 --> 00:00:43,440
and then going to backdrops and then to

20
00:00:41,129 --> 00:00:46,440
make the path I'm gonna first select the

21
00:00:43,440 --> 00:00:49,649
line tool and then drag it across the

22
00:00:46,440 --> 00:00:52,680
drawing window over here and I think I'm

23
00:00:49,649 --> 00:00:55,760
gonna make the path start from down over

24
00:00:52,680 --> 00:00:59,039
here and then end somewhere over here

25
00:00:55,760 --> 00:01:01,590
alright and then now I'm gonna use the

26
00:00:59,039 --> 00:01:04,080
reshape tool to click anywhere on the

27
00:01:01,590 --> 00:01:08,340
line to create more points and then that

28
00:01:04,080 --> 00:01:10,110
way I can create a curvy path so if I

29
00:01:08,340 --> 00:01:12,299
just drag the point then I can move it

30
00:01:10,110 --> 00:01:16,640
and then if I drag the handles then I

31
00:01:12,299 --> 00:01:16,640
can change the steepness of the curve

32
00:01:17,000 --> 00:01:22,970
[Applause]

33
00:01:18,430 --> 00:01:26,490
[Music]

34
00:01:22,970 --> 00:01:29,490
all right so now I have my path down and

35
00:01:26,490 --> 00:01:31,890
now I'm gonna select my path and then

36
00:01:29,490 --> 00:01:35,820
change this outline number right here to

37
00:01:31,890 --> 00:01:39,000
something like let's say 80 okay maybe

38
00:01:35,820 --> 00:01:41,700
90 all right cool so now the path is

39
00:01:39,000 --> 00:01:44,220
much wider and I think I'm going to also

40
00:01:41,700 --> 00:01:46,890
change the fill color of the path to

41
00:01:44,220 --> 00:01:50,009
something like a brown oops sorry I

42
00:01:46,890 --> 00:01:52,380
meant the outline color so I'm gonna

43
00:01:50,009 --> 00:02:00,600
change the outline color to a brown

44
00:01:52,380 --> 00:02:08,940
color so something like this okay a bit

45
00:02:00,600 --> 00:02:11,910
darker all right and then I think I also

46
00:02:08,940 --> 00:02:13,380
want to add a green background so I'm

47
00:02:11,910 --> 00:02:16,050
gonna select this rectangle tool and

48
00:02:13,380 --> 00:02:19,319
then draw it over my entire drawing area

49
00:02:16,050 --> 00:02:22,890
and then I'm gonna first take out the

50
00:02:19,319 --> 00:02:24,870
outline so I'm gonna click this and then

51
00:02:22,890 --> 00:02:28,230
for the fill I'm gonna make it a green

52
00:02:24,870 --> 00:02:31,739
color so it's gonna sort of look like

53
00:02:28,230 --> 00:02:33,660
grass all right and then I'm gonna

54
00:02:31,739 --> 00:02:36,360
select a rectangle and then click the

55
00:02:33,660 --> 00:02:39,000
backwards button right here and now we

56
00:02:36,360 --> 00:02:41,880
have sort of like a grass field and a

57
00:02:39,000 --> 00:02:45,390
dirt path and I think I'm going to

58
00:02:41,880 --> 00:02:46,620
change the colors a bit more so and now

59
00:02:45,390 --> 00:02:49,140
that we're done with the path let's

60
00:02:46,620 --> 00:02:52,799
begin creating our enemy so first off

61
00:02:49,140 --> 00:02:55,140
let's go to our cats bright and then I'm

62
00:02:52,799 --> 00:02:59,100
gonna go to costumes and delete all of

63
00:02:55,140 --> 00:03:00,900
the current costumes and now for the

64
00:02:59,100 --> 00:03:03,450
enemy I think I'm just gonna start with

65
00:03:00,900 --> 00:03:06,810
a simple circle so I'm gonna select a

66
00:03:03,450 --> 00:03:09,390
circle tool and then I am going to hold

67
00:03:06,810 --> 00:03:12,209
shift while pressing down to create a

68
00:03:09,390 --> 00:03:15,959
perfect circle and then I'm going to

69
00:03:12,209 --> 00:03:18,870
Center it all right and I think for the

70
00:03:15,959 --> 00:03:22,980
enemy I'll make it a orange color so

71
00:03:18,870 --> 00:03:28,739
something like this and for the outline

72
00:03:22,980 --> 00:03:33,750
I will have a brown outline so something

73
00:03:28,739 --> 00:03:37,170
like this all right cool and now we have

74
00:03:33,750 --> 00:03:40,230
our enemy so I'm going to first show the

75
00:03:37,170 --> 00:03:42,690
enemy alright and then I'm also going to

76
00:03:40,230 --> 00:03:47,510
name it enemy and then I'm gonna

77
00:03:42,690 --> 00:03:50,519
position it somewhere down here okay and

78
00:03:47,510 --> 00:03:54,500
they also think it's a bit too large so

79
00:03:50,519 --> 00:03:58,769
I'm gonna make a size something like 60

80
00:03:54,500 --> 00:04:00,420
and okay I think that looks fine so now

81
00:03:58,769 --> 00:04:02,790
of course the next thing I want to do is

82
00:04:00,420 --> 00:04:05,220
to make the enemy move and to make the

83
00:04:02,790 --> 00:04:07,769
enemy follow this curved path we have we

84
00:04:05,220 --> 00:04:10,290
are going to need an invisible line to

85
00:04:07,769 --> 00:04:12,750
guide the enemy along this path so to

86
00:04:10,290 --> 00:04:15,390
start let's go to the stage and copy our

87
00:04:12,750 --> 00:04:18,959
current path so I'm gonna select this

88
00:04:15,390 --> 00:04:22,530
and then ctrl C and then I'm going to

89
00:04:18,959 --> 00:04:26,700
create a new sprite so paint alright and

90
00:04:22,530 --> 00:04:29,520
then paste so ctrl V and now we have our

91
00:04:26,700 --> 00:04:32,159
second path so this is gonna be the line

92
00:04:29,520 --> 00:04:35,490
which the enemies follow so I'm going to

93
00:04:32,159 --> 00:04:38,039
select this and then I'm going to take

94
00:04:35,490 --> 00:04:40,050
out all the outline or actually I'll

95
00:04:38,039 --> 00:04:42,599
leave some in so I'll make the outline

96
00:04:40,050 --> 00:04:45,000
something small like six alright and

97
00:04:42,599 --> 00:04:47,640
then I'll also make the outline color a

98
00:04:45,000 --> 00:04:49,800
white color just to make it clear that

99
00:04:47,640 --> 00:04:51,750
this is the path the enemy follows and

100
00:04:49,800 --> 00:04:55,500
then I'm also going to go to the code

101
00:04:51,750 --> 00:04:58,200
and then go to motion and then drag a go

102
00:04:55,500 --> 00:05:01,229
to X Y block and I'm gonna change this

103
00:04:58,200 --> 00:05:04,050
to go to X 0 and y 0 all right

104
00:05:01,229 --> 00:05:06,630
and now your line should be directly on

105
00:05:04,050 --> 00:05:09,659
top of your path this is gonna be the

106
00:05:06,630 --> 00:05:11,849
line that guides the enemy I'm going to

107
00:05:09,659 --> 00:05:13,440
keep the line shown for now but we can

108
00:05:11,849 --> 00:05:15,930
hide it later once we're done coding the

109
00:05:13,440 --> 00:05:18,930
enemy movement now let's go to our enemy

110
00:05:15,930 --> 00:05:20,789
sprite and go to costumes and then I'm

111
00:05:18,930 --> 00:05:22,950
gonna create two detection boxes for the

112
00:05:20,789 --> 00:05:24,930
enemy so let's duplicate the enemy

113
00:05:22,950 --> 00:05:28,800
costume twice so right-click duplicate

114
00:05:24,930 --> 00:05:32,280
and then inside of the first costume I

115
00:05:28,800 --> 00:05:34,680
am going to create a rectangle so I'm

116
00:05:32,280 --> 00:05:37,650
gonna first choose a fill I'm gonna make

117
00:05:34,680 --> 00:05:40,050
a rectangle blue alright and for this

118
00:05:37,650 --> 00:05:44,490
rectangle I'm gonna have no outline so

119
00:05:40,050 --> 00:05:46,510
I'm gonna click this okay and now I'll

120
00:05:44,490 --> 00:05:50,110
draw a small rectangle like

121
00:05:46,510 --> 00:05:52,210
this and I am going to position this

122
00:05:50,110 --> 00:05:57,490
rectangle so that it's in front of the

123
00:05:52,210 --> 00:05:59,800
enemy so somewhere around here and in

124
00:05:57,490 --> 00:06:02,530
this case I am imagining that the enemy

125
00:05:59,800 --> 00:06:04,420
is facing towards the right and then I'm

126
00:06:02,530 --> 00:06:07,210
also going to move this rectangle

127
00:06:04,420 --> 00:06:10,990
slightly above the middle of the enemy

128
00:06:07,210 --> 00:06:12,780
so as you can see it's not here but it's

129
00:06:10,990 --> 00:06:15,940
slightly above the middle part so

130
00:06:12,780 --> 00:06:19,330
somewhere around here all right and then

131
00:06:15,940 --> 00:06:21,190
I'm going to delete the enemy image so

132
00:06:19,330 --> 00:06:23,410
now for the second detection box I'm

133
00:06:21,190 --> 00:06:26,590
going to copy the first rectangle and

134
00:06:23,410 --> 00:06:29,560
then go to costume two and then paste it

135
00:06:26,590 --> 00:06:31,780
and then I'm gonna make this a red color

136
00:06:29,560 --> 00:06:34,480
so go to fill and then change it to red

137
00:06:31,780 --> 00:06:36,520
and by the way these colors are not

138
00:06:34,480 --> 00:06:38,320
necessary but I'm just choosing two

139
00:06:36,520 --> 00:06:40,600
different colors to know which detection

140
00:06:38,320 --> 00:06:42,910
box is which anyways I'm now going to

141
00:06:40,600 --> 00:06:46,140
move it so that it's slightly below the

142
00:06:42,910 --> 00:06:48,970
middle of the enemy so right around here

143
00:06:46,140 --> 00:06:51,730
alright and then I'm going to delete the

144
00:06:48,970 --> 00:06:53,830
enemy image all right so now we have our

145
00:06:51,730 --> 00:06:56,350
two detection boxes for with the enemy

146
00:06:53,830 --> 00:06:57,970
like this and these are going to check

147
00:06:56,350 --> 00:07:00,040
if they're touching the white line and

148
00:06:57,970 --> 00:07:02,800
if they are then they are going to

149
00:07:00,040 --> 00:07:04,540
rotate the enemy back into place so that

150
00:07:02,800 --> 00:07:06,850
it's always following the white line and

151
00:07:04,540 --> 00:07:09,700
this way the enemy will follow the path

152
00:07:06,850 --> 00:07:12,430
and turn if necessary by the way I'm

153
00:07:09,700 --> 00:07:15,010
also going to copy and paste these

154
00:07:12,430 --> 00:07:17,890
detection boxes in the real enemy

155
00:07:15,010 --> 00:07:20,410
costume so that we can see how the line

156
00:07:17,890 --> 00:07:22,810
detection works alright cool so this is

157
00:07:20,410 --> 00:07:25,240
our enemy and these two are the line

158
00:07:22,810 --> 00:07:28,480
detection boxes so now let's go inside

159
00:07:25,240 --> 00:07:32,020
oakley code and then let's drag a win

160
00:07:28,480 --> 00:07:37,000
flag clicked then I'm going to show the

161
00:07:32,020 --> 00:07:40,320
sprite and then I'm gonna of course make

162
00:07:37,000 --> 00:07:45,070
the enemy start over here so that is

163
00:07:40,320 --> 00:07:46,750
negative 133 and Y negative 172 all

164
00:07:45,070 --> 00:07:49,330
right and then I'm also going to make

165
00:07:46,750 --> 00:07:51,700
the enemy point in the direction of the

166
00:07:49,330 --> 00:07:54,670
white line so as you can see right now

167
00:07:51,700 --> 00:07:57,340
the two detection boxes are not facing

168
00:07:54,670 --> 00:08:00,139
towards the white line so I have to drag

169
00:07:57,340 --> 00:08:04,060
a point in Direction block and then

170
00:08:00,139 --> 00:08:07,430
change this to point in direction zero

171
00:08:04,060 --> 00:08:09,740
alright and then I also am going to move

172
00:08:07,430 --> 00:08:14,629
the enemy a bit to the right

173
00:08:09,740 --> 00:08:17,060
so maybe negative 127 okay so now as you

174
00:08:14,629 --> 00:08:20,060
can see the white line is now perfectly

175
00:08:17,060 --> 00:08:22,189
in between d2 detection boxes and now

176
00:08:20,060 --> 00:08:24,949
let's go back and then when the flag is

177
00:08:22,189 --> 00:08:27,560
clicked I'm also going to switch costume

178
00:08:24,949 --> 00:08:30,770
to costume 3 so that is the enemy

179
00:08:27,560 --> 00:08:33,079
costume alright so now for the enemy

180
00:08:30,770 --> 00:08:35,510
movement I'm going to create a new block

181
00:08:33,079 --> 00:08:40,339
and then I'm gonna call this something

182
00:08:35,510 --> 00:08:43,699
like enemy movement alright and then

183
00:08:40,339 --> 00:08:46,160
click OK and now we are going to do all

184
00:08:43,699 --> 00:08:47,779
of the line detection code in here so

185
00:08:46,160 --> 00:08:50,000
first off we have to go to variables and

186
00:08:47,779 --> 00:08:52,220
then I'm going to create two new

187
00:08:50,000 --> 00:08:56,120
variables the first one is going to be

188
00:08:52,220 --> 00:08:58,880
movespeed so this is how fast the

189
00:08:56,120 --> 00:09:00,890
enemies will move and I will select for

190
00:08:58,880 --> 00:09:02,290
despite only so click this and then

191
00:09:00,890 --> 00:09:05,600
click OK

192
00:09:02,290 --> 00:09:07,430
alright and then for the next one I am

193
00:09:05,600 --> 00:09:10,339
going to create a variable called turn

194
00:09:07,430 --> 00:09:13,940
speed and then I will select for despite

195
00:09:10,339 --> 00:09:16,100
only and then I'll click OK alright so

196
00:09:13,940 --> 00:09:18,199
first off inside of the enemy movement

197
00:09:16,100 --> 00:09:21,949
block I am going to go to motion and

198
00:09:18,199 --> 00:09:24,199
then drag a move ten steps and then I'm

199
00:09:21,949 --> 00:09:27,620
gonna go to variables and drag a move

200
00:09:24,199 --> 00:09:29,870
move speed steps so under the wind I

201
00:09:27,620 --> 00:09:32,300
clicked I can set the move speed

202
00:09:29,870 --> 00:09:34,850
variables and turn speed variables to

203
00:09:32,300 --> 00:09:37,220
whatever I want so let's say if I have a

204
00:09:34,850 --> 00:09:39,649
move speed of like four and turn speed

205
00:09:37,220 --> 00:09:42,110
of eight then the enemy will move four

206
00:09:39,649 --> 00:09:44,750
steps and it will also turn eight

207
00:09:42,110 --> 00:09:46,970
degrees when we code in d rotation so

208
00:09:44,750 --> 00:09:48,860
now back inside of the enemy movement

209
00:09:46,970 --> 00:09:51,079
block I am going to first go to looks

210
00:09:48,860 --> 00:09:53,390
and then drag a switch costume to block

211
00:09:51,079 --> 00:09:57,230
and then I'm gonna change this to switch

212
00:09:53,390 --> 00:10:01,490
costume to costume one so this is the

213
00:09:57,230 --> 00:10:05,480
blue detection box so for this one we

214
00:10:01,490 --> 00:10:07,970
are going to check if the enemy is

215
00:10:05,480 --> 00:10:11,300
currently and they go to sensing

216
00:10:07,970 --> 00:10:13,940
touching the white line or sprite one

217
00:10:11,300 --> 00:10:16,690
then the enemy is going to

218
00:10:13,940 --> 00:10:20,570
turn to the left or counterclockwise

219
00:10:16,690 --> 00:10:22,940
turn speed degrees all right and then

220
00:10:20,570 --> 00:10:25,670
now for the other detection box we can

221
00:10:22,940 --> 00:10:28,430
just right click duplicate and then

222
00:10:25,670 --> 00:10:31,010
switch costume to costume two which is

223
00:10:28,430 --> 00:10:32,900
the red detection box and then it will

224
00:10:31,010 --> 00:10:36,770
also check if it's touching sprite one

225
00:10:32,900 --> 00:10:39,230
and if it is then the enemy will turn to

226
00:10:36,770 --> 00:10:42,470
the right or clockwise turn speed

227
00:10:39,230 --> 00:10:43,300
degrees all right and then at the very

228
00:10:42,470 --> 00:10:47,870
end

229
00:10:43,300 --> 00:10:49,790
let's switch costume to costume three so

230
00:10:47,870 --> 00:10:52,160
what happens is that all of these blocks

231
00:10:49,790 --> 00:10:54,800
should run immediately after one another

232
00:10:52,160 --> 00:10:56,840
so the detection box costumes are never

233
00:10:54,800 --> 00:10:58,670
going to show because the enemy always

234
00:10:56,840 --> 00:11:01,310
switches to the real costume at the end

235
00:10:58,670 --> 00:11:03,170
however the detection boxes will still

236
00:11:01,310 --> 00:11:04,370
do their job and the blue one will check

237
00:11:03,170 --> 00:11:07,220
when it turned left or counterclockwise

238
00:11:04,370 --> 00:11:09,920
and the red one will check when to turn

239
00:11:07,220 --> 00:11:12,440
right or clockwise so I think that

240
00:11:09,920 --> 00:11:14,840
should work and one last thing let's go

241
00:11:12,440 --> 00:11:18,470
to control drag a further loop put it

242
00:11:14,840 --> 00:11:20,960
after the wind flag clicked and then

243
00:11:18,470 --> 00:11:22,940
let's go to my blocks and drag the enemy

244
00:11:20,960 --> 00:11:26,810
movement block inside of the for loop

245
00:11:22,940 --> 00:11:29,480
all right cool so let's try it out if I

246
00:11:26,810 --> 00:11:31,280
click the green flag so as you can see

247
00:11:29,480 --> 00:11:34,070
the enemy is following the white line

248
00:11:31,280 --> 00:11:35,780
and the red and the blue detection boxes

249
00:11:34,070 --> 00:11:39,040
are preventing the enemy from going

250
00:11:35,780 --> 00:11:41,660
outside of the white line like so and

251
00:11:39,040 --> 00:11:43,630
also one thing to keep in mind is that

252
00:11:41,660 --> 00:11:46,460
this doesn't always work the first time

253
00:11:43,630 --> 00:11:49,430
for example like if I set the move speed

254
00:11:46,460 --> 00:11:51,380
to eight instead of four then the enemy

255
00:11:49,430 --> 00:11:53,450
is gonna move too fast and then the line

256
00:11:51,380 --> 00:11:55,550
detection might not always work as you

257
00:11:53,450 --> 00:11:57,680
can see it did not properly detect right

258
00:11:55,550 --> 00:11:59,750
there and then the enemy went out of the

259
00:11:57,680 --> 00:12:01,880
line so if your enemy movement does not

260
00:11:59,750 --> 00:12:04,010
work like if it goes out of the track or

261
00:12:01,880 --> 00:12:06,350
something there are several ways for you

262
00:12:04,010 --> 00:12:08,300
to check and see what's wrong so first

263
00:12:06,350 --> 00:12:11,240
off make sure the enemy is pointing in

264
00:12:08,300 --> 00:12:14,960
the right direction so your detection

265
00:12:11,240 --> 00:12:17,390
boxes over here should be on the two

266
00:12:14,960 --> 00:12:19,280
sides of the white line and if they

267
00:12:17,390 --> 00:12:22,190
aren't then you should rotate your enemy

268
00:12:19,280 --> 00:12:24,260
so that they are and secondly try

269
00:12:22,190 --> 00:12:26,630
creasing your enemy move speed or

270
00:12:24,260 --> 00:12:28,520
increasing your enemy turn speed

271
00:12:26,630 --> 00:12:30,260
and I would say having a turn speed of

272
00:12:28,520 --> 00:12:32,630
around double the amount of your move

273
00:12:30,260 --> 00:12:34,430
speed is a good number to have but you

274
00:12:32,630 --> 00:12:37,220
can play around with it so for example

275
00:12:34,430 --> 00:12:40,790
if I have a move speed of six I'm gonna

276
00:12:37,220 --> 00:12:44,000
try a turn speed of 12 and then if I try

277
00:12:40,790 --> 00:12:46,040
the enemy then as you can see it should

278
00:12:44,000 --> 00:12:50,630
work all right cool

279
00:12:46,040 --> 00:12:54,560
looks good all right nice so it worked

280
00:12:50,630 --> 00:12:56,870
let me try a move speed of 10 and turn

281
00:12:54,560 --> 00:13:02,120
speed of 20 it's not going to look as

282
00:12:56,870 --> 00:13:05,150
good but alright so that seemed to also

283
00:13:02,120 --> 00:13:08,720
work but I would suggest having a slower

284
00:13:05,150 --> 00:13:11,000
move speed and that way the enemy turns

285
00:13:08,720 --> 00:13:12,860
would look more smooth and if everything

286
00:13:11,000 --> 00:13:15,860
still does not work try making sure your

287
00:13:12,860 --> 00:13:18,320
line is smooth and try decreasing how

288
00:13:15,860 --> 00:13:19,940
much the track turns so make sure to not

289
00:13:18,320 --> 00:13:21,830
have any sharp edges or anything like

290
00:13:19,940 --> 00:13:23,930
that anyways now that we're done with

291
00:13:21,830 --> 00:13:27,200
the enemy movement we can now hide the

292
00:13:23,930 --> 00:13:30,110
white line so inside of these looks we

293
00:13:27,200 --> 00:13:33,320
can grab a set color effect 2-0 block

294
00:13:30,110 --> 00:13:37,250
and then I'm gonna change this to set

295
00:13:33,320 --> 00:13:39,170
ghost effect to 100 and pretty much this

296
00:13:37,250 --> 00:13:41,150
just makes the line invisible but it

297
00:13:39,170 --> 00:13:43,880
still allows the enemy to touch the line

298
00:13:41,150 --> 00:13:46,070
so I'm going to drag a 1 Phi clicked and

299
00:13:43,880 --> 00:13:48,500
then put it after everything all right

300
00:13:46,070 --> 00:13:51,790
and then I'm also going to go to looks

301
00:13:48,500 --> 00:13:54,560
and drag a show block just in case and

302
00:13:51,790 --> 00:13:57,380
now that should be fine and then for the

303
00:13:54,560 --> 00:14:00,800
enemies bright I am going to go to the

304
00:13:57,380 --> 00:14:03,620
costumes and take out the red and blue

305
00:14:00,800 --> 00:14:05,150
colliders in the third costume so the

306
00:14:03,620 --> 00:14:06,440
first costume is gonna have the blue

307
00:14:05,150 --> 00:14:08,120
Clyde err second one's gonna have the

308
00:14:06,440 --> 00:14:10,970
red one and then third one is going to

309
00:14:08,120 --> 00:14:13,840
have your actual enemy sprite all right

310
00:14:10,970 --> 00:14:19,340
so now if you try it again then

311
00:14:13,840 --> 00:14:22,280
everything should work as normal okay

312
00:14:19,340 --> 00:14:24,860
we have the enemy and then it's touching

313
00:14:22,280 --> 00:14:30,260
the white line but the line is not shown

314
00:14:24,860 --> 00:14:34,760
so alright and then it should complete

315
00:14:30,260 --> 00:14:36,830
the track okay cool so now of course we

316
00:14:34,760 --> 00:14:39,050
also want the enemy to hide once it

317
00:14:36,830 --> 00:14:40,220
touches the edge of the track so let's

318
00:14:39,050 --> 00:14:43,940
go to the code

319
00:14:40,220 --> 00:14:46,520
and then I'm going to drag another wind

320
00:14:43,940 --> 00:14:50,810
fly clicked and then I'm gonna go to

321
00:14:46,520 --> 00:14:52,550
control drag a forever loop and then

322
00:14:50,810 --> 00:14:55,700
before that four of a loop I am going to

323
00:14:52,550 --> 00:15:00,400
drag a weight until block and I'm going

324
00:14:55,700 --> 00:15:05,180
to check wait until not and then sensing

325
00:15:00,400 --> 00:15:08,750
touching and change this to edge alright

326
00:15:05,180 --> 00:15:11,900
and then inside of the Farva loop I am

327
00:15:08,750 --> 00:15:15,080
going to always check if and then

328
00:15:11,900 --> 00:15:18,860
duplicate this touching the edge then

329
00:15:15,080 --> 00:15:19,970
hide so go to looks and then hide all

330
00:15:18,860 --> 00:15:22,430
right cool

331
00:15:19,970 --> 00:15:24,740
so of course since the enemy is touching

332
00:15:22,430 --> 00:15:26,570
the edge of the screen when it spawns we

333
00:15:24,740 --> 00:15:28,640
are going to ignore that until it stops

334
00:15:26,570 --> 00:15:30,770
touching the edge and then once it

335
00:15:28,640 --> 00:15:32,840
touches the edge again that means the

336
00:15:30,770 --> 00:15:36,860
enemy left the track so we're going to

337
00:15:32,840 --> 00:15:40,580
hide it so let's try it out and now as

338
00:15:36,860 --> 00:15:43,700
you can see it should work so once it

339
00:15:40,580 --> 00:15:48,020
touches the edge over here then it

340
00:15:43,700 --> 00:15:55,040
should hide so almost there

341
00:15:48,020 --> 00:15:58,010
and it is hidden all right cool

342
00:15:55,040 --> 00:16:00,170
so now that we have one enemy down let's

343
00:15:58,010 --> 00:16:02,030
now create multiple enemies and this is

344
00:16:00,170 --> 00:16:04,820
actually pretty simple all we have to do

345
00:16:02,030 --> 00:16:07,930
is go to control and then drag a repeat

346
00:16:04,820 --> 00:16:10,640
loop and then in psychotherapy loop

347
00:16:07,930 --> 00:16:13,100
let's drag a create clone of myself and

348
00:16:10,640 --> 00:16:15,350
also a wait one seconds

349
00:16:13,100 --> 00:16:20,630
and then I'll change this to something

350
00:16:15,350 --> 00:16:22,880
like wait 0.2 seconds and then I will

351
00:16:20,630 --> 00:16:25,310
take away everything under this one flag

352
00:16:22,880 --> 00:16:28,250
clicked and then drag this under the

353
00:16:25,310 --> 00:16:30,680
wind I clicked and I am NOT going to

354
00:16:28,250 --> 00:16:33,260
show the original enemy sprite so I'm

355
00:16:30,680 --> 00:16:35,630
going to go to looks and then drag a

356
00:16:33,260 --> 00:16:39,290
hide block and put it right before they

357
00:16:35,630 --> 00:16:41,420
repeat ten all right and then now for

358
00:16:39,290 --> 00:16:43,490
this part we are going to put this under

359
00:16:41,420 --> 00:16:46,580
a when I start as a clone so let's go to

360
00:16:43,490 --> 00:16:49,730
control and then I'm going to drag a

361
00:16:46,580 --> 00:16:51,680
when a star is a clone and then I'm also

362
00:16:49,730 --> 00:16:54,110
going to replace this one if I clicked

363
00:16:51,680 --> 00:16:57,380
with a when I star is a clone

364
00:16:54,110 --> 00:16:58,040
and now everything should be fine so

365
00:16:57,380 --> 00:17:02,060
let's try it out

366
00:16:58,040 --> 00:17:04,429
all right here are our enemies and as

367
00:17:02,060 --> 00:17:07,579
you can see we have 10 enemies going

368
00:17:04,429 --> 00:17:11,500
around the track and they should

369
00:17:07,579 --> 00:17:11,500
disappear once they reach the end and

370
00:17:12,610 --> 00:17:18,290
all right cool

371
00:17:14,329 --> 00:17:20,660
and they do all right so I think I am

372
00:17:18,290 --> 00:17:23,030
going to increase the move speed of the

373
00:17:20,660 --> 00:17:26,569
enemies a bit so maybe from 3 to 4 and

374
00:17:23,030 --> 00:17:30,500
let me try the same turn speed of 6 cell

375
00:17:26,569 --> 00:17:34,940
let's try it out ok here are our enemies

376
00:17:30,500 --> 00:17:39,020
and I think a turn speed of 6 is working

377
00:17:34,940 --> 00:17:42,500
fine so I'll leave it at that and there

378
00:17:39,020 --> 00:17:44,660
we go alright cool so now we have a

379
00:17:42,500 --> 00:17:46,809
simple and very customizable enemy

380
00:17:44,660 --> 00:17:49,580
movement system along with our track

381
00:17:46,809 --> 00:17:51,110
anyways that's it for this tutorial if

382
00:17:49,580 --> 00:17:52,850
you enjoyed it then give it a thumbs up

383
00:17:51,110 --> 00:17:54,980
and subscribe to if you haven't already

384
00:17:52,850 --> 00:17:56,510
and the next tutorial I will begin

385
00:17:54,980 --> 00:17:58,700
creating some turrets to shoot the

386
00:17:56,510 --> 00:18:00,830
enemies by the way this project is

387
00:17:58,700 --> 00:18:01,610
shared on my scratcher file link is in

388
00:18:00,830 --> 00:18:06,190
the description below

389
00:18:01,610 --> 00:18:06,190
anyways that's for this video see ya

390
00:18:09,850 --> 00:18:13,030
[Music]


