Drawing with Pythonistas modules
midkin last edited by ccc
I 've been trying to create the Pong Game in Pythonista.
I have created the game in my PC using python's tkinter module.
However, I am having a difficulty in which library to use. Scene? Ui?
Till now I have tried:
import scene class TutoScene1(scene.Scene): def setup(self): self.background_color = 'green' self.item = scene.ShapeNode(scene.rect(0,0,0,0), color = 'red', position = (self.size.w / 2, self.size.h / 2), anchor_point = (0.5, 0.5), parent = self) def update(self): max_speed = 5 x, y, z = scene.gravity() pos = self.item.position pos.x = self.item.position.x + x * max_speed pos.y = self.item.position.y + y * max_speed self.item.position = pos scene.run(TutoScene1(), scene.PORTRAIT)
import scene import ui class TutoScene2(scene.Scene): def setup(self): self.background_color = 'black' self.paddle = ui.Path.rect(0, 0, 200, 50) self.ball = ui.Path.oval(100, 100, 400, 200) scene.run(TutoScene2(), scene.PORTRAIT)
In the first example dimensions don't work as they should (I get the same Rect no matter the x, y, width, height and in the 2nd example I don't know how to make things slow up (like give them colors etc)
abcabc last edited by
Here is an example pong program. I hope it helps. (It is not well tested. It is just for illustration.)