-
rex_noctis
I have recently been messing around with the
turtle
module on PC and have come up with a few handy programs. I then became curious about the possibilities on Pythonista. I am attempting to make a simple program where the title will move to where the user taps. Theonclick()
does not seem to work. I will include the code I was trying to use below. How would I make a program like this and is there any documentation on turtle in Pythonista (I couldn’t find any)?Code:
from turtle import * speed(0) screen = Screen() def moveTo(x, y): setpos(x, y) screen.onclick(moveTo) screen.listen()
-
rex_noctis
So I have been having a problem for a while.
I am trying to make a program that whilst running will listen for a key word (for example ‘Apple’) and then will activate a piece of code upon hearing it.
I have tried creating a loop that records 2 seconds of audio then performs speech recognition on it, but much of the time, the word is said during the speech recognition process and therefore is not picked up.
How can I get it so that it will keep listening and the only margin of error is the quality of the speech recognition? I can’t think of anything. -
rex_noctis
So long story short, I’m good at playing games with touch screen controls and I’m bad with an Xbox controller. However I like slot of Xbox games so this somewhat limits me. So I was wondering if there was some way I could write a programme to connect to my Xbox via Bluetooth and then use custom controls (possible made using
scene
module) to control it instead of the usual physical controller. I’ll divide this up into a few questions to make it a bit simpler. I know there is a sort of controller on the Xbox app but apparently that can’t be used with games.- Is there a module or other way to connect to more advanced devices via Bluetooth (the
cb
module says it’s only for basic Bluetooth devices)? - Would I be able to control the Xbox through this method without having to modify the Xbox in any way?
- If it’s looking good so far, what are some of the pieces of code I would need to use (quite specifically)?
Thanks in advance.
- Is there a module or other way to connect to more advanced devices via Bluetooth (the
-
rex_noctis
So I am working on a project with the
UI
module, with the end goal of having it published to the App Store. Is there any way to compile and publish the .py and .pyui files together to the App Store or would I have to redesign the entire project with thescene
module? -
-
rex_noctis
@cvp said:
@rex_noctis Did you try the 3 Australian voices?
speech: en-AU Objective-c: en-AU, Name: Catherine speech: en-AU Objective-c: en-AU, Name: Gordon speech: en-AU Objective-c: en-AU, Name: Karen```
How do I determine between those in the
speech.say()
line cause they’re allen-AU
-
rex_noctis
@cvp I have extensively read that post, it hasn’t helped.
-
rex_noctis
So I am building a text to speech program. It currently says text in the default Daniel Encanced voice. I want the program to say stuff in the Australian Male Siri voice. How would I do that? I have tried
speech.say(‘Hello’, ‘en-AU’)
but this uses a different Australian voice. Please help. -
-
rex_noctis
I just realised the error. It’s meant to be
Rect(self.player.position.x-12, self.player.position.y-12, 24, 24)
I forgot the.x
on the end of position. Thanks for making me notice it! -
rex_noctis
I am making a game. In the
def update(self):
bit I have the codeplayer_hitbox = Rect(self.player.position-12, self.player.position-12, 24, 24) if self.enemy1.frame.intersects(player_hitbox): self.gameOver()
However, when I run the game, there is this error:
Traceback (most recent call last): File "/var/containers/Bundle/Application/D2B5AEDE-2A6F-4263-8217-08037B4C2570/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/scene.py", line 199, in _draw self.update() File "/private/var/mobile/Containers/Shared/AppGroup/6311A336-2012-414A-9433-E66D7EBF131D/Pythonista3/Documents/impossibleGame.py", line 147, in update player_hitbox = Rect(self.player.position-12, self.player.position-12, 24, 24) TypeError: Unsupported operand type(s)
How can I get it so when the player’s hit box intersects enemy1’s frame, it runs
self.gameOver()
? -
rex_noctis
I don’t really know how to explain this but I’ll try.
I’m making a game usingscene
. I am using four buttons to control the movement of the player, however currently, if I hold down on the movement buttons, the character only moves one step in the given direction. The reason for this is because indef touch_began(self, touch):
I have only told it to move the player one step. I tried implementing a variable that changed depending on what button was pressed and then indef update(self):
telling it to move in whichever direction the variable (move
) specifies. When I try this, the buttons don’t even respond. How can I get it so the player (self.player
) moves in the direction of the button pressed until the user is no longer pressing the button?
Here is my game code at the moment (I have only programmed the up button intouch_began
):from scene import * import time class Game(Scene): def setup(self): self.background_color = '#ffffff' #Up button self.upCtrl = SpriteNode('2018-07-21 7.32.39 pm.png') self.upCtrl.x_scale = 100/2048 self.upCtrl.y_scale = 100/2048 self.add_child(self.upCtrl) self.upCtrl.position = (self.size.x/2), 175 #Left button self.leftCtrl = SpriteNode('2018-07-21 7.17.22 pm (1).png') self.leftCtrl.x_scale = 100/600 self.leftCtrl.y_scale = 100/600 self.add_child(self.leftCtrl) self.leftCtrl.position = (self.size.x/2)-100, 75 #downButton self.downCtrl = SpriteNode('2018-07-21 7.17.22 pm (2).png') self.downCtrl.x_scale = 100/600 self.downCtrl.y_scale = 100/600 self.add_child(self.downCtrl) self.downCtrl.position = self.size.x/2, 75 #Right button self.rightCtrl = SpriteNode('2018-07-21 7.17.22 pm (3).png') self.rightCtrl.x_scale = 100/600 self.rightCtrl.y_scale = 100/600 self.add_child(self.rightCtrl) self.rightCtrl.position = (self.size.x/2)+100, 75 #Game map self.gameMap = SpriteNode('2018-07-21 8.06.38 pm.png') self.gameMap.x_scale = 2 self.gameMap.y_scale = 2 self.add_child(self.gameMap) self.gameMap.position = self.size.x/2, (self.size.y/2)+100 #Player sprite self.player = SpriteNode('2018-07-21 9.05.27 pm.png') self.player.x_scale = 2 self.player.y_scale = 2 self.add_child(self.player) self.player.position = (self.size.w/2)-415, (self.size.h/2)+100 def touch_began(self, touch): touch_loc = touch.location if touch_loc in self.upCtrl.frame: self.player.position = self.player.position.x, self.player.position.y+5 run(Game(), LANDSCAPE, show_fps=True)```