<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
	<id>http://digida.mgpu.ru/index.php?action=history&amp;feed=atom&amp;title=How_to_Make_a_Tower_Defense_Game</id>
	<title>How to Make a Tower Defense Game - История изменений</title>
	<link rel="self" type="application/atom+xml" href="http://digida.mgpu.ru/index.php?action=history&amp;feed=atom&amp;title=How_to_Make_a_Tower_Defense_Game"/>
	<link rel="alternate" type="text/html" href="http://digida.mgpu.ru/index.php?title=How_to_Make_a_Tower_Defense_Game&amp;action=history"/>
	<updated>2026-05-06T17:04:37Z</updated>
	<subtitle>История изменений этой страницы в вики</subtitle>
	<generator>MediaWiki 1.44.0</generator>
	<entry>
		<id>http://digida.mgpu.ru/index.php?title=How_to_Make_a_Tower_Defense_Game&amp;diff=6102&amp;oldid=prev</id>
		<title>Patarakin: /* Creating a Main Menu */</title>
		<link rel="alternate" type="text/html" href="http://digida.mgpu.ru/index.php?title=How_to_Make_a_Tower_Defense_Game&amp;diff=6102&amp;oldid=prev"/>
		<updated>2022-11-25T19:12:24Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Creating a Main Menu&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Предыдущая версия&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Версия от 22:12, 25 ноября 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l17&quot;&gt;Строка 17:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Строка 17:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;If a main menu is desired (which is often more professional), a simple button can do. Assume the button is as follows:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;If a main menu is desired (which is often more professional), a simple button can do. Assume the button is as follows:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[File:TD Play.png|center]]&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;A simple button like this can be created in the Scratch [[Paint Editor]]. Along with a button, a menu typically has a background. The background can be an image created in the [[Stage]].&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;A simple button like this can be created in the Scratch [[Paint Editor]]. Along with a button, a menu typically has a background. The background can be an image created in the [[Stage]].&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key digida:diff:1.41:old-6101:rev-6102:php=table --&gt;
&lt;/table&gt;</summary>
		<author><name>Patarakin</name></author>
	</entry>
	<entry>
		<id>http://digida.mgpu.ru/index.php?title=How_to_Make_a_Tower_Defense_Game&amp;diff=6101&amp;oldid=prev</id>
		<title>Patarakin в 19:12, 25 ноября 2022</title>
		<link rel="alternate" type="text/html" href="http://digida.mgpu.ru/index.php?title=How_to_Make_a_Tower_Defense_Game&amp;diff=6101&amp;oldid=prev"/>
		<updated>2022-11-25T19:12:02Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Предыдущая версия&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Версия от 22:12, 25 ноября 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Строка 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Строка 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;NotUseful&lt;/del&gt;|&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Delete?&lt;/del&gt;|&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;date&lt;/del&gt;=&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;January 2018}}&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Scripting Tutorials&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;{{outdated&lt;/del&gt;|&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Does not work&lt;/del&gt;|&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;date&lt;/del&gt;=&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;December 2019&lt;/del&gt;}}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Description=Как сделать игру по защите города&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Field_of_knowledge&lt;/ins&gt;=&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Информатика&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Возрастная категория=10&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Environment&lt;/ins&gt;=&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Scratch&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Tower defense [[project]]s&amp;#039;&amp;#039;&amp;#039; are games where towers aim at enemies and try to destroy them. They are often hard to make, as they need advanced [[cloning]], aiming, and tower building.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Tower defense [[project]]s&amp;#039;&amp;#039;&amp;#039; are games where towers aim at enemies and try to destroy them. They are often hard to make, as they need advanced [[cloning]], aiming, and tower building.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Patarakin</name></author>
	</entry>
	<entry>
		<id>http://digida.mgpu.ru/index.php?title=How_to_Make_a_Tower_Defense_Game&amp;diff=1680&amp;oldid=prev</id>
		<title>Patarakin: 1 версия импортирована</title>
		<link rel="alternate" type="text/html" href="http://digida.mgpu.ru/index.php?title=How_to_Make_a_Tower_Defense_Game&amp;diff=1680&amp;oldid=prev"/>
		<updated>2022-07-21T08:33:14Z</updated>

		<summary type="html">&lt;p&gt;1 версия импортирована&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Предыдущая версия&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Версия от 11:33, 21 июля 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Patarakin</name></author>
	</entry>
	<entry>
		<id>http://digida.mgpu.ru/index.php?title=How_to_Make_a_Tower_Defense_Game&amp;diff=1679&amp;oldid=prev</id>
		<title>scratch&gt;TheTrillion: Minor thing.</title>
		<link rel="alternate" type="text/html" href="http://digida.mgpu.ru/index.php?title=How_to_Make_a_Tower_Defense_Game&amp;diff=1679&amp;oldid=prev"/>
		<updated>2021-05-17T21:38:21Z</updated>

		<summary type="html">&lt;p&gt;Minor thing.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{NotUseful|Delete?|date=January 2018}}&lt;br /&gt;
{{outdated|Does not work|date=December 2019}}&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Tower defense [[project]]s&amp;#039;&amp;#039;&amp;#039; are games where towers aim at enemies and try to destroy them. They are often hard to make, as they need advanced [[cloning]], aiming, and tower building.&lt;br /&gt;
&lt;br /&gt;
Tower defense games have taken an incline in popularity due to [[Scratch 2.0]]&amp;#039;s cloning features. Cloning is beneficial for a tower defense game because it allows multiple of the same tower, projectile, or target to be generated. This tutorial explains how to create a tower defense project from scratch. For this tutorial, assume the following:&lt;br /&gt;
* Towers are placed and fire at enemies&lt;br /&gt;
* Towers always fire at the front enemy&lt;br /&gt;
&lt;br /&gt;
==Planning Out==&lt;br /&gt;
Getting all or much of the artwork done prior to programming is helpful at times because it allows visualization of exactly how the game is desired to run. For example, the enemies have to be programmed to move along the proper path, which cannot be done until the map is created and the path visualized. Other factors should be taken into consideration such as if a main menu is in place.&lt;br /&gt;
&lt;br /&gt;
==Creating a Main Menu==&lt;br /&gt;
If a main menu is desired (which is often more professional), a simple button can do. Assume the button is as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:TD Play.png|center]]&lt;br /&gt;
&lt;br /&gt;
A simple button like this can be created in the Scratch [[Paint Editor]]. Along with a button, a menu typically has a background. The background can be an image created in the [[Stage]].&lt;br /&gt;
&lt;br /&gt;
===Programming===&lt;br /&gt;
To program the main menu, simply add the following script to the button:&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when gf clicked&lt;br /&gt;
switch backdrop to (Main Menu v) // sets the Stage&amp;#039;s backdrop&lt;br /&gt;
show // make sure the button is positioned in a good location&lt;br /&gt;
&lt;br /&gt;
when this sprite clicked&lt;br /&gt;
hide&lt;br /&gt;
broadcast (play v) // triggers the game to begin&lt;br /&gt;
switch backdrop to (game v)&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Structure of Enemies==&lt;br /&gt;
Assuming the enemies have multiple layers to break down, the enemies have to have multiple costumes. One enemy sprite can be used for every enemy that will be present when the game runs due to cloning. In the [[Costume Pane]], organize the costumes of the enemy so they are in sequential order of layers. This helps with the proper transition in the [[script]]ing of the project.&lt;br /&gt;
&lt;br /&gt;
==Starting Rounds==&lt;br /&gt;
When the game begins, the round should not immediately begin; typically there is a start button in which one has time to assemble towers before clicking. Inside the start button, the following script can be placed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when I receive [play v]&lt;br /&gt;
show&lt;br /&gt;
&lt;br /&gt;
when this sprite clicked&lt;br /&gt;
set [running v] to [true] // variable that tells if the round is in progress&lt;br /&gt;
hide&lt;br /&gt;
wait until &amp;lt;(running) = [false]&amp;gt; // wait until the round finishes&lt;br /&gt;
show // show again so the next round can be begun by clicking the button&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
When a round begins, the enemies need to be generated. For the enemy generation, the following script can be placed inside the enemy sprite. However, first assume the following:&lt;br /&gt;
* &amp;quot;waits&amp;quot; is a [[list]] that determines how long the wait is before the next enemy is generated&lt;br /&gt;
* &amp;quot;types&amp;quot; is a list that tells what costume the enemy begins at when it is generated. A higher costume makes a stronger enemy with more layers.&lt;br /&gt;
The boulder generation is encoded into lists, which is a part of efficient programming. Each item in the &amp;quot;waits&amp;quot; list is associated with the corresponding item in the &amp;quot;types&amp;quot; list. For example, if item 1 of &amp;quot;waits&amp;quot; is 4, then the enemy sprite would wait 4 seconds before creating an enemy with the [[Costume Number (value)|costume #]] stored in item 1 of &amp;quot;types&amp;quot;. Furthermore, each round is separated by a blank list item in each list. The following script generates the enemies constantly and pauses between rounds:&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when I receive [play v]&lt;br /&gt;
set [i v] to (0)&lt;br /&gt;
forever&lt;br /&gt;
wait until &amp;lt;(running) = [true]&amp;gt;&lt;br /&gt;
repeat until &amp;lt;(item (i) of [types v]) = []&amp;gt; // generate until blank list item detected&lt;br /&gt;
change [i v] by (1)&lt;br /&gt;
wait (item (i) of [waits v]) secs&lt;br /&gt;
switch costume to (item (i) of [types v])&lt;br /&gt;
change [amountOfBoulders v] by (1)&lt;br /&gt;
create clone of (myself v)&lt;br /&gt;
end&lt;br /&gt;
wait until &amp;lt;(amountOfBoulders) = [0]&amp;gt; // it must wait for the map to clear&lt;br /&gt;
set [running v] to [false]&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Programming Enemies==&lt;br /&gt;
All the enemy clones have a very simple method of determining which is in the front. There are four [[variable]]s associated with the leading enemy:&lt;br /&gt;
* &amp;lt;sb&amp;gt;(progress)&amp;lt;/sb&amp;gt;&lt;br /&gt;
* &amp;lt;sb&amp;gt;(lead progress)&amp;lt;/sb&amp;gt;&lt;br /&gt;
* &amp;lt;sb&amp;gt;(lead x)&amp;lt;/sb&amp;gt;&lt;br /&gt;
* &amp;lt;sb&amp;gt;(lead y)&amp;lt;/sb&amp;gt;&lt;br /&gt;
The only private variable above is &amp;quot;progress&amp;quot;. Each enemy has its own progress it records. When an enemy is generated, it starts with zero progress. Every pixel it moves along the path, its progress increases by 1. Make a block called &amp;quot;change y by () and update&amp;quot; that makes the sprite move &amp;#039;&amp;#039;&amp;#039;and&amp;#039;&amp;#039;&amp;#039; increase its progress. Every enemy constantly checks if it&amp;#039;s progress is greater than the &amp;quot;lead progress&amp;quot; global variable. If an enemy&amp;#039;s private progress is greater than the global lead progress, it sets the lead progress to its own, showing that it is in the lead. In addition, the leading enemy sets &amp;quot;lead x&amp;quot; and &amp;quot;lead y&amp;quot; to its x and y position to identify to the towers where the leading clone actually is.&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when I start as a clone&lt;br /&gt;
go to x: (200) y: (180) // starting position&lt;br /&gt;
repeat until &amp;lt;(y position) &amp;lt; (0)&amp;gt; // until it reaches the center&lt;br /&gt;
change y by (-2) and update // custom block; speed may be modified mathematically according to costume #&lt;br /&gt;
change [progress v] by (2)&lt;br /&gt;
check&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
define change y by (pixels) and update&lt;br /&gt;
change y by (pixels)&lt;br /&gt;
change [progress v] by (pixels)&lt;br /&gt;
&lt;br /&gt;
define check&lt;br /&gt;
if &amp;lt;touching (projectile v)?&amp;gt; then&lt;br /&gt;
if &amp;lt;(costume [number v]) = [1]&amp;gt; then&lt;br /&gt;
if &amp;lt;(progress) = (lead progress)&amp;gt; then&lt;br /&gt;
set [lead progress v] to [0]&lt;br /&gt;
set [lead x v] to [0]&lt;br /&gt;
set [lead y v] to [0]&lt;br /&gt;
end&lt;br /&gt;
delete this clone&lt;br /&gt;
end&lt;br /&gt;
switch costume to ((costume [number v]) - (1))&lt;br /&gt;
if &amp;lt;(progress) &amp;gt; (lead progress)&amp;gt; then&lt;br /&gt;
set [lead progress v] to (progress)&lt;br /&gt;
set [lead x v] to (x position)&lt;br /&gt;
set [lead y v] to (y position)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The tower defense game is complete.&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting Tutorials|Tower Defense Game]]&lt;/div&gt;</summary>
		<author><name>scratch&gt;TheTrillion</name></author>
	</entry>
</feed>