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)
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,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)
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)
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): 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)
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
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
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
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")
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)
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'])
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)
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 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, )
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)
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
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)
def draw_cell(self, x, y): w, h = CELL ui.rect(self.bounds.x + x * w, self.bounds.y + y * h, w, h)
def rect(rectangle, borderw=0, borderclr=(0, 0, 0)): scene.stroke(*borderclr) scene.stroke_weight(borderw) scene.rect(*rectangle)
def draw(self): self.update() scene.stroke(0, 0, 0) scene.fill(*self.color) scene.rect(*self.frame)
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)
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]
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
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)
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)
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)
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)
def draw(self): scene.fill(*self.colour) scene.rect(self.x, self.y, 8, 8)
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)
def draw(self): scene.fill(1, 1, 0) scene.rect(*self.bounds)