示例#1
0
 def draw(self):
     self.invocations += 1
     scene.background(0, 0, 0)
     scene.fill(1, 0, 0)
     self.active_scene.touches = self.touches
     self.active_scene.t = self.t - self.tmp_t
     self.active_scene.draw()
示例#2
0
 def draw(self):
     scene.background(0,0,1) # 0,0,1 = blue
     if self.color == 1:
         scene.fill(0,1,0)       # 0,1,0 = green
     elif self.color == 2:
         scene.fill(1,0,0)       # 1,0,0 = red
     scene.rect(50,50,50,50)
示例#3
0
 def draw(self):
     scene.background(0, 0, 1)  # 0,0,1 = blue
     scene.fill(0, 1, 0)  # 0,1,0 = green
     scene.rect(
         *self.rect1)  # *self.rect1 = self.rect1[0], ..., self.rect1[3]
     scene.fill(1, 0, 0)  # 1,0,0 = red
     scene.rect(*self.rect2)
 def draw(self):
     scene.background(0, 0, 0)
     self.root_layer.update(self.dt)
     self.root_layer.draw()
     scene.fill(1, 1, 1)  # watch+battery -> white background
     scene.rect(0, self.bounds.h, self.bounds.w, 20)  # watch+battery
     locations = [[0, 0], [0, 0]]
     i = 0
     if len(self.touches) == 2:
         for touch in self.touches.values():
             locations[i] = touch.location
             i += 1
         if self.reset:
             self.reset = False
             self.distance_old = math.sqrt(
                 math.pow((locations[1][0] - locations[0][0]), 2) +
                 pow((locations[1][1] - locations[0][1]), 2))
         else:
             self.distance_new = math.sqrt(
                 math.pow((locations[1][0] - locations[0][0]), 2) +
                 pow((locations[1][1] - locations[0][1]), 2))
             self.distance_abs = self.distance_new - self.distance_old
             self.reset = True
         if self.distance_abs != 0:
             zoom_new = self.distance_abs / self.bounds.w * self.zoom_speed
             if zoom_new < 0:
                 self.zoom += zoom_new
             else:
                 self.zoom += zoom_new
             if self.zoom < self.zoom_min:
                 self.zoom = self.zoom_min
             elif self.zoom > self.zoom_max:
                 self.zoom = self.zoom_max
             self.root_layer.animate('scale_x', self.zoom, duration=0.0)
             self.root_layer.animate('scale_y', self.zoom, duration=0.0)
示例#5
0
 def draw(self):
     scene.background(0,0,1) # 0,0,1 = blue
     self.rect1_layer.update(self.dt)   # alpha animation
     self.rect1_layer.draw()            # alpha animation
     #scene.fill(0,1,0)       # 0,1,0 = green
     #scene.ellipse(*self.rect1) # *self.rect1 = self.rect1[0], ..., self.rect1[3]
     scene.fill(1,0,0)       # 1,0,0 = red
示例#6
0
    def draw(self):
        portrait = self.size.h > self.size.w
        scene.background(0.40, 0.80, 1.00) # light blue background color

        if portrait:
            self.play_btn_rect = scene.Rect(200, 358, 600, 100)
            self.char_btn_rect = scene.Rect(140, 485, 470, 100)
        else:
            self.play_btn_rect = scene.Rect( 20, 358, 350, 100)
            self.char_btn_rect = scene.Rect( 20, 485, 230, 100)
        
        scene.fill(0.50, 1.00, 0.00) # play button fill color
        scene.rect(*self.play_btn_rect)
        scene.fill(1.00, 1.00, 1.00) # character select button fill color
        scene.rect(*self.char_btn_rect)
        
        scene.tint(1.00, 1.00, 1.00) # white text color
        fs, x, y = (100, 385, 850) if portrait else (150, 525, 600)
        scene.text('Cloud Jump', MENU_FONT,  font_size=fs, x=x, y=y)
        fs, x, y = ( 65, 380, 650) if portrait else ( 65, 200, 400)
        scene.text('Play Game', BUTTON_FONT, font_size=fs, x=x, y=y)
        scene.tint(0.00, 0.50, 1.00) # blue text color
        fs, x, y = ( 54, 380, 521) if portrait else ( 54, 260, 285)
        scene.text('Character Select', BUTTON_FONT, font_size=fs, x=x, y=y)
        scene.tint(1.00, 1.00, 1.00) # white text color
        fs =  30
        if portrait:
            x, y = self.bounds.w / 2.0, self.bounds.h / 1.34
        else:
            x, y = self.bounds.w / 1.4, self.bounds.h / 1.7
        s = 'Welcome {}!'.format(player_name)
        scene.text(s, MENU_FONT, font_size=fs, x=x, y=y)

        for i in xrange(11):
            scene.image('PC_Grass_Block', self.bounds.w / 11 * i, 0)
示例#7
0
 def draw(self):
     scene.background(0, 0, 1)  # 0,0,1 = blue
     if self.color == 1:
         scene.fill(0, 1, 0)  # 0,1,0 = green
     elif self.color == 2:
         scene.fill(1, 0, 0)  # 1,0,0 = red
     scene.rect(50, 50, 50, 50)
 def draw(self):
     scene.background(0,0,0)
     self.root_layer.update(self.dt)
     self.root_layer.draw()
     scene.fill(1,1,1)   # watch+battery -> white background
     scene.rect(0, self.bounds.h, self.bounds.w, 20)  # watch+battery
     locations = [[0,0],[0,0]]
     i = 0
     if len(self.touches) == 2:
         for touch in self.touches.values():
             locations[i] = touch.location
             i += 1
         if self.reset:
             self.reset = False
             self.distance_old = math.sqrt(math.pow((locations[1][0] - locations[0][0]),2) + pow((locations[1][1] - locations[0][1]),2))
         else:
             self.distance_new = math.sqrt(math.pow((locations[1][0] - locations[0][0]),2) + pow((locations[1][1] - locations[0][1]),2))
             self.distance_abs = self.distance_new - self.distance_old
             self.reset = True
         if self.distance_abs != 0:
             zoom_new = self.distance_abs/self.bounds.w*self.zoom_speed
             if zoom_new < 0:
                 self.zoom += zoom_new
             else:
                 self.zoom += zoom_new
             if self.zoom < self.zoom_min:
                 self.zoom = self.zoom_min
             elif self.zoom > self.zoom_max:
                 self.zoom = self.zoom_max
             self.root_layer.animate('scale_x', self.zoom, duration=0.0)
             self.root_layer.animate('scale_y', self.zoom, duration=0.0)     
示例#9
0
 def draw(self):
     # Called for every frame (typically 60 per second).
     scene.background(0, 0, 0)
     # Draw a circle for every finger touch
     scene.fill(*self.fgColor)
     for touch in self.touches.values():
         scene.ellipse(touch.location.x - 50, touch.location.y - 50, 100,
                       100)
示例#10
0
 def draw(self):
     self.root_layer.update(self.dt)
     self.root_layer.draw()
     scene.tint(*self.current_color())  # draw the user's text
     scene.text(self.text, self.current_font(), self.fontsize,
                self.position[0], self.position[1], 5)
     scene.fill(*color('white'))   # watch+battery -> white background
     scene.rect(0, 748, 1024, 20)  # watch+battery
示例#11
0
 def draw(self):
     scene.background(0, 0, 1)  # 0,0,1 = blue
     self.rect1_layer.update(self.dt)  # alpha animation
     self.rect1_layer.draw()  # alpha animation
     #scene.fill(0,1,0)       # 0,1,0 = green
     #scene.ellipse(*self.rect1) # *self.rect1 = self.rect1[0], ..., self.rect1[3]
     scene.fill(1, 0, 0)  # 1,0,0 = red
     scene.ellipse(*self.circle2)
 def draw(self):
     ''' real time drawing only'''
     scene.background(0, 0, 0)
     if self.touch:
         scene.fill(self.spot_color)
         loc = self.touch.location
         scene.ellipse(loc.x - 50, loc.y - 50, 100, 100)
         scene.text('{}, {}'.format(*loc), 'Futura', 20, 100, 50)
示例#13
0
 def draw(self):
     scene.background(*color('black'))
     self.root_layer.update(self.dt)
     self.root_layer.draw()
     scene.tint(*self.current_color())  # draw the user's text
     scene.text(self.text, self.current_font(), self.fontsize,
                self.position[0], self.position[1]+self.btn_height, 5)   # add ...position[1]+self.btn_height
     scene.fill(*color('white'))   # watch+battery -> white background
     scene.rect(0, self.bounds.h, self.bounds.w, 20)  # watch+battery
示例#14
0
	def draw(self):
		scene.background(0.40, 0.80, 1.00)
		scene.fill(1.00, 1.00, 1.00)

		scene.image('Boy', *self.p1_rect)
		scene.image('Girl', *self.p2_rect)
		scene.image('Guardsman', *self.p3_rect)
		scene.image('Hamster_Face', *self.p4_rect)
		scene.image('Mouse_Face', *self.p5_rect)
		scene.image('Man', *self.p6_rect)
示例#15
0
 def draw(self):
     scene.background(*color('black'))
     self.root_layer.update(self.dt)
     self.root_layer.draw()
     scene.tint(*self.current_color())  # draw the user's text
     scene.text(self.text, self.current_font(), self.fontsize,
                self.position[0], self.position[1] + self.btn_height,
                5)  # add ...position[1]+self.btn_height
     scene.fill(*color('white'))  # watch+battery -> white background
     scene.rect(0, self.bounds.h, self.bounds.w, 20)  # watch+battery
示例#16
0
 def draw(self):
     scene.background(0.09,0.09,0.102)
     scene.image(self.bgImages[self.bgIndex],
                                  200, 300, 300, 300)
     scene.fill(0.3, 0.3, 0.3, 1)
     scene.no_stroke()
     scene.text(theMessage, font_name='Chalkduster',
                            font_size=22, alignment=9)
     scene.ellipse(self.tapLoc.x - 50,
                   self.tapLoc.y - 50, 100, 100)
示例#17
0
    def draw(self):
        scene.push_matrix()
        scene.translate(self.frame.x, self.frame.y)
        scene.no_stroke()
        scene.fill(0.90, 0.90, 0.90)
        for i in self.shapes:
            scene.ellipse(i[0], i[1] - 5, i[2], i[2])

        scene.fill(1.00, 1.00, 1.00)
        for i in self.shapes:
            scene.ellipse(i[0], i[1] + 5, i[2], i[2])
        scene.pop_matrix()
示例#18
0
 def draw(self):
     scene.background(0, 0, 0)
     if self.touch:
         scene.fill('red')
         loc = self.touch.location
         scene.ellipse(loc.x - 50, loc.y - 50, 100, 100)
         scene.text('{}, {}'.format(*loc), 'Futura', 20, 100, 50)
         points.append(loc)  # is it be useful to check if loc == prev_loc?
     elif points:
         scene.fill('blue')
         for loc in points:
             scene.ellipse(loc.x - 50, loc.y - 50, 100, 100)
 def draw(self):
     scene.background(0, 0, 0)
     self.root_layer.update(self.dt)
     self.root_layer.draw()
     scene.fill(1, 1, 1)
     scene.stroke(*self.stroke_color)
     scene.stroke_weight(4)
     scene.rect(0, 180, 320, 15)
     scene.rect(0, 290, 320, 15)
     scene.rect(92, 87, 15, 310)
     scene.rect(208, 87, 15, 310)
     for l in self.lines:
         scene.line(*l)
示例#20
0
 def draw(self):
     scene.background(0, 0, 0)
     scene.fill(1, 1, 1)
     x = screen_width / 2
     s_y = screen_height / 2 + 100
     d_y = s_y - 30
     l_y = d_y - 75
     scene.tint(0.32645,0.28306,0.93492)
     scene.text('PhantomChess version {}'.format(version), x=x, y=s_y, font_size=20.0)
     scene.tint(1, 1, 1)
     if debug:
         scene.text('Debugger set to level {}'.format(debug), x=x, y=d_y)
     for i, line in enumerate(short().splitlines()):
         scene.text(line, x=x, y=l_y - (i*20))
示例#21
0
  def draw(self):
    if self.xy_velocity and not self.cur_touch:
      #self.dx += self.xy_velocity[0] * self.dt
      self.dy += self.xy_velocity[1] * self.dt
      decay = exp( - self.dt / self.velocity_decay_timescale_seconds )
      self.xy_velocity = (self.xy_velocity[0] * decay, self.xy_velocity[1] * decay)
      if ((abs(self.xy_velocity[0]) <= self.min_velocity_points_per_second) and (abs(self.xy_velocity[1]) <= self.min_velocity_points_per_second)):
        self.xy_velocity = None

    # Get day of week...Monday=1, etc
    day = datetime.datetime.today().isoweekday()

    # Rotate a color for each day in week
    r,g,b = get_background_color(day)
    scene.background(r,g,b)

    scene.translate(self.dx, self.dy)
    scene.fill(1, 1, 1)
    scene.stroke(1, 1, 1)
    # Line thickness
    scene.stroke_weight(1)

    # Vertical lines
    scene.line(-150,-931,-150,255)
    scene.line(150,-931,150,255)

    # Horizontal lines
    scene.line(-150,255,150,255)
    scene.line(-150,230,150,230)
    scene.line(-150,60,150,60)
    scene.line(-150,35,150,35)
    scene.line(-150,-104,150,-104)
    scene.line(-150,-241,150,-241)
    scene.line(-150,-379,150,-379)
    scene.line(-150,-517,150,-517)
    scene.line(-150,-655,150,-655)
    scene.line(-150,-794,150,-794)
    scene.line(-150,-931,150,-931)

    '''
    Text will be white by default and
    images drawn in their natural colors
    unless tint(r,g,b,a) function is used
    '''
    scene.text(weather_now,font_size=12,x=-140,y=250, alignment=3)
    scene.text(forecast,font_size=12,x=-140,y=55, alignment=3)

    # Insert icons into scene
    for i, image in enumerate(self.images):
      scene.image(image,75,y[i])
示例#22
0
 def draw(self):
     ui.background(*COLORS["mbg"])
     ui.fill(*COLORS["bg"])
     ui.rect(*self.bounds)
     ui.fill(*COLORS["walls"])
     for wall in self.walls:
         self.draw_cell(*wall)
     self.apple.draw(self)
     self.snake.update(self)
     self.snake.draw(self)
     sx, sy = self.scorepos
     ui.text("Score: %d" % self.score, "Monofur", 30, sx, sy, 9)
     if self.snake.dead:
         self.draw_text_center("Game Over")
示例#23
0
 def scene_draw(self):
     if self.touch:
         if (self.magnitude < 0.99 * self.max_length):
             scene.stroke_weight(self.color['normal']['weight'])
             scene.stroke(*self.color['normal']['stroke'])
             scene.fill(*self.color['normal']['fill'])
         else:
             scene.stroke_weight(self.color['highlight']['weight'])
             scene.stroke(*self.color['highlight']['stroke'])
             scene.fill(*self.color['highlight']['fill'])
         scene.ellipse(self.boundary['left'], self.boundary['lower'],
                       2.0 * self.max_length, 2.0 * self.max_length)
         scene.line(self.ref_x, self.ref_y, self.clamp_x, self.clamp_y)
         scene.text(self.label, x=self.ref_x, y=self.ref_y)
示例#24
0
 def draw(self):
     scene.background(0, 0, 0)
     scene.fill(1, 1, 1)
     x, y = self.bounds.center()
     #print(self.bounds)
     s_y = y + 100
     d_y = s_y - 30
     l_y = s_y - 75
     scene.tint(0.32645, 0.28306, 0.93492)
     scene.text('PhantomChess version {}'.format(C.version), x=x, y=s_y, font_size=20.0)
     scene.tint(1, 1, 1)
     if C.debug:
         scene.text('Debugger set to level {}'.format(C.debug), x=x, y=d_y)
     for i, line in enumerate(short().splitlines()):
         scene.text(line, x=x, y=l_y - (i*20))
示例#25
0
 def scene_draw(self):
     if self.touch:
         if not (int(self.x) or int(self.y)):
             scene.stroke_weight(self.color['normal']['weight'])
             scene.stroke(*self.color['normal']['stroke'])
             scene.fill(*self.color['normal']['fill'])
         else:
             scene.stroke_weight(self.color['highlight']['weight'])
             scene.stroke(*self.color['highlight']['stroke'])
             scene.fill(*self.color['highlight']['fill'])
         scene.rect(self.boundary['left'], self.boundary['lower'],
                    2.0 * self.max_length, 2.0 * self.max_length)
         scene.line(self.clamp_x, self.boundary['upper'], self.clamp_x,
                    self.boundary['lower'])
         scene.line(self.boundary['left'], self.clamp_y,
                    self.boundary['right'], self.clamp_y)
         scene.text(self.label, x=self.ref_x, y=self.ref_y)
示例#26
0
 def draw(self):
     scene.background(0, 0, 0)
     scene.fill(1, 1, 1)
     x, y = self.bounds.center()
     #print(self.bounds)
     s_y = y + 100
     d_y = s_y - 30
     l_y = s_y - 75
     scene.tint(0.32645, 0.28306, 0.93492)
     scene.text('PhantomChess version {}'.format(C.version),
                x=x,
                y=s_y,
                font_size=20.0)
     scene.tint(1, 1, 1)
     if C.debug:
         scene.text('Debugger set to level {}'.format(C.debug), x=x, y=d_y)
     for i, line in enumerate(short().splitlines()):
         scene.text(line, x=x, y=l_y - (i * 20))
示例#27
0
 def scene_draw(self):
     if self.touch:
         scene.stroke_weight(self.color['highlight']['weight'])
         scene.stroke(*self.color['highlight']['stroke'])
         scene.fill(*self.color['highlight']['fill'])
         scene.line(self.touch.location.x, self.respond_area['y1'],
                    self.touch.location.x, self.respond_area['y2'])
         scene.line(self.respond_area['x1'], self.touch.location.y,
                    self.respond_area['x2'], self.touch.location.y)
     else:
         scene.stroke_weight(self.color['normal']['weight'])
         scene.stroke(*self.color['normal']['stroke'])
         scene.fill(*self.color['normal']['fill'])
     scene.rect(self.respond_area['x1'], self.respond_area['y1'],
                self.respond_area['x2'], self.respond_area['y2'])
     scene.text(self.label,
                x=self.respond_area['x1'],
                y=self.respond_area['y1'])
示例#28
0
	def draw(self):
		self.prevmode = self.mode
		self.mode = 'off'
		for touch in touches:
			if touch.location in scene.Rect(*self.rect):
				self.mode = 'on'
			elif self.prevmode == 'on':
				self.mode = 'up'
				
		if self.mode == 'on':
			scene.fill(*self.altcolor)
			scene.tint(*self.alttxtcolor)
			scene.stroke(*self.altbordrcolor)
		else:
			scene.fill(*self.color)
			scene.tint(*self.txtcolor)
			scene.stroke(*self.bordrcolor)
		
		scene.stroke_weight(self.bordrw)
		scene.rect(*self.rect)
		scene.text(self.text, self.font, self.fontsize, self.rect[0] + self.rect[2] / 2, self.rect[1] + self.rect[3] / 2)
    def draw(self):
        scene.background(0, 0.5, 1.0)
        scene.fill(1, 1, 1)
        scene.rect(self.x,self.y, 32, 32)  # player
        scene.fill(0, 0, 0)
        scene.rect(self.x - 70, self.y + 75, 700, 32)  # roof
        self.floor = scene.rect(self.x - 70, self.y - 75, 700, 32)  # floor
        print('self.floor is always None:', self.floor)
        if not self.grav:
            self.acel += 1

  #text
        scene.tint(0, 0, 0, 1)
        if self.dead:
            scene.text('You are DEAD', 'Arial', 12, 48, self.y + 16)
        else:
            self.pts += 1
        scene.text('Points: %i' % self.pts, 'Arial', 12, self.x-48, self.y + 32)

  # Touch input:
        scene.fill(1,0,0)
        if not self.grav:
            self.acel += 1

  # Physics
        if not self.dead:
            self.y += self.acel
        if self.y < self.floor:
            self.y = self.floor
            self.acel = 0
        else:
            print('problem: {} > {}'.format(self.y, self.floor))
            self.acel -= self.g
        self.acel = max(min(self.acel, self.ms), -self.ms)
示例#30
0
 def scene_draw(self):
     if not (self.touch or (self.toggle)):
         scene.stroke_weight(self.color['normal']['weight'])
         scene.stroke(*self.color['normal']['stroke'])
         scene.fill(*self.color['normal']['fill'])
     else:
         scene.stroke_weight(self.color['highlight']['weight'])
         scene.stroke(*self.color['highlight']['stroke'])
         scene.fill(*self.color['highlight']['fill'])
     scene.rect(self.respond_area['x1'] * self.scrnWdth,
                self.respond_area['y1'] * self.scrnHght,
                (self.respond_area['x2'] - self.respond_area['x1']) *
                self.scrnWdth,
                (self.respond_area['y2'] - self.respond_area['y1']) *
                self.scrnHght)
     scene.text(
         self.label,
         x=0.5 * (self.respond_area['x1'] + self.respond_area['x2']) *
         self.scrnWdth,
         y=0.5 * (self.respond_area['y1'] + self.respond_area['y2']) *
         self.scrnHght,
     )
示例#31
0
    def draw(self):
        self.prevmode = self.mode
        self.mode = 'off'
        for touch in touches:
            if touch.location in scene.Rect(*self.rect):
                self.mode = 'on'
            elif self.prevmode == 'on':
                self.mode = 'up'

        if self.mode == 'on':
            scene.fill(*self.altcolor)
            scene.tint(*self.alttxtcolor)
            scene.stroke(*self.altbordrcolor)
        else:
            scene.fill(*self.color)
            scene.tint(*self.txtcolor)
            scene.stroke(*self.bordrcolor)

        scene.stroke_weight(self.bordrw)
        scene.rect(*self.rect)
        scene.text(self.text, self.font, self.fontsize,
                   self.rect[0] + self.rect[2] / 2,
                   self.rect[1] + self.rect[3] / 2)
 def draw(self):
     scene.background(0, 0, 0)
     self.root_layer.update(self.dt)
     self.root_layer.draw()
     scene.fill(1, 1, 1)  # watch+battery -> white background
     scene.rect(0, self.bounds.h, self.bounds.w, 20)  # watch+battery
示例#33
0
 def draw(self):
     x, y, sx, sy = self.bounds
     x += self.wall.bounds.x
     y += self.wall.bounds.y
     scene.fill(*self.color)
     scene.rect(x, y, sx, sy)
示例#34
0
 def draw(self, state):
     ui.fill(*COLORS["snake"])
     for segment in self.body[1:]:
         state.draw_cell(*segment)
     ui.fill(*COLORS["head"])
     state.draw_cell(*self.body[0])
 def draw(self):
     scene.background(0,0,1) # 0,0,1 = blue
     scene.fill(0,1,0)       # 0,1,0 = green
     scene.rect(50,50,50,50)
     scene.fill(1,0,0)       # 1,0,0 = red
     scene.rect(self.rect2.x,self.rect2.y,50,50)
示例#36
0
 def draw (self):
     scene.background(0, 0, 0)
     scene.fill(1, 0, 0)
     for touch in self.touches.values():
         x, y = touch.location
         scene.ellipse(x - 50, y - 50, 100, 100)
 def draw(self):
     scene.fill(*self.colour)
     scene.rect(self.x, self.y, 8, 8)
示例#38
0
 def draw(self):
     scene.background(0,0,0)
     self.root_layer.update(self.dt)
     self.root_layer.draw()
     scene.fill(1,1,1)   # watch+battery -> white background
     scene.rect(0, self.bounds.h, self.bounds.w, 20)  # watch+battery
示例#39
0
 def draw(self):
     background = scene.Color(1, 1, 1) if self.alive else scene.Color(
         0, 0, 0)
     scene.fill(*background)
     scene.rect(*self.frame)
示例#40
0
 def draw(self):
     background = scene.Color(1, 1, 1) if self.alive else scene.Color(0, 0, 0)
     scene.fill(*background)
     scene.rect(*self.frame)
示例#41
0
 def draw(self):
     scene.background(0, 0, 0)
     scene.fill(1, 1, 1, 1)
     if self.render_mode['pieces']:
         for piece in self.game.board.pieces:
             scene.tint(1, 1, 1, 0.5)
             pos = piece.coord.as_screen()
             img = self.img_names[piece.pythonista_gui_imgname]
             scene.image(img, pos.x, pos.y, scale_factor, scale_factor)
             scene.tint(1, 1, 1, 1)
             if piece.coord == self.selected:
                 scene.fill(0.23347,0.3564,0.59917, 0.6)
                 scene.rect(pos.x, pos.y, scale_factor, scale_factor)
                 scene.fill(1, 1, 1, 1)
         if self.render_mode['timers']:
             white = str(self.game.board.player1.timer.get_run())
             black = str(self.game.board.player2.timer.get_run())
             bpos = Coord(992, 672)
             wpos = Coord(992, 96)
             scene.tint(1, 1, 1, 1)
             scene.text(black, x=bpos.x, y=bpos.y)
             scene.text(white, x=wpos.x, y=wpos.y)
             scene.tint(1, 1, 1, 1)
     if self.render_mode['sqrs']:
         for tile in self.game.board.tiles:
             color = tile.color.tilecolor
             color += (0.57,)  # alpha value
             pos = tile.coord.as_screen()
             scene.fill(*color)
             scene.rect(pos.x, pos.y, scale_factor, scale_factor)
             scene.fill(1, 1, 1, 1)
             if self.render_mode['coords']:
                 center = Coord(pos.x + (scale_factor / 2), pos.y + (scale_factor / 2))
                 chess_pos = center + Coord(0, 10)
                 coord_pos = center - Coord(0, 10)
                 chess = tile.coord.as_chess()
                 coord = str(tile.coord.as_tup())
                 scene.text(chess, x=chess_pos.x, y=chess_pos.y)
                 scene.text(coord, x=coord_pos.x, y=coord_pos.y)
         if self.err_pos.x is not None:
             sc = self.err_pos.as_screen()
             scene.fill(1, 0, 0, 0.3)
             scene.rect(sc.x, sc.y, scale_factor, scale_factor)
             scene.fill(1, 1, 1, 1)
             scene.tint(0, 0, 1, 1)
             scene.text('Move\nInvalid', x=(sc.x + scale_factor/2), y=(sc.y + scale_factor/2))
             scene.tint(1, 1, 1, 1)
     if self.render_mode['valid']:
         for tile in self.game.board.tiles:
             if tile.coord in self.valid_cache:
                 pos = tile.coord.as_screen()
                 scene.fill(0.47934,0.81198,0.41839, 0.3)
                 scene.rect(pos.x, pos.y, scale_factor, scale_factor)
                 scene.fill(1, 1, 1, 1) 
     if self.render_mode['turn']:
         if self.game.board.turn == 'white':
             turn_y = 1 * scale_factor
         elif self.game.board.turn == 'black':
             turn_y = 7 * scale_factor
         pos = Coord(896, turn_y)
         size = Coord(scale_factor / 2, scale_factor / 2)
         scene.tint(1, 1, 1, 1)
         scene.image(self.turn_indicator_img, pos.x, pos.y, size.x, size.y)
         scene.tint(1, 1, 1, 1)
     if self.won:
         pos = Coord(self.size.w/2, self.size.h/2)
         scene.tint(0.32645,0.28306,0.93492)
         # commented out until the bug in ChessGame.is_won() is fixed to be 
         # less annoying
         scene.text('{} wins'.format(self.won), x=pos.x, y=pos.y, font_size=40.0)
         scene.tint(1, 1, 1, 1)
     
     # Buttons
     scene.text('AI Easy', x=scale_factor/2, y=scale_factor*6 - scale_factor/2)
     scene.text('AI Hard', x=scale_factor/2, y=scale_factor*5 - scale_factor/2)
     scene.text('Get score', x=scale_factor/2, y=scale_factor*4 - scale_factor/2)
     if self.disp_score:
         scene.text(str(self.pos_score), x=scale_factor/2, y=scale_factor*4 - scale_factor/1.5)
     scene.text('Undo', x=scale_factor/2, y=scale_factor*3 - scale_factor/2)
     scene.text('Deselect', x=scale_factor/2, y=scale_factor*2 - scale_factor/2)
     scene.text('Options', x=scale_factor/2, y=scale_factor*7 - scale_factor/2)
示例#42
0
 def draw(self):
     scene.background(0, 0, 0)
     if self.touch:
         scene.fill(*self.dot_color)
         x, y = self.touch.location
         scene.ellipse(x - 50, y - 50, 100, 100)
示例#43
0
 def draw(self):
     self.update()
     scene.stroke(0, 0, 0)
     scene.fill(*self.color)
     scene.rect(*self.frame)
示例#44
0
    def draw(self):
        scale_factor = self.square_size
        scene.background(0, 0, 0)
        scene.fill(1, 1, 1, 1)
        board = self.game_view.game.board
        if self.render_mode['pieces']:
            for piece in board.pieces:
                scene.tint(1, 1, 1, 0.5)
                pos = self.as_screen(piece)  # piece.coord.as_screen
                #print(self.img_names)
                img = self.img_names[piece.name]
                scene.image(img, pos.x, pos.y, scale_factor, scale_factor)
                scene.tint(1, 1, 1, 1)
                if piece.fen_loc == self.selected:
                    scene.fill(0.23347,0.3564,0.59917, 0.6)
                    scene.rect(pos.x, pos.y, scale_factor, scale_factor)
                    scene.fill(1, 1, 1, 1)
            if self.render_mode['timers']:
                white = str(board.player1.timer.get_run())
                black = str(board.player2.timer.get_run())
                bpos = Coord(992, 672)
                wpos = Coord(992, 96)
                scene.tint(1, 1, 1, 1)
                scene.text(black, x=bpos.x, y=bpos.y)
                scene.text(white, x=wpos.x, y=wpos.y)
                scene.tint(1, 1, 1, 1)
        if self.render_mode['sqrs']:
            for tile in board.tiles:
                x = int(tile.color == 'white')  # zero or one Thi is code
                color = (x, x, x, 0.57)  # alpha value
                scene.fill(*color)
                pos = self.as_screen(tile)  # tile.as_screen
                scene.rect(pos.x, pos.y, scale_factor, scale_factor)
                scene.fill(1, 1, 1, 1)
                if self.render_mode['coords']:
                    center = Coord(pos.x + (scale_factor / 2), pos.y + (scale_factor / 2))
                    chess_pos = center + Coord(0, 10)
                    coord_pos = center - Coord(0, 10)
                    chess = tile.coord.as_chess
                    coord = str(tile.coord.as_tup)
                    scene.text(chess, x=chess_pos.x, y=chess_pos.y)
                    scene.text(coord, x=coord_pos.x, y=coord_pos.y)
            #if self.err_pos:  # FIXME this needs to be reenabled!
            #    sc = self.err_pos.as_screen
            #    scene.fill(1, 0, 0, 0.3)
            #    scene.rect(sc.x, sc.y, scale_factor, scale_factor)
            #    scene.fill(1, 1, 1, 1)
            #    scene.tint(0, 0, 1, 1)
            #    scene.text('Move\nInvalid', x=(sc.x + scale_factor/2), y=(sc.y + scale_factor/2))
            #    scene.tint(1, 1, 1, 1)
        if self.render_mode['valid']:
            for tile in board.tiles:
                #if self.valid_cache:
                #    print([x for x in self.valid_cache])
                #if tile.coord in self.valid_cache:  # FIXME
                if tile.fen_loc in self.valid_cache:
                    pos = self.as_screen(tile)  # tile.coord.as_screen
                    scene.fill(0.47934,0.81198,0.41839, 0.3)
                    scene.rect(pos.x, pos.y, scale_factor, scale_factor)
                    scene.fill(1, 1, 1, 1)
        if self.render_mode['turn_color']:
            if board.turn == 'white':
                turn_y = 1 * scale_factor
            elif board.turn == 'black':
                turn_y = 7 * scale_factor
            pos = Coord(896, turn_y)
            size = Coord(scale_factor / 2, scale_factor / 2)
            scene.tint(1, 1, 1, 1)
            scene.image(self.turn_indicator_img, pos.x, pos.y, size.x, size.y)
            scene.tint(1, 1, 1, 1)
        if self.won:
            pos = Coord(self.size.w/2, self.size.h/2)
            scene.tint(0.32645,0.28306,0.93492)
            # commented out until the bug in ChessGame.is_won() is fixed to be
            # less annoying
            scene.text('{} wins'.format(self.won), x=pos.x, y=pos.y, font_size=40.0)
            scene.tint(1, 1, 1, 1)

        # Buttons
        x=scale_factor/2
        scene.text('AI Easy', x=x, y=scale_factor*6 - x)
        scene.text('AI Hard', x=x, y=scale_factor*5 - x)
        scene.text('Get score', x=x, y=scale_factor*4 - x)
        if self.disp_score:
            scene.text(str(self.pos_score), x=x, y=scale_factor*4 - scale_factor/1.5)
        scene.text('Undo', x=x, y=scale_factor*3 - x)
        scene.text('Deselect', x=x, y=scale_factor*2 - x)
        scene.text('Options', x=x, y=scale_factor*7 - x)
示例#45
0
 def draw(self):
     scene.background(0, 0, 0)
     scene.fill(1, 0, 0)
     for touch in self.touches.values():
         x, y = touch.location
         scene.ellipse(x - 50, y - 50, 100, 100)
示例#46
0
 def draw(self, state):
     ui.fill(*COLORS["apple"])
     state.draw_cell(*self.pos)
示例#47
0
 def draw(self):
     scene.background(0,0,1) # 0,0,1 = blue
     scene.fill(0,1,0)       # 0,1,0 = green
     scene.rect(*self.rect1) # *self.rect1 = self.rect1[0], ..., self.rect1[3]
     scene.fill(1,0,0)       # 1,0,0 = red
     scene.rect(*self.rect2)
 def draw(self):
     self.update()
     scene.stroke(0, 0, 0)
     scene.fill(*self.color)
     scene.rect(*self.frame)
示例#49
0
    def draw(self):

        # HP bar player 1

        scene.fill("#000")
        scene.rect(100, 500, 200, 50)
        scene.fill("#4cd658")
        scene.rect(110, 510, hppercentage(player1), 30)

        # HP bar player 2

        scene.fill("#000")
        scene.rect(750, 500, 200, 50)
        scene.fill("#4cd658")
        scene.rect(760, 510, hppercentage(player2), 30)

        # Elemental sprites

        if player1['status'] != '':
            #self.pyro.alpha = 1
            setattr(getattr(self, '{}{}'.format(player1['status'], '1')),
                    'alpha', 1)  # en bedre måte å skrive det over
        else:
            setattr(getattr(self, 'pyro1'), 'alpha', 0)
            setattr(getattr(self, 'hydro1'), 'alpha', 0)
            setattr(getattr(self, 'cryo1'), 'alpha', 0)
            setattr(getattr(self, 'electro1'), 'alpha', 0)
            setattr(getattr(self, 'geo1'), 'alpha', 0)
            setattr(getattr(self, 'anemo1'), 'alpha', 0)
            setattr(getattr(self, 'dendro1'), 'alpha', 0)
        if player2['status'] != '':
            #self.pyro.alpha = 1
            setattr(getattr(self, '{}{}'.format(player2['status'], '2')),
                    'alpha', 1)
        else:
            setattr(getattr(self, 'pyro2'), 'alpha', 0)
            setattr(getattr(self, 'hydro2'), 'alpha', 0)
            setattr(getattr(self, 'cryo2'), 'alpha', 0)
            setattr(getattr(self, 'electro2'), 'alpha', 0)
            setattr(getattr(self, 'geo2'), 'alpha', 0)
            setattr(getattr(self, 'anemo2'), 'alpha', 0)
            setattr(getattr(self, 'dendro2'), 'alpha', 0)

        # DOTs

        try:
            if player1['isBurningRounds'] != 0:
                self.Player1DOT.text = 'Burning'
            else:
                self.Player1DOT.text = ''
        except:
            pass

        try:
            if player1['isElectroChargedRounds'] != 0:
                self.Player1DOT.text = 'Electro Charged'
            else:
                self.Player1DOT.text = ''
        except:
            pass

        try:
            if player1['isFrozenRounds'] != 0:
                self.Player1DOT.text = 'Frozen'
            else:
                self.Player1DOT.text = ''
        except:
            pass

        try:
            if player2['isBurningRounds'] != 0:
                self.Player2DOT.text = 'Burning'
            else:
                self.Player2DOT.text = ''
        except:
            pass

        try:
            if player2['isElectroChargedRounds'] != 0:
                self.Player2DOT.text = 'Electro Charged'
            else:
                self.Player2DOT.text = ''
        except:
            pass

        try:
            if player2['isFrozenRounds'] != 0:
                self.Player2DOT.text = 'Frozen'
            else:
                self.Player2DOT.text = ''
        except:
            pass

        # Attack #1-4 button
        scene.fill("#000")
        scene.rect(attack1x, attack1y, attackboxsizex, attackboxsizey)
        scene.rect(attack2x, attack2y, attackboxsizex, attackboxsizey)
        scene.rect(attack3x, attack3y, attackboxsizex, attackboxsizey)
        scene.rect(attack4x, attack4y, attackboxsizex, attackboxsizey)

        # Attack text

        if self.currentMover == 1:
            self.attack1label.text = player1['attacks']['attack1'][2]
            self.attack1label2.text = player1['attacks']['attack2'][2]
            self.attack1label3.text = player1['attacks']['attack3'][2]
            self.attack1label4.text = player1['attacks']['attack4'][2]
        else:
            self.attack1label.text = player2['attacks']['attack1'][2]
            self.attack1label2.text = player2['attacks']['attack2'][2]
            self.attack1label3.text = player2['attacks']['attack3'][2]
            self.attack1label4.text = player2['attacks']['attack4'][2]
示例#50
0
 def draw(self):
     scene.fill(1, 1, 0)
     scene.rect(*self.bounds)
示例#51
0
 def draw(self):
     scene.background(0, 0, 1)  # 0,0,1 = blue
     scene.fill(1, 0, 0)  # 1,0,0 = red
     scene.rect(50, 50, 50,
                50)  # you like circles, try scene.ellipse(50,50,50,50)
示例#52
0
    def draw(self):
        scale_factor = self.square_size
        scene.background(0, 0, 0)
        scene.fill(1, 1, 1, 1)
        board = self.game_view.game.board
        if self.render_mode['pieces']:
            for piece in board.pieces:
                scene.tint(1, 1, 1, 0.5)
                pos = self.as_screen(piece)  # piece.coord.as_screen
                #print(self.img_names)
                img = self.img_names[piece.name]
                scene.image(img, pos.x, pos.y, scale_factor, scale_factor)
                scene.tint(1, 1, 1, 1)
                if piece.fen_loc == self.selected:
                    scene.fill(0.23347, 0.3564, 0.59917, 0.6)
                    scene.rect(pos.x, pos.y, scale_factor, scale_factor)
                    scene.fill(1, 1, 1, 1)
            if self.render_mode['timers']:
                white = str(board.player1.timer.get_run())
                black = str(board.player2.timer.get_run())
                bpos = Coord(992, 672)
                wpos = Coord(992, 96)
                scene.tint(1, 1, 1, 1)
                scene.text(black, x=bpos.x, y=bpos.y)
                scene.text(white, x=wpos.x, y=wpos.y)
                scene.tint(1, 1, 1, 1)
        if self.render_mode['sqrs']:
            for tile in board.tiles:
                x = int(tile.color == 'white')  # zero or one Thi is code
                color = (x, x, x, 0.57)  # alpha value
                scene.fill(*color)
                pos = self.as_screen(tile)  # tile.as_screen
                scene.rect(pos.x, pos.y, scale_factor, scale_factor)
                scene.fill(1, 1, 1, 1)
                if self.render_mode['coords']:
                    center = Coord(pos.x + (scale_factor / 2),
                                   pos.y + (scale_factor / 2))
                    chess_pos = center + Coord(0, 10)
                    coord_pos = center - Coord(0, 10)
                    chess = tile.coord.as_chess
                    coord = str(tile.coord.as_tup)
                    scene.text(chess, x=chess_pos.x, y=chess_pos.y)
                    scene.text(coord, x=coord_pos.x, y=coord_pos.y)
            #if self.err_pos:  # FIXME this needs to be reenabled!
            #    sc = self.err_pos.as_screen
            #    scene.fill(1, 0, 0, 0.3)
            #    scene.rect(sc.x, sc.y, scale_factor, scale_factor)
            #    scene.fill(1, 1, 1, 1)
            #    scene.tint(0, 0, 1, 1)
            #    scene.text('Move\nInvalid', x=(sc.x + scale_factor/2), y=(sc.y + scale_factor/2))
            #    scene.tint(1, 1, 1, 1)
        if self.render_mode['valid']:
            for tile in board.tiles:
                #if self.valid_cache:
                #    print([x for x in self.valid_cache])
                #if tile.coord in self.valid_cache:  # FIXME
                if tile.fen_loc in self.valid_cache:
                    pos = self.as_screen(tile)  # tile.coord.as_screen
                    scene.fill(0.47934, 0.81198, 0.41839, 0.3)
                    scene.rect(pos.x, pos.y, scale_factor, scale_factor)
                    scene.fill(1, 1, 1, 1)
        if self.render_mode['turn_color']:
            if board.turn == 'white':
                turn_y = 1 * scale_factor
            elif board.turn == 'black':
                turn_y = 7 * scale_factor
            pos = Coord(896, turn_y)
            size = Coord(scale_factor / 2, scale_factor / 2)
            scene.tint(1, 1, 1, 1)
            scene.image(self.turn_indicator_img, pos.x, pos.y, size.x, size.y)
            scene.tint(1, 1, 1, 1)
        if self.won:
            pos = Coord(self.size.w / 2, self.size.h / 2)
            scene.tint(0.32645, 0.28306, 0.93492)
            # commented out until the bug in ChessGame.is_won() is fixed to be
            # less annoying
            scene.text('{} wins'.format(self.won),
                       x=pos.x,
                       y=pos.y,
                       font_size=40.0)
            scene.tint(1, 1, 1, 1)

        # Buttons
        x = scale_factor / 2
        scene.text('AI Easy', x=x, y=scale_factor * 6 - x)
        scene.text('AI Hard', x=x, y=scale_factor * 5 - x)
        scene.text('Get score', x=x, y=scale_factor * 4 - x)
        if self.disp_score:
            scene.text(str(self.pos_score),
                       x=x,
                       y=scale_factor * 4 - scale_factor / 1.5)
        scene.text('Undo', x=x, y=scale_factor * 3 - x)
        scene.text('Deselect', x=x, y=scale_factor * 2 - x)
        scene.text('Options', x=x, y=scale_factor * 7 - x)
示例#53
0
 def draw(self):
     scene.background(0, 0, 0)
     if self.touch:
         scene.fill(*self.dot_color)
         x, y = self.touch.location
         scene.ellipse(x - 50, y - 50, 100, 100)