Añade nuevas funciones a este juego, sin utilizar archivos externos: import pygame…
Private research annotation
Sign in to add a private research label or note.
- User
Añade nuevas funciones a este juego, sin utilizar archivos externos:
import pygame import time import random
Inicia pygame
pygame.init()
Colores
white = (255, 255, 255) yellow = (255, 255, 102) black = (0, 0, 0) red = (213, 50, 80) green = (0, 255, 0) blue = (50, 153, 213)
Dimensiones de la pantalla
dis_width = 600 dis_height = 400
Configuración de la pantalla
dis = pygame.display.set_mode((dis_width, dis_height)) pygame.display.set_caption('Juego de Snake por Column AI')
Reloj para controlar la velocidad del juego
clock = pygame.time.Clock()
Tamaño de la snake y velocidad
snake_block = 10 snake_speed = 15
Fuentes para el texto
font_style = pygame.font.SysFont(None, 50) score_font = pygame.font.SysFont(None, 35)
def our_snake(snake_block, snake_list): for x in snake_list: pygame.draw.rect(dis, black, [x[0], x[1], snake_block, snake_block])
def message(msg, color): mesg = font_style.render(msg, True, color) dis.blit(mesg, [dis_width / 6, dis_height / 3])
def draw_score(score): value = score_font.render("Puntuación: " + str(score), True, black) dis.blit(value, [0, 0])
def gameLoop(): game_over = False game_close = False
code Assistant
- User
Dame el codigo entero por favor
Assistant