3D Workspace
Home
Assets
Affiliate Program
Sign up/Log in
?
Upgrade
DCC Bridge
Anonymous1762589921
11-08 08:19
Model Name
arcade basketball cabinet 3d model
Tags
machine
game asset
stylized
Prompt
import pygame import random pygame.init() # Screen setup WIDTH, HEIGHT = 800, 600 screen = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption("Ball Catch Game") # Colors WHITE = (255, 255, 255) RED = (255, 0, 0) BLUE = (0, 0, 255) # Basket setup basket = pygame.Rect(WIDTH//2 - 50, HEIGHT - 50, 100, 20) # Ball setup ball = pygame.Rect(random.randint(0, WIDTH-20), 0, 20, 20) ball_speed = 5 score = 0 font = pygame.font.SysFont(None, 40) # Main loop running = True while running: screen.fill(WHITE) for event in pygame.event.get(): if event.type == pygame.QUIT: running = False # Basket movement keys = pygame.key.get_pressed() if keys[pygame.K_LEFT] and basket.left > 0: basket.move_ip(-8, 0) if keys[pygame.K_RIGHT] and basket.right < WIDTH: basket.move_ip(8, 0) # Ball falling ball.move_ip(0, ball_speed) if ball.top > HEIGHT: ball.x = random.randint(0, WIDTH-20) ball.y = 0 # Collision if ball.colliderect(basket): score += 1 ball.x = random.randint(0, WIDTH-20) ball.y = 0 # Draw objects pygame.draw.rect(screen, BLUE, basket) pygame.draw.ellipse(screen, RED, ball) score_text = font.render(f"Score: {score}", True, (0,0,0)) screen.blit(score_text, (10,10)) pygame.display.flip() pygame.time.Clock().tick(30) pygame.quit()
Detailed Info
Related Models
Enter invite code
Enter invite code to get credits!