<?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=Wall_Sensors</id>
	<title>Wall Sensors - История изменений</title>
	<link rel="self" type="application/atom+xml" href="http://digida.mgpu.ru/index.php?action=history&amp;feed=atom&amp;title=Wall_Sensors"/>
	<link rel="alternate" type="text/html" href="http://digida.mgpu.ru/index.php?title=Wall_Sensors&amp;action=history"/>
	<updated>2026-05-18T13:24:17Z</updated>
	<subtitle>История изменений этой страницы в вики</subtitle>
	<generator>MediaWiki 1.44.0</generator>
	<entry>
		<id>http://digida.mgpu.ru/index.php?title=Wall_Sensors&amp;diff=1870&amp;oldid=prev</id>
		<title>Patarakin: 1 версия импортирована</title>
		<link rel="alternate" type="text/html" href="http://digida.mgpu.ru/index.php?title=Wall_Sensors&amp;diff=1870&amp;oldid=prev"/>
		<updated>2022-07-21T08:33:18Z</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;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;Версия от 11:33, 21 июля 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&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;!-- diff cache key digida:diff:1.41:old-1869:rev-1870 --&gt;
&lt;/table&gt;</summary>
		<author><name>Patarakin</name></author>
	</entry>
	<entry>
		<id>http://digida.mgpu.ru/index.php?title=Wall_Sensors&amp;diff=1869&amp;oldid=prev</id>
		<title>scratch&gt;Jvvg в 21:46, 6 июня 2022</title>
		<link rel="alternate" type="text/html" href="http://digida.mgpu.ru/index.php?title=Wall_Sensors&amp;diff=1869&amp;oldid=prev"/>
		<updated>2022-06-06T21:46:51Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Wall sensors&amp;#039;&amp;#039;&amp;#039; are commonly used in [[Platformer|platform games]]. They consist of four lines, two vertical and two horizontal, fixed to the left, right, top, and bottom of the player [[sprite]]. When a sensor detects contact with a wall, a message broadcasted will tell the player sprite to invert its current velocity, making the wall deflect the player sprite.&lt;br /&gt;
&lt;br /&gt;
== Programming a Sensor Set ==&lt;br /&gt;
It is vital that the player sprite uses [[velocity]] to enhance the realism of movement (including gravitational velocity) before making wall sensors.&lt;br /&gt;
&lt;br /&gt;
# Duplicate the player sprite.&lt;br /&gt;
# Erase all [[script]]s and [[costume]]s (except the idle costume).&lt;br /&gt;
# Edit the idle costume. Draw four lines, each a different color, on each side (left, right, top, and bottom) of the costume.&lt;br /&gt;
# Erase the original costume. The result should look like four colored lines.&lt;br /&gt;
# Program the following scripts on the wall sensor sprite:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--[[File:Wall Sensors 1.png]]--&amp;gt;&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
forever&lt;br /&gt;
if &amp;lt;color [#000000] is touching [#FFFFFF]?&amp;gt; then&lt;br /&gt;
broadcast ( bump v)&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The white should be the color of the sensor(left, right, top, or bottom).&lt;br /&gt;
&lt;br /&gt;
The black should be the color of the wall, or whatever the player can not move through.&lt;br /&gt;
&lt;br /&gt;
The parentheses() should be replaced with whichever direction it is detecting. (up, down, left or right)&lt;br /&gt;
&lt;br /&gt;
Do this four times, once for each sensor.&lt;br /&gt;
&lt;br /&gt;
Program the following scripts on the player sprite:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--[[File:Wall Sensor 2.png]]--&amp;gt;&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when I receive [left bump v]&lt;br /&gt;
set [x velocity v] to (10)&lt;br /&gt;
&lt;br /&gt;
when I receive [right bump v]&lt;br /&gt;
set [x velocity v] to (-10)&lt;br /&gt;
&lt;br /&gt;
when I receive [up bump v]&lt;br /&gt;
set [y velocity v] to (10)&lt;br /&gt;
&lt;br /&gt;
when I receive [down bump v]&lt;br /&gt;
set [gravity v] to (0)&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another simple method without broadcasts would be to simply move the&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
set [gravity v] to (0)&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
to replace the broadcast [[blocks]]. This only works if the [[variable]]s are global and can be accessed by any sprite.&lt;br /&gt;
&lt;br /&gt;
If done correctly, the player sprite should bounce off walls and stop when it jumps and hits a platform&amp;#039;s bottom.&lt;br /&gt;
&lt;br /&gt;
=== How it Works ===&lt;br /&gt;
This method uses colors to detect if a sprite is hitting a wall, and from which direction, and then reacts accordingly.  It also makes use of the fact that the rendering speed is not instantaneous, allowing for the sprite to switch to its &amp;quot;sensing costume&amp;quot; and back with not noticeable effects to the user.&lt;br /&gt;
&lt;br /&gt;
== Without the Sensor Set ==&lt;br /&gt;
This third method does not use a &amp;quot;sensing costume&amp;quot;, but demands that a constant costume is used for all sensing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;scratchblocks&amp;gt;&lt;br /&gt;
when gf clicked&lt;br /&gt;
set [y-vel v] to (0)&lt;br /&gt;
forever&lt;br /&gt;
if &amp;lt;key (right arrow v) pressed?&amp;gt; then&lt;br /&gt;
change x by (3)&lt;br /&gt;
if &amp;lt;touching (wall v)?&amp;gt; then&lt;br /&gt;
change x by (-3)&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
if &amp;lt;key (left arrow v) pressed?&amp;gt; then&lt;br /&gt;
change x by (-3)&lt;br /&gt;
if &amp;lt;touching (wall v)?&amp;gt; then&lt;br /&gt;
change x by (3)&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
change [y-vel v] by (-0.1) // gravity&lt;br /&gt;
change y by (y-vel)&lt;br /&gt;
if &amp;lt;touching (wall v)?&amp;gt; then // vertical collision&lt;br /&gt;
set [y-vel v] to ((-0.5)*(y-vel))&lt;br /&gt;
change y by (y-vel)&lt;br /&gt;
if &amp;lt;touching (wall v)?&amp;gt; then&lt;br /&gt;
change y by (y-vel)&lt;br /&gt;
end&lt;br /&gt;
if &amp;lt;&amp;lt;(y-vel) &amp;gt; (0)&amp;gt; and &amp;lt;key (up arrow v) pressed?&amp;gt;&amp;gt; then // jump&lt;br /&gt;
set [y-vel v] to (5)&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/scratchblocks&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How it Works ===&lt;br /&gt;
This method works around color sensing by checking if it is touching a wall after essentially every movement along one dimension.  For instance, if the sprite moves right, it then checks if it is touching a wall.  If it is touching a wall, it knows that it must be a wall on its right.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
You may have problems with sensing walls properly. If you do, make sure that:&lt;br /&gt;
&lt;br /&gt;
* You have all of the proper variables.&lt;br /&gt;
* Your left-moving script changes the x velocity variable by a negative number, and that your right-moving one changes it by a positive number.&lt;br /&gt;
* Your jumping script changes the y velocity variable by a positive number.&lt;br /&gt;
* If you have multiple ground colors (only in the top layer of pixels, where the player sprite lands), repeat step 5 and program four multiples of the following script, each one representing each sensor.&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting Tutorials]]&lt;br /&gt;
[[Category:Game Design Tutorials]]&lt;/div&gt;</summary>
		<author><name>scratch&gt;Jvvg</name></author>
	</entry>
</feed>