Ejemplo n.º 1
0
 def update(self):
     self.image = Image.new('1', self.display.size, (0))
     draw = ImageDraw.Draw(self.image)
     if self.init_status < 4:
         self.drawInit(draw)
     else:
         events = self.get_input()
         if events:
             for event in events:
                 if event.value == 0:
                     continue;
                 print event
                 if self.is_event(event,self.input_map['up']):
                     self.direction = (0,-1)
                 if self.is_event(event,self.input_map['down']):
                     self.direction = (0,1)
                 if self.is_event(event,self.input_map['left']):
                     self.direction = (-1,0)
                 if self.is_event(event,self.input_map['right']):
                     self.direction = (1,0)
         self.snake.append((self.snake[-1][0]+self.direction[0],self.snake[-1][1]+self.direction[1]))
         if self.on_fruit(self.snake[-1]):
             self.fruits.remove(self.snake[-1])
             self.snake_length += 3
         while len(self.fruits) < self.max_fruits:
             self.place_fruit()
         while len(self.snake) > self.snake_length:
             self.snake.pop(0)
         
         for p in self.snake:
             draw.point(p,(1))
             
         for p in self.fruits:
             draw.point(p,(1))
     View.update(self)
Ejemplo n.º 2
0
 def update(self):
     self.image = Image.new('1', self.display.size, "#000000")
     font = ImageFont.truetype("/home/teddydestodes/unifont-5.1.20080907.ttf",16)
     draw = ImageDraw.Draw(self.image)
     tsize = font.getsize(self.text)
     draw.text((0-self.offset, 0),self.text,(1),font=font)
     if self.offset > tsize[0]:
         self.offset = self.display.size[0]*-1
     self.offset +=5
     View.update(self)
Ejemplo n.º 3
0
 def update(self):
     if time.time() - self.lastdraw > self.framelimit:
         self.level.tick()
         self.lastdraw = time.time()
     self.image = Image.new('1', self.display.size, (0))
     pixels = self.image.load()
     map = self.level.get_map_data()
     for line in range(0,16):
         for dot in range(0,len(map[line])): 
             pixels[dot,line] = map[line][dot]
     
     View.update(self)
Ejemplo n.º 4
0
 def __init__(self, display):
     View.__init__(self,display)
     self.dev = InputDevice('/dev/input/event16')
     self.init_status = 0
     self.input_map = {'up': None,
                       'down': None,
                       'left': None,
                       'right': None,
                       'pause': None}
     self.last_event = None
     self.direction = (1,0)
     self.snake = [(5,5),(6,5),(7,5),(8,5),]
     self.snake_length = 4
     self.fruits = []
     self.max_fruits = 1
Ejemplo n.º 5
0
 def __init__(self, display):
     View.__init__(self,display)
     self.offset = 0
     self.level = SPBLevel('testlevel')
     self.level.drawsize = (80,16)
     self.player = SPBPlayer(self.level)
     self.player.position = [3.0,10.0]
     en = SPBGoomba(self.level)
     en.position = [20.0,10.0]
     en2 = SPBGoomba(self.level)
     en2.position = [21.0,10.0]
     en3 = SPBGoomba(self.level)
     en3.position = [22.0,10.0]
     en4 = SPBGoomba(self.level)
     en4.position = [23.0,10.0]
     self.level.add_creature(self.player)
     self.level.add_creature(en)
     #self.level.add_creature(en2)
     #self.level.add_creature(en3)
     #self.level.add_creature(en4)
     self.lastdraw = 0
Ejemplo n.º 6
0
 def __init__(self, display, text):
     View.__init__(self, display)
     self.text = text
     self.offset = 0
Ejemplo n.º 7
0
 def update(self):
     draw = ImageDraw.Draw(self.image)
     draw.line((0,0,self.display.size[0],0), (1), 1)
     draw.line((0,self.display.size[1],self.display.size[0],self.display.size[1]), (1), 1)
     View.update(self)