<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://pico8wiki.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=37.203.240.25</id>
	<title>Pico-8 Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://pico8wiki.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=37.203.240.25"/>
	<link rel="alternate" type="text/html" href="http://pico8wiki.com/index.php?title=Special:Contributions/37.203.240.25"/>
	<updated>2026-12-03T01:43:00Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.1</generator>
	<entry>
		<id>http://pico8wiki.com/index.php?title=Update&amp;diff=9358</id>
		<title>Update</title>
		<link rel="alternate" type="text/html" href="http://pico8wiki.com/index.php?title=Update&amp;diff=9358"/>
		<updated>2021-10-24T00:49:21Z</updated>

		<summary type="html">&lt;p&gt;37.203.240.25: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The first part of a [[GameLoop|game loop]] is normally an &#039;&#039;update&#039;&#039;.  In PICO-8, this is done with either an &amp;lt;code&amp;gt;_update()&amp;lt;/code&amp;gt; function, for 30fps games, or &amp;lt;code&amp;gt;_update60()&amp;lt;/code&amp;gt; for 60fps games. &lt;br /&gt;
&lt;br /&gt;
If a cartridge&#039;s source code includes both an &amp;lt;code&amp;gt;_update()&amp;lt;/code&amp;gt; function and a &amp;lt;code&amp;gt;_draw()&amp;lt;/code&amp;gt; function, then PICO-8 will attempt to call these functions once for each animation frame, at a rate of 30 frames per second for &amp;lt;code&amp;gt;_update()&amp;lt;/code&amp;gt; or 60 frames per second with with &amp;lt;code&amp;gt;_update60()&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You define this function in your game&#039;s source code. It takes no arguments.&lt;br /&gt;
&lt;br /&gt;
The intended purpose of &amp;lt;code&amp;gt;_update()&amp;lt;/code&amp;gt; is to test for user inputs (button presses), perform all of the calculations to advance the state of the game, and update the game&#039;s data structures with the results. For example, you might compare the state of variables to see if the player&#039;s avatar is near an item during &amp;lt;code&amp;gt;_update()&amp;lt;/code&amp;gt;. Typically, this function does not update the display, though it may initiate sound effects and music.&lt;br /&gt;
&lt;br /&gt;
See the entry on the [[GameLoop|game loop]].&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
player_x=64&lt;br /&gt;
player_y=100&lt;br /&gt;
&lt;br /&gt;
function _update()&lt;br /&gt;
  if(btn(0)) then player_x-=1 end&lt;br /&gt;
  if(btn(1)) then player_x+=1 end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[GameLoop|game loop]]&lt;br /&gt;
* &amp;lt;code&amp;gt;[[Init|_init()]]&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;[[Draw|_draw()]]&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;[[Music|music()]]&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;[[Sfx|sfx()]]&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;[[Stat|&amp;lt;code&amp;gt;stat()]]&amp;lt;/code&amp;gt;&lt;br /&gt;
[[Category:Reference]]&lt;br /&gt;
[[Category:API]]&lt;/div&gt;</summary>
		<author><name>37.203.240.25</name></author>
	</entry>
</feed>