• Pythonistapro777

    I completely agree with @/Webmaster4o , you will cover ground much quicker by finding out what you want to gain from programming and finding codes that implement that. Then work on finding out how the codes work and modifying it. It's useful to strip down from different programs than to add to it, so tat would be a place to start.
    Then the forum is also a good place to get help and find different ways to improve your code.

    posted in General Discussion read more
  • Pythonistapro777

    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 read more
  • Pythonistapro777

    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 read more
  • Pythonistapro777

    @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 read more
  • Pythonistapro777

    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 read more
  • Pythonistapro777

    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 read more
  • Pythonistapro777

    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 read more
  • Pythonistapro777

    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 read more

Internal error.

Oops! Looks like something went wrong!