omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular
    1. Home
    2. Pythonistapro777

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    • Profile
    • Following 5
    • Followers 0
    • Topics 43
    • Posts 101
    • Best 3
    • Controversial 0
    • Groups 0

    Pythonistapro777

    @Pythonistapro777

    3
    Reputation
    1416
    Profile views
    101
    Posts
    0
    Followers
    5
    Following
    Joined Last Online

    Pythonistapro777 Unfollow Follow

    Best posts made by Pythonistapro777

    • RE: Pythonista alternatives for Android

      @Phuket2 I agree on the emulator comment, it wouldn't be ideal especially on the way i like to program during bus rides etc.
      Also, I looked through an old forum post about 5 minues ago and @omz mentioned an app called Kivy. I'm about to test it out for myself with a game i made a while back but it looks very promising :D
      If it doesn't work I'll look up the minimum requirements you mentioned

      posted in Pythonista
      Pythonistapro777
      Pythonistapro777
    • Agar.io

      I'm pretty much finished with the basic agar.io, but there is a slight problem. When the bot/player eats a cell I added an append for a new cell to be formed, but they are formed outside the bounds, this is because of the setup but I'm sure I'll find a fix for this - it's also now on Github.
      https://github.com/Pythonistapro777/Python-Scripts/blob/master/Agar.io
      @ccc @Webmaster4o @Cethric @dgelessus @JonB
      Thanks for all the help!

      posted in Pythonista
      Pythonistapro777
      Pythonistapro777
    • RE: Help with variable glitch

      Lol, yea. I get what they mean. I don't really put what I've tried on here 'cause I didn't it would really help but I'll work on everything. Also, I'm 14 - so bear with me.

      posted in Pythonista
      Pythonistapro777
      Pythonistapro777

    Latest posts made by Pythonistapro777

    • Help with intersetion between line and rect

      So, I'm working on my new project which is a game that there are two balls. One red, and one blue. You must draw a line to prevent them from touching.
      I have gotten the balls, and bouncing to work and I just got the lines to work.
      I just need help or ideas on how to get the balls bounce off the line.
      I can use a similar code to the one I used for the edges of the screen but I'm thinking there might be issues since the line wont be horizontal or vertical. They might be diagonal.
      Any ideas are welcome!

      import random, scene
      from scene import *
      
      class Particle(object):
      	def __init__(self, wh):
      		self.w = wh.w
      		self.h = wh.h
      		self.xblue = random.randint(0, self.w)
      		self.yblue = random.randint(0, self.h)
      	
      		self.vxblue = 10
      		self.vyblue = 10
      		
      		self.xred = random.randint(0, self.w)
      		self.yred = random.randint(0, self.h)
      		
      		self.vxred = 10
      		self.vyred = 10
      		
      		self.blueball = Rect(self.xblue, self.yblue, self.w/6, self.w/6)
      		self.redball = Rect(self.xred, self.yred, self.w/6, self.w/6)
      		
      		
      	def update(self):
      		self.xblue += self.vxblue
      		self.yblue += self.vyblue
      		
      		if self.xblue > self.w-100:
      			self.xblue = self.w-100
      			self.vxblue *= -1
      		if self.xblue < 0:
      			self.xblue = 0
      			self.vxblue *= -1
      		if self.yblue > self.h-100:
      			self.yblue = self.h-100
      			self.vyblue *= -1
      		if self.yblue < 0:
      			self.yblue = 0
      			self.vyblue *= -1
      			
      			
      			
      		self.xred += self.vxred
      		self.yred += self.vyred
      		
      		if self.xred > self.w-100:
      			self.xred = self.w-100
      			self.vxred *= -1
      		if self.xred < 0:
      			self.xred = 0
      			self.vxred *= -1
      		if self.yred > self.h-100:
      			self.yred = self.h-100
      			self.vyred *= -1
      		if self.yred < 0:
      			self.yred = 0
      			self.vyred *= -1
      			
      			
      		self.blueball = Rect(self.xblue, self.yblue, self.w/6, self.w/6)
      		self.redball = Rect(self.xred, self.yred, self.w/6, self.w/6)
      			
      	
      	def draw(self):
      		fill('#3547ff')
      		ellipse(*self.blueball)
      		fill('#ff0b0b')
      		ellipse(*self.redball)
      		if self.blueball.intersects(self.redball):
      				print('yay')
      	
      		
      class MyScene(Scene):
      	def setup(self):
      		self.particles = []
      		self.particles.append(Particle(self.size))
      		self.line = []
      		
      	def touch_began(self, touch):
      		self.pposx = touch.location.x
      		self.pposy = touch.location.y
      
      	def touch_moved(self, touch):
      		self.x = touch.location.x
      		self.y = touch.location.y
      		x = touch.location.x
      		y = touch.location.y
      		self.line = Rect(self.pposx, self.pposy, self.x, self.y)
      		
      		
      	def draw(self):
      		background(0, 0, 0)
      		for p in self.particles:
      			p.update()
      			p.draw()
      		stroke(1, 1, 1)
      		stroke_weight(7)
      		line(*self.line)
      	
      		
      run(MyScene(), PORTRAIT)
      
      posted in Pythonista
      Pythonistapro777
      Pythonistapro777
    • RE: How to draw lines using touch_began/touch_moved/touch_ended

      Also, just an additional question while I'm here:
      If I decided that I want to take THIS code and compile it into an API. Do you think it would be better to use UI?
      And if so, do you think turning it into a UI will be easy when I'm done or is it better to start over and write the code as a UI.

      Thanks in advance!

      posted in Pythonista
      Pythonistapro777
      Pythonistapro777
    • RE: Pythonista alternatives for Android

      @Phuket2 I agree on the emulator comment, it wouldn't be ideal especially on the way i like to program during bus rides etc.
      Also, I looked through an old forum post about 5 minues ago and @omz mentioned an app called Kivy. I'm about to test it out for myself with a game i made a while back but it looks very promising :D
      If it doesn't work I'll look up the minimum requirements you mentioned

      posted in Pythonista
      Pythonistapro777
      Pythonistapro777
    • Pythonista alternatives for Android

      HI
      I've been off the Pythonista Forum for about 10 months because I did get an android phone and since then I've been unable to use Pythonista. I would have gotten an IOS emulator on my PC but I couldn't find any (if any of you know some please let me know).
      Again, I've been off this app for 10 months so I've probably missed a lot; but do you guys think Pyhtonista will be coming to Android?
      If not - do any of you know any alternatives LIKE Pythonista that I can run on android. I'm asking this because on Android you can run basic commands but nothing complicated like Scenes or UI,which I mostly use.
      IF you guys are aware of any please let me know :D

      @ccc @Webmaster4o @dgelessus @Phuket2 @Cethric @JonB
      I tagged you guys since I remembered you from my last time online.

      posted in Pythonista
      Pythonistapro777
      Pythonistapro777
    • Django

      Later on in the school year, we will be uploading python games/apps that we make using Django. I'm just creating this post to know whether or not anything I make with scenes, etc. on pythonista will be comparable with making it web-based on Django.

      Teacher said I shouldn't get ahead of myself, but it's too late for that. :D

      Thanks in advance!

      posted in Pythonista
      Pythonistapro777
      Pythonistapro777
    • Agar.io

      I'm pretty much finished with the basic agar.io, but there is a slight problem. When the bot/player eats a cell I added an append for a new cell to be formed, but they are formed outside the bounds, this is because of the setup but I'm sure I'll find a fix for this - it's also now on Github.
      https://github.com/Pythonistapro777/Python-Scripts/blob/master/Agar.io
      @ccc @Webmaster4o @Cethric @dgelessus @JonB
      Thanks for all the help!

      posted in Pythonista
      Pythonistapro777
      Pythonistapro777
    • Help with intersects()

      I created bounds for the game, and they seem to be moving and working as they should. But the player intersects the line it shouldn't go past it. For some of the boundtop line, it woks fine - but it also goes through. This happens for all the lines. Could someone please point out what I did wrong? I tried changing the variables used in making the line to a limit number but it wouldn't work and this is my last option.

      Here's the code:

      from scene import *
      from random import *
      
      class Particle(object):
      	def __init__(self, wh):
      		self.w = wh.w
      		self.h = wh.h
      		self.x = randint(self.w*-1, self.w)
      		self.y = randint(self.h*-1, self.h)
      		self.colour = Color(random(), random(), random())
      		
      		self.cells=Rect(self.x, self.y, 5, 5)
      		
      		self.lw=self.w*-1
      		self.rw=self.w
      		self.bh=self.h*-1
      		self.th=self.h
      		self.boundleft=Rect(self.lw, self.bh, self.lw, self.th)
      		self.boundtop=Rect(self.lw, self.th, self.rw, self.th)
      		self.boundright=Rect(self.rw, self.bh, self.rw, self.th)
      		self.boundbottom=Rect(self.lw, self.bh, self.rw, self.bh)
      
      	def update(self):
      		self.cells=Rect(self.x, self.y, 5, 5)
      		self.boundleft=Rect(self.lw, self.bh, self.lw, self.th)
      		self.boundtop=Rect(self.lw, self.th, self.rw, self.th)
      		self.boundright=Rect(self.rw, self.bh, self.rw, self.th)
      		self.boundbottom=Rect(self.lw, self.bh, self.rw, self.bh)
      
      	def draw(self):
      		stroke(0,0,0)
      		stroke_weight(4)
      		line(*self.boundleft)
      		line(*self.boundtop)
      		line(*self.boundright)
      		line(*self.boundbottom)
      		fill(*self.colour)
      		stroke(*self.colour)
      		ellipse(*self.cells)
      
      class Intro(Scene):
      	def setup(self):
      		global count
      		count=0
      		global psize
      		psize=8
      		plocx=240
      		plocy=160
      		self.player = Rect(plocx, plocy, 20, 20)
      		self.colour = Color(random(), random(), random())
      		self.particles = []
      		for p in xrange(10):
      			self.particles.append(Particle(self.size))
      
      	def touch_began(self, touch):
      		global x1
      		global y1
      		x1=touch.location.x
      		y1=touch.location.y
      
      
      	def touch_moved(self, touch):
      		global x
      		global y
      		x=touch.location.x
      		y=touch.location.y
      		global count
      		count = 1
      
      	def movecells(self):
      		global x
      		global x1
      		global y
      		global y1
      		for p in self.particles:
      			if x1 > x and not p.boundleft.intersects(self.player):
      				p.x += 1.5
      				p.lw += 1.5
      				p.rw += 1.5
      			if x1 < x and not p.boundright.intersects(self.player):
      				p.x += -1.5
      				p.lw += -1.5
      				p.rw += -1.5
      			if y1 > y and not p.boundbottom.intersects(self.player):
      				p.y += 1.5
      				p.bh += 1.5
      				p.th += 1.5
      			if y1 < y and not p.boundtop.intersects(self.player):
      				p.y += -1.5
      				p.bh += -1.5
      				p.th += -1.5
      
      	def draw(self):
      		global count
      		if count == 1:
      			self.movecells()
      		global psize
      		background(0.00, 0.05, 0.20)
      		for p in self.particles:
      			p.update()
      			p.draw()
      			plocx=p.w/2-psize/2
      			plocy=p.h/2-psize/2
      			if self.player.intersects(p.cells):
      				self.newpsize=psize+0.2*10
      				psize=self.newpsize
      				self.particles.remove(p)
      		self.player = Rect(plocx, plocy, psize, psize)
      		ellipse(*self.player)
      
      run(Intro(), LANDSCAPE)
      

      Thanks in advance!

      P.s I know I'm not supposed to post this onto this forum but on stack overflow, etc - no one was able to help me, probably because they don't have pythonista or don't use it as much as the people on this forum do. Just bear with me for this post.
      @ccc @Cethric @dgelessus @Webmaster4o

      posted in Pythonista
      Pythonistapro777
      Pythonistapro777
    • RE: Why isn't my script running correctly? [SOLVED]

      @ccc @Webmaster4o @dgelessus @Phuket2 @Cethric

      posted in Pythonista
      Pythonistapro777
      Pythonistapro777
    • RE: Why isn't my script running correctly? [SOLVED]

      Then I put those 2 together:

      from scene import *
      from random import *
      class Particle(object):
              def __init__(self, wh):
                      self.w = wh.w
                      self.h = wh.h
                      self.x = randint(0, self.w)
                      self.y = randint(0, self.h)
                      self.vx = 0
                      self.vy = 0
                      self.colour = Color(random(), random(), random())
                      self.cells=Rect(self.x, self.y, 5, 5)
                      cells=self.cells
      
              def update(self):
                      self.x += self.vx
                      self.y += self.vy
                      if self.x > self.w:
                              self.x = self.w
                              self.vx *= -1
                      if self.x < 0:
                              self.x = 0
                              self.vx *= -1
                      if self.y > self.h:
                              self.y = self.h
                              self.vy *= -1
                      if self.y < 0:
                              self.y = 0
                              self.vy *= -1
      
              def draw(self):
                      fill(*self.colour)
                      ellipse(*self.cells)
      
      class Intro(Scene):
              def setup(self):
                      self.psize=13
                      global plocx
                      global plocy
                      plocx=240
                      plocy=160
                      self.player = Rect(plocx, plocy, 20, 20)
                      self.colour = Color(random(), random(), random())
      
                      self.particles = []
                      for p in range(100):
                              self.particles.append(Particle(self.size))
      
              def touch_began(self, touch):
                      global x1
                      global y1
                      x1=touch.location.x
                      y1=touch.location.y
      
      
              def touch_moved(self, touch):
                      global plocx
                      global plocy
                      global newplocx
                      global newplocy
                      x=touch.location.x
                      y=touch.location.y
      
                      for p in self.particles:
                              if x1 > x:
                                      p.vx = 1
                                      subx=(x-x1)/4
                                      newplocx=plocx+subx
                              if x1 < x:
                                      p.vx = -1
                                      addx=(x-x1)/4
                                      newplocx=plocx+addx
                              if y1 > y:
                                      p.vy = 1
                                      suby=(y-y1)/4
                                      newplocy=plocy+suby
                              if y1 < y:
                                      p.vy = -1
                                      addy=(y-y1)/4
                                      newplocy=plocy+addy
                              if x1 == x:
                                      p.vx = 0
                              if y1 == y:
                                      p.vy = 0
      
                      xmin=215
                      xmax=265
                      ymin=140
                      ymax=190
      
                      while xmax > plocx and newplocx > plocx:
                              plocx = plocx + 1
                              self.player = Rect(plocx, plocy, 16, 16)
      
                      while xmin < plocx and newplocx < plocx:
                              plocx = plocx - 1
                              self.player = Rect(plocx, plocy, 16, 16)
      
                      while ymax > plocy and newplocy > plocy:
                              plocy = plocy + 1
                              self.player = Rect(plocx, plocy, 16, 16)
      
                      while ymin < plocy and newplocy < plocy:
                              plocy = plocy - 1
                              self.player = Rect(plocx, plocy, 16, 16)
      
              def touch_ended(self, touch):
                      for p in self.particles:
                              p.vx = 0
                              p.vy = 0
      
              def draw(self):
                      background(0, 0.05, 0.2)
                      self.player = Rect(plocx, plocy, self.psize, self.psize)
                      for p in self.particles:
                              p.update()
                              p.draw()
                              cells = p.cells
                              if self.player.intersects(cells):
                                      self.newpsize=self.psize+0.2
                                      self.psize=self.newpsize
                                      self.particles.remove(p)
                      ellipse(*self.player)
      
      run(Intro(), LANDSCAPE)
      

      But it won't move the cells.
      Could someone please help me with what I have done wrong, because I can't seem to figure it out.

      Thanks in advance!

      Also, it wouldn't let me post the whole thing because it was marked as "spam" by akismet.com. Sorry if it caused any inconvinience. Furthermore, sorry I've been asking loads of questions on the forum, but this and maybe one or two more, till I'm finnished with Agar.io clone. :D

      posted in Pythonista
      Pythonistapro777
      Pythonistapro777
    • Why isn't my script running correctly? [SOLVED]

      First I have this script, that works fine:

      from scene import *
      from random import *
      class Particle(object):
              def __init__(self, wh):
                      self.w = wh.w
                      self.h = wh.h
                      self.x = randint(0, self.w)
                      self.y = randint(0, self.h)
                      self.vx = randint(-10, 20)
                      self.vy = randint(-10, 20)
                      self.colour = Color(random(), random(), random())
                      self.cells=Rect(self.x, self.y, 5, 5)
                      cells=self.cells
      
              def update(self):
                      self.x += self.vx
                      self.y += self.vy
                      self.vx *= 0
                      self.vy *= 0
                      if self.x > self.w:
                              self.x = self.w
                              self.vx *= -1
                      if self.x < 0:
                              self.x = 0
                              self.vx *= -1
                      if self.y > self.h:
                              self.y = self.h
                              self.vy *= -1
                      if self.y < 0:
                              self.y = 0
                              self.vy *= -1
      
              def draw(self):
                      fill(*self.colour)
                      ellipse(*self.cells)
      
      class Intro(Scene):
              def setup(self):
                      self.psize=13
                      global plocx
                      global plocy
                      plocx=240
                      plocy=160
                      self.player = Rect(plocx, plocy, 20, 20)
                      self.colour = Color(random(), random(), random())
      
                      self.particles = []
                      for p in range(100):
                              self.particles.append(Particle(self.size))
      
              def touch_began(self, touch):
                      global x1
                      global y1
                      x1=touch.location.x
                      y1=touch.location.y
      
      
              def touch_moved(self, touch):
                      global plocx
                      global plocy
                      global newplocx
                      global newplocy
                      x=touch.location.x
                      y=touch.location.y
                      if x > x1:
                              addx=(x-x1)/4
                              newplocx=plocx+addx
      
                      if x < x1:
                              subx=(x-x1)/4
                              newplocx=plocx+subx
      
                      if y > y1:
                              addy=(y-y1)/4
                              newplocy=plocy+addy
      
                      if y < y1:
                              suby=(y-y1)/4
                              newplocy=plocy+suby
      
                      xmin=215
                      xmax=265
                      ymin=140
                      ymax=190
      
                      while xmax > plocx and newplocx > plocx:
                              plocx = plocx + 1
                              self.player = Rect(plocx, plocy, 16, 16)
      
                      while xmin < plocx and newplocx < plocx:
                              plocx = plocx - 1
                              self.player = Rect(plocx, plocy, 16, 16)
      
                      while ymax > plocy and newplocy > plocy:
                              plocy = plocy + 1
                              self.player = Rect(plocx, plocy, 16, 16)
      
                      while ymin < plocy and newplocy < plocy:
                              plocy = plocy - 1
                              self.player = Rect(plocx, plocy, 16, 16)
      
              def draw(self):
                      background(0, 0.05, 0.2)
                      self.player = Rect(plocx, plocy, self.psize, self.psize)
                      for p in self.particles:
                              p.update()
                              p.draw()
                              cells = p.cells
                              if self.player.intersects(cells):
                                      self.newpsize=self.psize+0.2
                                      self.psize=self.newpsize
                                      self.particles.remove(p)
                      ellipse(*self.player)
      
      run(Intro(), LANDSCAPE)
      

      The main script for agar.io

      Then the script for moving the cells:

      from scene import *
      from random import *
      
      class Particle(object):
              def __init__(self, wh):
                      self.w = wh.w
                      self.h = wh.h
                      self.x = randint(0, self.w)
                      self.y = randint(0, self.h)
                      self.vx = 0
                      self.vy = 0
                      self.colour = Color(random(), random(), random())
      
              def update(self):
                      self.x += self.vx
                      self.y += self.vy
                      if self.x > self.w:
                              self.x = self.w
                              self.vx *= -1
                      if self.x < 0:
                              self.x = 0
                              self.vx *= -1
                      if self.y > self.h:
                              self.y = self.h
                              self.vy *= -1
                      if self.y < 0:
                              self.y = 0
                              self.vy *= -1
      
              def draw(self):
                      fill(*self.colour)
                      rect(self.x, self.y, 8, 8)
      
      class Intro(Scene):
              def setup(self):
                      self.particles = []
                      for p in xrange(100):
                              self.particles.append(Particle(self.size))
      
              def draw(self):
                      background(0.00, 0.05, 0.20)
                      for p in self.particles:
                              p.update()
                              p.draw()
      
              def touch_began(self, touch):
                      global x1
                      global y1
                      x1=touch.location.x
                      y1=touch.location.y
      
      
              def touch_moved(self, touch):
                      x=touch.location.x
                      y=touch.location.y
      
                      for p in self.particles:
                              if x1 > x:
                                      p.vx = 1
                              if x1 < x:
                                      p.vx = -1
                              if y1 > y:
                                      p.vy = 1
                              if y1 < y:
                                      p.vy = -1
                              if x1 == x:
                                      p.vx = 0
                              if y1 == y:
                                      p.vy = 0
      
              def touch_ended(self, touch):
                      for p in self.particles:
                              p.vx = 0
                              p.vy = 0
      
      run(Intro())
      
      posted in Pythonista
      Pythonistapro777
      Pythonistapro777