• squiffel

    First time user of Python and Pythonista. Started yesterday.

    I think its really cool! Built a game on my phone.

    So I'm making it open source, I'd love to see your modifications.

    Lastly, if anyone can teach me how to get Pythonista files to work on a desktop, I would super appreciate it! I don't know how to get the right IDE, or the correct modules so that I can just run the script. Thanks!

    <code>

    from scene import *
    import random
    
    class MyScene (Scene):
    
    def setup(self):
        # This will be called before the first frame is drawn.
        
        self.x = 100
        self.y = 0
        self.scr_h = 480
        self.scr_w = 320
        self.flr = 32 #floor
        self.g = 0.5 #gravity
        self.acel = 0
        
        self.lw = self.scr_h
        
        self.ms = 6 #max speed
        self.n = 6
        
        #wall
        self.ex = self.scr_h - 32
        self.ey = self.flr
        self.etimer = 0.0
        self.box_h = 32
        self.box_2 = 32
        self.rand = 1
        self.col = 0
        self.m = 32
        
        #reset
        self.pts = 0
        self.rtimer = 0
        
        #collisions
        self.dead = False
        pass
    
    def draw(self):
        # This will be called for every frame (typically 60 times per second).
        background(255, 255, 255)
        stroke(255,0,0)
        
        #floor
        if self.col < self.n:
            line(0,self.flr,self.lw,self.flr)
            stroke(200,100,50)
            stroke_weight(1)
        else:
            self.flr = 0
            self.ey = 0
            self.m = 64
            if self.y == 0:
                self.dead = True
        
        if self.col == self.n - 1:
            text('Lets fly!!', 'Arial', 12, self.scr_h / 2, (self.scr_w / 2) + 16, 5)
            self.lw = self.ex
            
        #text
        tint(0,0,0,1)
        if self.dead == True:
            text('You are DEAD', 'Arial', 12, 48, self.y+ 16, 5)
        
        if self.dead == False:
            self.pts += 1
            
        text('Points: ' + str(self.pts), 'Arial', 12, self.x-48, self.y + 32, 5)
        
        #character
        rect(self.x,self.y,32,32)
        
        #character badguy
        rect(self.ex,self.ey,32,self.box_h)
        rect(self.ex,self.ey+self.scr_w,32,-self.box_2-32)
        
        # Touch input:
        fill(1, 0, 0)
        for touch in self.touches.values():
            #ellipse(touch.location.x - 50, touch.location.y - 50, 100, 100)
            self.acel += 1
            
            #reset when dead
            if self.rtimer > 30:
                self.ex = self.scr_h - 32
                self.ey = self.flr
                self.rtimer = 0.0
                self.box_h = 32
                self.box_2 = 32
                self.rand = 1
                self.pts = 0
                self.etimer = 0
                self.dead = False
                self.flr = 32
                self.ey = self.flr
                self.col = 0
                self.m = 32
                self.lw = self.scr_h
                
        
                
        if self.dead == True:
            self.rtimer += 1
            text('Press to reset!', 'Arial', 12, self.scr_h / 2, self.scr_w / 2, 5)
        
        # Physics
        if self.dead == False:
            self.y += self.acel
        
        if self.y < self.flr:
            self.y = self.flr
            self.acel = 0
        else:
            self.acel -= self.g
        
        if self.y > self.scr_w - 32:
            self.y = self.scr_w - 32
            self.acel = 0
        
        if self.acel > self.ms:
            self.acel = self.ms
        if self.acel < -self.ms:
            self.acel = -self.ms
            
        #badguy
        if self.dead == False:
            self.etimer += 0.1
            self.ex -= self.etimer
            if self.ex < 0:
                self.ex = self.scr_h
                self.rand = random.randrange(1,8)
                self.box_h = 32 * self.rand
                self.box_2 = 32 * (10 - self.rand - 4)
                self.dead = False
                self.etimer = 0
                self.col += 1
        
        #Collisions
        if self.ex > 100 - 32 and self.ex < 100 + 32:
            if self.y < self.box_h + self.flr:
                self.dead = True
            
            if self.y > self.scr_w - self.box_2 - self.m:
                self.dead = True
            
            if self.dead == False:
                self.pts += 50
                
        if self.dead == True:
            self.etimer = 0
        
    
    def touch_began(self, touch):
        pass
    
    def touch_moved(self, touch):
        pass
    
    def touch_ended(self, touch):
        pass
    
    run(MyScene())
    

    </code>

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!