JustPaste
HomeCategoriesAboutDonateContactTerms of UsePrivacy Policy
JustPaste

Free online notepad — write and share instantly

Navigate

  • Home
  • Timeline
  • Categories

Info

  • About
  • Donate
  • Contact

Legal

  • Terms of Use
  • Privacy Policy

© 2026 JustPaste.app. All rights reserved.

Made with ♥ by JustPaste

Untitled Page | JustPaste.app
3 months ago34 views
👨‍💻Programming

import pygame
import random
pygame.init()
screen = pygame.display.set_mode((600, 400))
clock = pygame.time.Clock()
# Create cat objects
cats = []
for _ in range(4):
cats.append({
"x": random.randint(50, 550),
"y": random.randint(50, 350),
"dx": random.choice([-2, 2]),
"dy": random.choice([-2, 2])
})
def draw_cat(x, y):
# Face
pygame.draw.circle(screen, (200, 150, 150), (x, y), 18)
# Ears
pygame.draw.polygon(screen, (200, 150, 150),
[(x-15, y-10), (x-5, y-30), (x, y-10)])
pygame.draw.polygon(screen, (200, 150, 150),
[(x+15, y-10), (x+5, y-30), (x, y-10)])

# Eyes
pygame.draw.circle(screen, (0, 0, 0), (x-6, y-3), 2)
pygame.draw.circle(screen, (0, 0, 0), (x+6, y-3), 2)
running = True
while running:
screen.fill((255, 255, 255))
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
for cat in cats:
cat["x"] += cat["dx"]

cat["y"] += cat["dy"]
# Bounce off walls
if cat["x"] <= 20 or cat["x"] >= 580:
cat["dx"] *= -1
if cat["y"] <= 30 or cat["y"] >= 380:
cat["dy"] *= -1
draw_cat(cat["x"], cat["y"])
pygame.display.update()
clock.tick(60)
pygame.quit()
← Back to timeline