Пример #1
0
   def draw_dummy(self):
      n = len(self.tile_matrix)  # n = number of rows = number of columns

      for row in range(n):
         for col in range(n):
            # draw each occupied tile (not equal to None) on the game grid

            if self.tile_matrix[row][col] != None:

                  dummy = Tile(Point(self.grid_width+col+1,self.grid_height-row-14))
                  dummy.number =  self.tile_matrix[row][col].number

                  dummy.draw()
Пример #2
0
def draw_board(dis: pygame.display, size: int, my_snake: Snake, my_snack: Snack):
    dis.fill((30, 32, 40))  # dark blue

    snake_pos_list = my_snake.get_pos()
    snack_pos = my_snack.get_pos()

    increment = min(display.get_size()) / size

    for y in range(size):
        for x in range(size):
            tile_size = increment - 2
            tile_pos = (x * increment, (-y + size - 1) * increment)
            tile = Tile(dis, tile_size, tile_pos)

            if (x, y) in snake_pos_list:
                tile.change_state('SNAKE')
            elif (x, y) == snack_pos:
                tile.change_state('SNACK')
            else:
                tile.change_state('BLANK')
            tile.draw()

    pygame.display.update()
Пример #3
0
 def draw(self):
     from visible import Window
     text = Window.instance.font_provider.render(self.text)
     self.setSize(text.get_size())
     Tile.draw(self)
     self.image.blit(text, (0, 0))
Пример #4
0
 def create_new_tile(self, x, y, value = 2):
     tile = Tile(self.canvas, x, y, value)
     self.board[x][y] = tile
     tile.draw()
Пример #5
0
background.fill((0,0,0))

pacman = PacMan((50,50), [500,200])
tile = Tile((150,150), [150,100])
tile2 = Tile((16,16), [300,300])

#GAMELOOP

while True:
	time_passed=clock.tick(30) #framerate du jeu
	#key_pressed=pygame.key.get_pressed()

	for event in pygame.event.get():
		if event.type == QUIT:
			exit()

	pacman.move()
	pacman.collide(tile)
	pacman.collide(tile2)


	screen.blit(background, (0,0))
	
	tile.draw(screen)
	tile2.draw(screen)
	pacman.draw(screen)


	#pygame.draw.circle(screen,(255,255,0),(x,y),16)
	pygame.display.update()