Skip to content
View etesech29's full-sized avatar

Block or report etesech29

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Please don't include any personal information such as legal names or email addresses. Maximum 100 characters, markdown supported. This note will be visible to only you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse
etesech29/README.md

import pygame import random

Inicializar Pygame

pygame.init()

Configuración de la pantalla

SCREEN_WIDTH = 300 SCREEN_HEIGHT = 600 SCREEN = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT)) pygame.display.set_caption("Tetris")

Colores

WHITE = (255, 255, 255) BLACK = (0, 0, 0)

Formas de Tetris (cubos)

tetris_shapes = [ [[1, 1, 1], [0, 1, 0]], [[0, 1, 1], [1, 1, 0]], [[1, 1], [1, 1]], [[1, 1, 1, 1]], [[1], [1], [1], [1]], ]

Función para crear una forma aleatoria

def create_shape(): shape = random.choice(tetris_shapes) color = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) return shape, color

Función para dibujar una forma en la pantalla

def draw_shape(shape, x, y, color): for row in range(len(shape)): for col in range(len(shape[row])): if shape[row][col] != 0: pygame.draw.rect(SCREEN, color, pygame.Rect((x + col) * 30, (y + row) * 30, 30, 30))

Loop principal del juego

def main(): clock = pygame.time.Clock() shape, color = create_shape() x, y = 4, 0

while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            quit()

    keys = pygame.key.get_pressed()
    if keys[pygame.K_LEFT]:
        x -= 1
    if keys[pygame.K_RIGHT]:
        x += 1
    if keys[pygame.K_DOWN]:
        y += 1

    SCREEN.fill(BLACK)
    draw_shape(shape, x, y, color)
    pygame.display.update()

    clock.tick(5)

if name == "main": main()

Popular repositories Loading

  1. etesech29 etesech29 Public

    Config files for my GitHub profile.

  2. donvitelio donvitelio Public

  3. ghwdoughds0igd ghwdoughds0igd Public

  4. SendScriptWhatsApp SendScriptWhatsApp Public

    Forked from Matt-Fontes/SendScriptWhatsApp

    Script para enviar o Roteiro do filme Shrek, linha por linha, no WhatsApp

    JavaScript