# How do I make a second level on processing.py

**URL:** https://discourse.processing.org/t/how-do-i-make-a-second-level-on-processing-py/6244
**Category:** Processing.py
**Created:** [December 3, 2018, 8:21am UTC](https://discourse.processing.org/t/how-do-i-make-a-second-level-on-processing-py/6244 "2018-12-03T08:21:02Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![dashmc](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@dashmc](https://discourse.processing.org/u/dashmc)
#### Post date: [December 3, 2018, 8:21am UTC](https://discourse.processing.org/t/how-do-i-make-a-second-level-on-processing-py/6244/1 "2018-12-03T08:21:02Z")

</div>

Here is my code so far. Level two is not activating when I need it to. Any ideas? Pls help

```auto
global cWidth
global cHeight
cWidth=600
cHeight=600
level1 = True
level2 = False
class character(object):
    def __init__ (self):
          self.x=100
          self.y=100
          self.up=0
          self.down=0
          self.left=0
          self.right=0
          self.speed=4
          self.w = 20
          self.h = 20
    def show(self):
        c.levels()
        if (level1):
            fill(200);
            rect(100, 100, 400, 400);
            fill(0,0,255);
            rect(439,465,60,35);
            fill(0,0,255);
            rect(100,100,60,35);
            fill(0,0,255);
            rect(100,100,60,35);
            fill(255,0,0);
            rect(200,100,20,350);
            fill(255,0,0);
            rect(275,150,20,350);
            fill(255,0,0);
            rect(350,100,20,350);
            fill(0);
            rect(self.x,self.y,self.w,self.h)
        elif (level2):
            fill(200);
            rect(100, 100, 400, 400);
            fill(200);
            rect(self.x,self.y,self.w,self.h)
                            
    def update(self):
        c.levels()
        if (level1):
            self.x = self.x + (self.right - self.left)*self.speed
            self.y = self.y + (self.down - self.up)*self.speed
            if not(self.x >= 100):
                self.x=100
            if not(self.y >= 100):
                self.y=100
            if not(self.x <= 500-self.w):
                self.x=500-self.w
            if not(self.y <= 500-self.h):
                self.y=500-self.h
            if self.x>200-self.w and self.x<218 and self.y<450:
                self.x=100
                self.y=100
            if self.x>279-self.w and self.x<295 and self.y>131:
                self.x=100
                self.y=100
            if self.x>350-self.w and self.x<368 and self.y<450:
                self.x=100
                self.y=100
            if self.x>=385 and self.x<=390 and self.y>131:
                self.x=385
                textSize(25);
                text("invisible wall?", 150, 300); 
                fill(0, 102, 153);
            elif(level2):
                self.x = self.x + (self.right - self.left)*self.speed
                self.y = self.y + (self.down - self.up)*self.speed
                self.x=100
                self.y=100
                
    
    def levels(self):
        if self.x>=440-self.w and self.y>=465-self.h:
            clear()
            noLoop()
            level1 = False
            level2 = True
            
            

                            
                                                                                    
def setup():
    size(cWidth,cHeight)
    global c
    global d
    if (level1):
        c=character()
    elif (level2):
        d=character()
def draw():
    if (level1):
        c.levels()
        background(100)
        c.show()
        c.update()
    elif (level2):
        c.levels()
        background(100)
        d.show()
        
        

def keyPressed():
    c.levels()
    if (level1):
        if keyCode == UP:
            c.up = 1
        if keyCode == DOWN:
            c.down = 1
        if keyCode == RIGHT:
            c.right = 1
        if keyCode == LEFT:
            c.left = 1
    if (level2):
        if keyCode == UP:
            d.up = 1
        if keyCode == DOWN:
            d.down = 1
        if keyCode == RIGHT:
            d.right = 1
        if keyCode == LEFT:
            d.left = 1
        
def keyReleased():
    if (level1):
        if keyCode == UP:
            c.up = 0
        if keyCode == DOWN:
            c.down = 0
        if keyCode == RIGHT:
            c.right = 0
        if keyCode == LEFT:
            c.left = 0 
    if (level2):
        if keyCode == UP:
            d.up = 0
        if keyCode == DOWN:
            d.down = 0
        if keyCode == RIGHT:
            d.right = 0
        if keyCode == LEFT:
            d.left = 0

```

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [December 6, 2018, 11:48pm UTC](https://discourse.processing.org/t/how-do-i-make-a-second-level-on-processing-py/6244/2 "2018-12-06T23:48:11Z")

</div>

Are level1 and level2 global?
