<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Simple game sample, frustrating results - M5Flow]]></title><description><![CDATA[<p dir="auto">Hi</p>
<p dir="auto">I'm sure many have been through this.<br />
M5Flow blocks used for programming graphics and commands: testing if the interpreter is enough to assemble mid-fast interfaces.<br />
Example attached:<br />
Q any way to pass priority to the buttons' trigger and improve response?</p>
<p dir="auto">Kind regards</p>
<p dir="auto"><a href="https://github.com/ipodjupiter/M5Stack.git" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/ipodjupiter/M5Stack.git</a></p>
<p dir="auto">from m5stack import *<br />
from m5ui import *<br />
from uiflow import *</p>
<p dir="auto">setScreenColor(0x222222)</p>
<p dir="auto">circle0 = M5Circle(92, 65, 15, 0xe21414, 0xFFFFFF)<br />
rectangle1 = M5Rect(0, 220, 30, 15, 0xFFFFFF, 0x22f470)<br />
label0 = M5TextBox(30, 113, "Text1", lcd.FONT_Default,0xFFFFFF, rotate=0)<br />
label1 = M5TextBox(29, 145, "Text2", lcd.FONT_Default,0xFFFFFF, rotate=0)<br />
label2 = M5TextBox(187, 117, "Text3", lcd.FONT_Default,0xFFFFFF, rotate=0)<br />
label3 = M5TextBox(182, 155, "Text4", lcd.FONT_Default,0xFFFFFF, rotate=0)</p>
<p dir="auto">from numbers import Number<br />
import random<br />
import math</p>
<p dir="auto">pos = None<br />
circY = None<br />
circX = None<br />
destCircY = None<br />
destCircX = None</p>
<p dir="auto">def buttonA_wasPressed():<br />
global pos, circY, circX, destCircY, destCircX<br />
pos = (pos if isinstance(pos, Number) else 0) + -5<br />
if pos &lt; 0:<br />
pos = 0<br />
else:<br />
pos = pos<br />
pass<br />
btnA.wasPressed(buttonA_wasPressed)</p>
<p dir="auto">def buttonC_wasPressed():<br />
global pos, circY, circX, destCircY, destCircX<br />
pos = (pos if isinstance(pos, Number) else 0) + 5<br />
if pos &gt;= 320:<br />
pos = 320<br />
else:<br />
pos = pos<br />
pass<br />
btnC.wasPressed(buttonC_wasPressed)</p>
<p dir="auto">rectangle1.setPosition(150, 220)<br />
pos = 150<br />
circY = 0<br />
circX = 0<br />
circle0.setPosition(30, 30)<br />
while True:<br />
rectangle1.setPosition(x=pos)<br />
destCircY = random.randint(0, 200)<br />
destCircX = random.randint(0, 320)<br />
while math.fabs(circX - destCircX) &gt; 10 or math.fabs(circY - destCircY) &gt; 10:<br />
if destCircX - circX &gt; 0:<br />
circX = circX + 5<br />
else:<br />
circX = circX - 5<br />
if destCircY - circY &gt; 0:<br />
circY = circY + 5<br />
else:<br />
circY = circY - 5<br />
circle0.setPosition(circX, circY)<br />
wait_ms(5)<br />
wait_ms(2)</p>
]]></description><link>https://community.m5stack.com/topic/1912/simple-game-sample-frustrating-results-m5flow</link><generator>RSS for Node</generator><lastBuildDate>Thu, 30 Apr 2026 04:36:53 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/1912.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 29 Apr 2020 12:55:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Simple game sample, frustrating results - M5Flow on Fri, 01 May 2020 16:24:28 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ipodlux" aria-label="Profile: ipodlux">@<bdi>ipodlux</bdi></a> Found it!<br />
in order to compensate the slow reading of the interrupt I moved the reading in the loop. It less less classy that the external function but now it reacts as it should.</p>
]]></description><link>https://community.m5stack.com/post/8469</link><guid isPermaLink="true">https://community.m5stack.com/post/8469</guid><dc:creator><![CDATA[iPodLux]]></dc:creator><pubDate>Fri, 01 May 2020 16:24:28 GMT</pubDate></item></channel></rss>