🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Simple game sample, frustrating results - M5Flow

    Scheduled Pinned Locked Moved PROJECTS
    2 Posts 1 Posters 5.6k Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • I Offline
      iPodLux
      last edited by iPodLux

      Hi

      I'm sure many have been through this.
      M5Flow blocks used for programming graphics and commands: testing if the interpreter is enough to assemble mid-fast interfaces.
      Example attached:
      Q any way to pass priority to the buttons' trigger and improve response?

      Kind regards

      https://github.com/ipodjupiter/M5Stack.git

      from m5stack import *
      from m5ui import *
      from uiflow import *

      setScreenColor(0x222222)

      circle0 = M5Circle(92, 65, 15, 0xe21414, 0xFFFFFF)
      rectangle1 = M5Rect(0, 220, 30, 15, 0xFFFFFF, 0x22f470)
      label0 = M5TextBox(30, 113, "Text1", lcd.FONT_Default,0xFFFFFF, rotate=0)
      label1 = M5TextBox(29, 145, "Text2", lcd.FONT_Default,0xFFFFFF, rotate=0)
      label2 = M5TextBox(187, 117, "Text3", lcd.FONT_Default,0xFFFFFF, rotate=0)
      label3 = M5TextBox(182, 155, "Text4", lcd.FONT_Default,0xFFFFFF, rotate=0)

      from numbers import Number
      import random
      import math

      pos = None
      circY = None
      circX = None
      destCircY = None
      destCircX = None

      def buttonA_wasPressed():
      global pos, circY, circX, destCircY, destCircX
      pos = (pos if isinstance(pos, Number) else 0) + -5
      if pos < 0:
      pos = 0
      else:
      pos = pos
      pass
      btnA.wasPressed(buttonA_wasPressed)

      def buttonC_wasPressed():
      global pos, circY, circX, destCircY, destCircX
      pos = (pos if isinstance(pos, Number) else 0) + 5
      if pos >= 320:
      pos = 320
      else:
      pos = pos
      pass
      btnC.wasPressed(buttonC_wasPressed)

      rectangle1.setPosition(150, 220)
      pos = 150
      circY = 0
      circX = 0
      circle0.setPosition(30, 30)
      while True:
      rectangle1.setPosition(x=pos)
      destCircY = random.randint(0, 200)
      destCircX = random.randint(0, 320)
      while math.fabs(circX - destCircX) > 10 or math.fabs(circY - destCircY) > 10:
      if destCircX - circX > 0:
      circX = circX + 5
      else:
      circX = circX - 5
      if destCircY - circY > 0:
      circY = circY + 5
      else:
      circY = circY - 5
      circle0.setPosition(circX, circY)
      wait_ms(5)
      wait_ms(2)

      I 1 Reply Last reply Reply Quote 0
      • I Offline
        iPodLux @iPodLux
        last edited by

        @ipodlux Found it!
        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.

        1 Reply Last reply Reply Quote 1

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post