NightCafe AI Art
Crear

Todos los mejores modelos de IA en un solo lugar

Nano Banana, Imagen GPT, Flux, Seedream, Seedance y más. ¡Pruébalo ahora gratis!

Tetris Game in Pygame - A Colorful Block Puzzle
Tetris Game in Pygame - A Colorful Block Puzzle
2 years ago

import pygame import random # Constants WIDTH, HEIGHT = 300, 600 GRID_SIZE = 30 GRID_WIDTH = WIDTH // GRID_SIZE GRID_HEIGHT = HEIGHT // GRI...

Creado hace 2 years ago · 0 comentarios· 0 Me gusta

Dreamshaper XL Lightning

I put the entire tetris code as prompt
Avatar de Vincent
Resumen de creación por Vincent

Tetris Game in Pygame - A Colorful Block Puzzle

This image shows a vibrant and dynamic representation of a Tetris game in progress, featuring a variety of colorful blocks in mid-motion.

Creado por Dvdyrh el Jan 28, 2025 usando el modelo generador de imágenes de IA Dreamshaper XL Lightning.


Aún no hay comentarios

¡Sé el primero en responder!

Anonymous User

No comments yet.

Configuraciones de Creación

Prompts de texto
import pygame import random # Constants WIDTH, HEIGHT = 300, 600 GRID_SIZE = 30 GRID_WIDTH = WIDTH // GRID_SIZE GRID_HEIGHT = HEIGHT // GRID_SIZE FPS = 60 # Colors COLORS = [ (0, 0, 0), (255, 0, 0), (0, 150, 0), (0, 0, 255), (255, 120, 0), (255, 255, 0), (180, 0, 180), ...
Weight: 1
Modelo
Dreamshaper XL Lightning
CKPT

Dreamshaper XL Lightning

Resolución inicial

Medium

Relación de aspecto

1:1

Tiempo de ejecución

Short

Configuraciones de edición selectiva

Prompts

"import pygame import random # Constants WIDTH, HEIGHT = 300, 600 GRID_SIZE = 30 GRID_WIDTH = WIDTH // GRID_SIZE GRID_HEIGHT = HEIGHT // GRID_SIZE FPS = 60 # Colors COLORS = [ (0, 0, 0), (255, 0, 0), (0, 150, 0), (0, 0, 255), (255, 120, 0), (255, 255, 0), (180, 0, 180), (0, 220, 220) ] # Tetromino shapes SHAPES = [ [[1, 1, 1, 1]], # I [[1, 1], [1, 1]], # O [[1, 1, 1], [0, 1, 0]], # T [[1, 1, 1], [1, 0, 0]], # L [[1, 1, 1], [0, 0, 1]], # J [[1, 1, 0], [0, 1, 1]], # S [[0, 1, 1], [1, 1, 0]] # Z ] class Tetromino: def __init__(self): self.shape = random.choice(SHAPES) self.color = random.randint(1, len(COLORS)-1) self.x = GRID_WIDTH // 2 - len(self.shape[0])//2 self.y = 0 def rotate(self): self.shape = [list(row) for row in zip(*self.shape[::-1])] def create_grid(locked_pos={}): grid = [[(0,0,0) for _ in range(GRID_WIDTH)] for _ in range(GRID_HEIGHT)] for y in range(GRID_HEIGHT): for x in range(GRID_WIDTH): if (x, y) in locked_pos: grid[y][x] = locked_pos[(x,y)] return grid def draw_grid(surface, grid): for y in range(GRID_HEIGHT): for x in range(GRID_WIDTH): pygame.draw.rect(surface, grid[y][x], (x*GRID_SIZE, y*GRID_SIZE, GRID_SIZE-1, GRID_SIZE-1)) def valid_space(shape, pos): for y, row in enumerate(shape): for x, cell in enumerate(row): if cell: if x + pos[0] < 0 or x + pos[0] >= GRID_WIDTH: return False if y + pos[1] >= GRID_HEIGHT: return False if (x + pos[0], y + pos[1]) in locked_positions: return False return True def clear_rows(grid, locked): full_rows = [] for y, row in enumerate(grid): if (0,0,0) not in row: full_rows.append(y) for y in full_rows: for x in range(GRID_WIDTH): del locked[(x, y)] shifted_lock = {} for (x, y) in locked: new_y = y for dy in full_rows: if y < dy: new_y += 1 shifted_lock[(x, new_y)] = locked[(x, y)] return len(full_rows), shifted_lock # Initialize Pygame pygame.init() screen = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption("Python Tetris") clock = pygame.time.Clock() locked_positions = {} current_piece = Tetromino() fall_time = 0 score = 0 running = True while running: screen.fill((0,0,0)) grid = create_grid(locked_positions) fall_speed = 0.27 for event in pygame.event.get(): if event.type == pygame.QUIT: running = False if event.type == pygame.KEYDOWN: if event.key == pygame.K_LEFT: current_piece.x -= 1 if not valid_space(current_piece.shape, (current_piece.x, current_piece.y)): current_piece.x += 1 if event.key == pygame.K_RIGHT: current_piece.x += 1 if not valid_space(current_piece.shape, (current_piece.x, current_piece.y)): current_piece.x -= 1 if event.key == pygame.K_DOWN: current_piece.y += 1 if not valid_space(current_piece.shape, (current_piece.x, current_piece.y)): current_piece.y -= 1 if event.key == pygame.K_UP: current_piece.rotate() if not valid_space(current_piece.shape, (current_piece.x, current_piece.y)): current_piece.rotate() # Piece falling fall_time += clock.get_rawtime() clock.tick() if fall_time/1000 > fall_speed: fall_time = 0 current_piece.y += 1 if not valid_space(current_piece.shape, (current_piece.x, current_piece.y)): current_piece.y -= 1 for y, row in enumerate(current_piece.shape): for x, cell in enumerate(row): if cell: locked_positions[(current_piece.x + x, current_piece.y + y)] = COLORS[current_piece.color] cleared, locked_positions = clear_rows(grid, locked_positions) score += cleared * 100 current_piece = Tetromino() if not valid_space(current_piece.shape, (current_piece.x, current_piece.y)): running = False # Drawing draw_grid(screen, grid) for y, row in enumerate(current_piece.shape): for x, cell in enumerate(row): if cell: pygame.draw.rect(screen, COLORS[current_piece.color], ((current_piece.x + x)*GRID_SIZE, (current_piece.y + y)*GRID_SIZE, GRID_SIZE-1, GRID_SIZE-1)) pygame.display.update() pygame.quit( Text saying tetris.py"

peso: 1

Tipo de Inpainting

Inpainting

Imagen de inicio (enmascarada)
import pygame
import random

# Constants
WIDTH, HEIGHT = 300, 600
GRID_SIZE = 30
GRID_WIDTH = WIDTH // GRID_SIZE
GRID_HEIGHT = HEIGHT // GRI...
Máscara

Más Creaciones

Siempre hay más por explorar

3
Cyberpunk Goddess in Neon Dreamscape
2
Resilient Elderly Woman Stands Firm in Icy Storm
0
Confident Female Figure in Bikini on Sunny Argentinian Beach
3
romeo and juliet