<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://miniscript.org/w/index.php?action=history&amp;feed=atom&amp;title=How_to_do_simple_physics</id>
	<title>How to do simple physics - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://miniscript.org/w/index.php?action=history&amp;feed=atom&amp;title=How_to_do_simple_physics"/>
	<link rel="alternate" type="text/html" href="http://miniscript.org/w/index.php?title=How_to_do_simple_physics&amp;action=history"/>
	<updated>2026-11-04T04:15:10Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.0</generator>
	<entry>
		<id>http://miniscript.org/w/index.php?title=How_to_do_simple_physics&amp;diff=519&amp;oldid=prev</id>
		<title>JoeStrout at 20:46, 4 May 2020</title>
		<link rel="alternate" type="text/html" href="http://miniscript.org/w/index.php?title=How_to_do_simple_physics&amp;diff=519&amp;oldid=prev"/>
		<updated>2020-05-04T20:46:26Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&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;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 20:46, 4 May 2020&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-l52&quot; &gt;Line 52:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 52:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;For another example, see the &amp;#039;&amp;#039;&amp;#039;flappyBat&amp;#039;&amp;#039;&amp;#039; demo in &amp;#039;&amp;#039;&amp;#039;/sys/demo/&amp;#039;&amp;#039;&amp;#039;.&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;For another example, see the &amp;#039;&amp;#039;&amp;#039;flappyBat&amp;#039;&amp;#039;&amp;#039; demo in &amp;#039;&amp;#039;&amp;#039;/sys/demo/&amp;#039;&amp;#039;&amp;#039;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; 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;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; 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;[[Category:Mini Micro]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; 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;[[Category:How To]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wiki:diff::1.12:old-518:rev-519 --&gt;
&lt;/table&gt;</summary>
		<author><name>JoeStrout</name></author>
		
	</entry>
	<entry>
		<id>http://miniscript.org/w/index.php?title=How_to_do_simple_physics&amp;diff=518&amp;oldid=prev</id>
		<title>JoeStrout at 16:37, 4 May 2020</title>
		<link rel="alternate" type="text/html" href="http://miniscript.org/w/index.php?title=How_to_do_simple_physics&amp;diff=518&amp;oldid=prev"/>
		<updated>2020-05-04T16:37:20Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&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;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 16:37, 4 May 2020&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-l49&quot; &gt;Line 49:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 49:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;# When &amp;lt;c&amp;gt;self.y &amp;lt; 32&amp;lt;/c&amp;gt; (the object hits the ground), instead of setting &amp;lt;c&amp;gt;self.vy&amp;lt;/c&amp;gt; to zero, what if you set it to &amp;lt;c&amp;gt;abs(self.vy)&amp;lt;/c&amp;gt; (i.e. make it positive)?&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;# When &amp;lt;c&amp;gt;self.y &amp;lt; 32&amp;lt;/c&amp;gt; (the object hits the ground), instead of setting &amp;lt;c&amp;gt;self.vy&amp;lt;/c&amp;gt; to zero, what if you set it to &amp;lt;c&amp;gt;abs(self.vy)&amp;lt;/c&amp;gt; (i.e. make it positive)?&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;# Try adding a thruster you can control, by adding this to the &amp;quot;update velocity&amp;quot; section: &amp;lt;c&amp;gt;if key.pressed(&amp;quot;space&amp;quot;) then self.vy = self.vy + 500*dt&amp;lt;/c&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;# Try adding a thruster you can control, by adding this to the &amp;quot;update velocity&amp;quot; section: &amp;lt;c&amp;gt;if key.pressed(&amp;quot;space&amp;quot;) then self.vy = self.vy + 500*dt&amp;lt;/c&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; 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;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; 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;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; 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;For another example, see the &amp;#039;&amp;#039;&amp;#039;flappyBat&amp;#039;&amp;#039;&amp;#039; demo in &amp;#039;&amp;#039;&amp;#039;/sys/demo/&amp;#039;&amp;#039;&amp;#039;.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wiki:diff::1.12:old-517:rev-518 --&gt;
&lt;/table&gt;</summary>
		<author><name>JoeStrout</name></author>
		
	</entry>
	<entry>
		<id>http://miniscript.org/w/index.php?title=How_to_do_simple_physics&amp;diff=517&amp;oldid=prev</id>
		<title>JoeStrout at 15:54, 4 May 2020</title>
		<link rel="alternate" type="text/html" href="http://miniscript.org/w/index.php?title=How_to_do_simple_physics&amp;diff=517&amp;oldid=prev"/>
		<updated>2020-05-04T15:54:32Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&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;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 15:54, 4 May 2020&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;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; 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;Games often need simple Newtonian physics to make things move in a believable manner.  That basically means, objects have inertia and tend to stay in motion once they&amp;#039;re in motion, affected by forces like gravity.  Examples include the ship and rocks in &amp;#039;&amp;#039;Asteroids&amp;#039;&amp;#039;, the projectiles in any &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;ballistic &lt;/del&gt;game, and even the characters in a platformer.&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; 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;Games often need simple Newtonian physics to make things move in a believable manner.  That basically means, objects have inertia and tend to stay in motion once they&amp;#039;re in motion, affected by forces like gravity.  Examples include the ship and rocks in &amp;#039;&amp;#039;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[https://en.wikipedia.org/wiki/Asteroids_(video_game) &lt;/ins&gt;Asteroids&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;]&lt;/ins&gt;&amp;#039;&amp;#039;, the projectiles in any &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[https://en.wikipedia.org/wiki/Artillery_game artillery &lt;/ins&gt;game&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;]&lt;/ins&gt;, and even the characters in a &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[https://en.wikipedia.org/wiki/Platform_game &lt;/ins&gt;platformer&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;]&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;Fortunately, simple physics are easy to do!  The key concept is: in addition to the object&amp;#039;s position, you must also keep track of its velocity.  This is normally done by adding two new properties, &amp;lt;c&amp;gt;vx&amp;lt;/c&amp;gt; and &amp;lt;c&amp;gt;vy&amp;lt;/c&amp;gt;, to your object.&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; 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;Fortunately, simple physics are easy to do!  The key concept is: in addition to the object&amp;#039;s position, you must also keep track of its velocity.  This is normally done by adding two new properties, &amp;lt;c&amp;gt;vx&amp;lt;/c&amp;gt; and &amp;lt;c&amp;gt;vy&amp;lt;/c&amp;gt;, to your object.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wiki:diff::1.12:old-516:rev-517 --&gt;
&lt;/table&gt;</summary>
		<author><name>JoeStrout</name></author>
		
	</entry>
	<entry>
		<id>http://miniscript.org/w/index.php?title=How_to_do_simple_physics&amp;diff=516&amp;oldid=prev</id>
		<title>JoeStrout: Created page with &quot;Games often need simple Newtonian physics to make things move in a believable manner.  That basically means, objects have inertia and tend to stay in motion once they&#039;re in mo...&quot;</title>
		<link rel="alternate" type="text/html" href="http://miniscript.org/w/index.php?title=How_to_do_simple_physics&amp;diff=516&amp;oldid=prev"/>
		<updated>2020-05-04T15:50:13Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;Games often need simple Newtonian physics to make things move in a believable manner.  That basically means, objects have inertia and tend to stay in motion once they&amp;#039;re in mo...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Games often need simple Newtonian physics to make things move in a believable manner.  That basically means, objects have inertia and tend to stay in motion once they&amp;#039;re in motion, affected by forces like gravity.  Examples include the ship and rocks in &amp;#039;&amp;#039;Asteroids&amp;#039;&amp;#039;, the projectiles in any ballistic game, and even the characters in a platformer.&lt;br /&gt;
&lt;br /&gt;
Fortunately, simple physics are easy to do!  The key concept is: in addition to the object&amp;#039;s position, you must also keep track of its velocity.  This is normally done by adding two new properties, &amp;lt;c&amp;gt;vx&amp;lt;/c&amp;gt; and &amp;lt;c&amp;gt;vy&amp;lt;/c&amp;gt;, to your object.&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;vx&amp;#039;&amp;#039;&amp;#039; is the object&amp;#039;s &amp;#039;&amp;#039;&amp;#039;horizontal velocity&amp;#039;&amp;#039;&amp;#039;: how much its x position changes per second.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;vy&amp;#039;&amp;#039;&amp;#039; is the object&amp;#039;s &amp;#039;&amp;#039;&amp;#039;vertical velocity&amp;#039;&amp;#039;&amp;#039;: how much its y position changes per second.&lt;br /&gt;
&lt;br /&gt;
If we were updating the position of our object once per second, we could just add &amp;lt;c&amp;gt;vx&amp;lt;/c&amp;gt; to its &amp;lt;c&amp;gt;x&amp;lt;/c&amp;gt; position, and &amp;lt;c&amp;gt;vy&amp;lt;/c&amp;gt; to its &amp;lt;c&amp;gt;y&amp;lt;/c&amp;gt; position.  But usually we&amp;#039;re updating the screen much faster than that (typically 60 frames per second).  The time step (usually called &amp;lt;c&amp;gt;dt&amp;lt;/c&amp;gt;) is much smaller than 1 second, so the object won&amp;#039;t move as far on each step.  We accomplish this by simply multiplying &amp;lt;c&amp;gt;vx&amp;lt;/c&amp;gt; and &amp;lt;c&amp;gt;vy&amp;lt;/c&amp;gt; by &amp;lt;c&amp;gt;dt&amp;lt;/c&amp;gt;, before adding them to &amp;lt;c&amp;gt;x&amp;lt;/c&amp;gt; and &amp;lt;c&amp;gt;y&amp;lt;/c&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&lt;br /&gt;
The code below loads a sprite in the center of the screen, initially stationary.  Then it falls due to gravity, until it hits the bottom of the screen.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ms&amp;gt;clear&lt;br /&gt;
gravity = 100  // acceleration, in pixels/sec^2&lt;br /&gt;
&lt;br /&gt;
obj = new Sprite&lt;br /&gt;
obj.image = file.loadImage(&amp;quot;/sys/pics/Block.png&amp;quot;)&lt;br /&gt;
display(4).sprites.push obj&lt;br /&gt;
obj.x = 480&lt;br /&gt;
obj.y = 320&lt;br /&gt;
obj.vx = 0&lt;br /&gt;
obj.vy = 0&lt;br /&gt;
&lt;br /&gt;
obj.update = function(dt=0.016)&lt;br /&gt;
	// update velocity (applying gravity)&lt;br /&gt;
	self.vy = self.vy - gravity * dt&lt;br /&gt;
&lt;br /&gt;
	// update position (applying velocity)&lt;br /&gt;
	self.x = self.x + self.vx * dt&lt;br /&gt;
	self.y = self.y + self.vy * dt&lt;br /&gt;
&lt;br /&gt;
	// apply any limits, collision checks, etc.&lt;br /&gt;
	if self.y &amp;lt; 32 then&lt;br /&gt;
		self.y = 32&lt;br /&gt;
		self.vy = 0&lt;br /&gt;
		self.vx = floor(self.vx / 2)&lt;br /&gt;
	end if&lt;br /&gt;
end function&lt;br /&gt;
&lt;br /&gt;
while true  // press control-C to exit&lt;br /&gt;
	obj.update&lt;br /&gt;
	yield&lt;br /&gt;
end while&amp;lt;/ms&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Things to try&amp;#039;&amp;#039;&amp;#039;: &lt;br /&gt;
&lt;br /&gt;
# Change the initial values of &amp;lt;c&amp;gt;vx&amp;lt;/c&amp;gt; and &amp;lt;c&amp;gt;vy&amp;lt;/c&amp;gt; to something other than zero.  What happens?  &lt;br /&gt;
# When &amp;lt;c&amp;gt;self.y &amp;lt; 32&amp;lt;/c&amp;gt; (the object hits the ground), instead of setting &amp;lt;c&amp;gt;self.vy&amp;lt;/c&amp;gt; to zero, what if you set it to &amp;lt;c&amp;gt;abs(self.vy)&amp;lt;/c&amp;gt; (i.e. make it positive)?&lt;br /&gt;
# Try adding a thruster you can control, by adding this to the &amp;quot;update velocity&amp;quot; section: &amp;lt;c&amp;gt;if key.pressed(&amp;quot;space&amp;quot;) then self.vy = self.vy + 500*dt&amp;lt;/c&amp;gt;&lt;/div&gt;</summary>
		<author><name>JoeStrout</name></author>
		
	</entry>
</feed>