Qwen3-235B-A22B-Instruct-2507-gguf-q2ks-mixed-AutoRound
428
11
235.0B
license:apache-2.0
by
Intel
Other
OTHER
235B params
New
428 downloads
Early-stage
Edge AI:
Mobile
Laptop
Server
526GB+ RAM
Mobile
Laptop
Server
Quick Summary
This model is a mixed gguf:q2ks of Qwen/Qwen3-235B-A22B-Instruct-2507 generated by intel/auto-round algorithm.
Device Compatibility
Mobile
4-6GB RAM
Laptop
16GB RAM
Server
GPU
Minimum Recommended
219GB+ RAM
Code Examples
š§ Requirements:bash
pip install pygameš§ Requirements:bash
pip install pygameš§ Requirements:bash
pip install pygameš§ Requirements:bash
pip install pygameš§ Requirements:bash
pip install pygameš§ Requirements:bash
pip install pygameš§ Requirements:bash
pip install pygameš§ Requirements:bash
pip install pygameš§ Requirements:bash
pip install pygameš§ Requirements:bash
pip install pygameš§ Requirements:bash
pip install pygameš§ Requirements:bash
pip install pygameš§ Requirements:bash
pip install pygameš§ Requirements:bash
pip install pygameš§ Requirements:bash
pip install pygameš§ Requirements:bash
pip install pygameš§ Requirements:bash
pip install pygameš§ Requirements:bash
pip install pygameš§ Requirements:bash
pip install pygameš§ Requirements:bash
pip install pygameš§ Requirements:bash
pip install pygameš§ Requirements:bash
pip install pygameš§ Requirements:bash
pip install pygameš§ Requirements:bash
pip install pygameš§ Requirements:bash
pip install pygameš§ Requirements:bash
pip install pygameš§ Requirements:bash
pip install pygameš§ Requirements:python
import pygame
import random
import sys
# Initialize Pygame
pygame.init()
# Screen dimensions
WIDTH, HEIGHT = 400, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Flappy Bird")
# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
GREEN = (0, 128, 0)
SKY_BLUE = (135, 206, 235)
# Game settings
GRAVITY = 0.5
FLAP_STRENGTH = -10
PIPE_SPEED = 3
PIPE_GAP = 150
PIPE_FREQUENCY = 1500 # milliseconds
# Bird class
class Bird:
def __init__(self):
self.x = 50
self.y = HEIGHT // 2
self.velocity = 0
self.width = 20
self.height = 20
def flap(self):
self.velocity = FLAP_STRENGTH
def update(self):
self.velocity += GRAVITY
self.y += self.velocity
if self.y < 0:
self.y = 0
if self.y > HEIGHT:
self.y = HEIGHT
def draw(self):
pygame.draw.circle(screen, BLACK, (self.x, int(self.y)), self.width // 2)
# Pipe class
class Pipe:
def __init__(self):
self.x = WIDTH
self.top = random.randint(50, HEIGHT - PIPE_GAP - 50)
self.bottom = self.top + PIPE_GAP
self.width = 50
self.passed = False
def update(self):
self.x -= PIPE_SPEED
return self.x > -self.width
def draw(self):
pygame.draw.rect(screen, GREEN, (self.x, 0, self.width, self.top))
pygame.draw.rect(screen, GREEN, (self.x, self.bottom, self.width, HEIGHT - self.bottom))
def collide(self, bird):
if bird.x + bird.width // 2 > self.x and bird.x - bird.width // 2 < self.x + self.width:
if bird.y - bird.height // 2 < self.top or bird.y + bird.height // 2 > self.bottom:
return True
return False
# Main game loop
def game():
bird = Bird()
pipes = []
score = 0
clock = pygame.time.Clock()
last_pipe = pygame.time.get_ticks()
running = True
game_active = True
font = pygame.font.SysFont(None, 55)
while running:
screen.fill(SKY_BLUE)
dt = clock.tick(60)
current_time = pygame.time.get_ticks()
# Event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE and game_active:
bird.flap()
if event.key == pygame.K_r and not game_active:
game()
if game_active:
# Update bird
bird.update()
# Generate new pipes
if current_time - last_pipe > PIPE_FREQUENCY:
pipes.append(Pipe())
last_pipe = current_time
# Update and draw pipes
pipes = [p for p in pipes if p.update()]
for pipe in pipes:
pipe.draw()
if pipe.collide(bird):
game_active = False
# Score logic
if pipe.x + pipe.width < bird.x and not pipe.passed:
score += 1
pipe.passed = True
# Draw bird
bird.draw()
# Check if bird hits the ground or flies too high
if bird.y >= HEIGHT or bird.y <= 0:
game_active = False
# Display score
score_text = font.render(f"Score: {score}", True, BLACK)
screen.blit(score_text, (10, 10))
else:
# Game over screen
game_over_text = font.render("Game Over!", True, BLACK)
restart_text = font.render("Press 'R' to Restart", True, BLACK)
screen.blit(game_over_text, (WIDTH // 2 - 90, HEIGHT // 2 - 50))
screen.blit(restart_text, (WIDTH // 2 - 150, HEIGHT // 2 + 10))
pygame.display.update()
# Start the game
game()š§ Requirements:python
import pygame
import random
import sys
# Initialize Pygame
pygame.init()
# Screen dimensions
WIDTH, HEIGHT = 400, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Flappy Bird")
# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
GREEN = (0, 128, 0)
SKY_BLUE = (135, 206, 235)
# Game settings
GRAVITY = 0.5
FLAP_STRENGTH = -10
PIPE_SPEED = 3
PIPE_GAP = 150
PIPE_FREQUENCY = 1500 # milliseconds
# Bird class
class Bird:
def __init__(self):
self.x = 50
self.y = HEIGHT // 2
self.velocity = 0
self.width = 20
self.height = 20
def flap(self):
self.velocity = FLAP_STRENGTH
def update(self):
self.velocity += GRAVITY
self.y += self.velocity
if self.y < 0:
self.y = 0
if self.y > HEIGHT:
self.y = HEIGHT
def draw(self):
pygame.draw.circle(screen, BLACK, (self.x, int(self.y)), self.width // 2)
# Pipe class
class Pipe:
def __init__(self):
self.x = WIDTH
self.top = random.randint(50, HEIGHT - PIPE_GAP - 50)
self.bottom = self.top + PIPE_GAP
self.width = 50
self.passed = False
def update(self):
self.x -= PIPE_SPEED
return self.x > -self.width
def draw(self):
pygame.draw.rect(screen, GREEN, (self.x, 0, self.width, self.top))
pygame.draw.rect(screen, GREEN, (self.x, self.bottom, self.width, HEIGHT - self.bottom))
def collide(self, bird):
if bird.x + bird.width // 2 > self.x and bird.x - bird.width // 2 < self.x + self.width:
if bird.y - bird.height // 2 < self.top or bird.y + bird.height // 2 > self.bottom:
return True
return False
# Main game loop
def game():
bird = Bird()
pipes = []
score = 0
clock = pygame.time.Clock()
last_pipe = pygame.time.get_ticks()
running = True
game_active = True
font = pygame.font.SysFont(None, 55)
while running:
screen.fill(SKY_BLUE)
dt = clock.tick(60)
current_time = pygame.time.get_ticks()
# Event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE and game_active:
bird.flap()
if event.key == pygame.K_r and not game_active:
game()
if game_active:
# Update bird
bird.update()
# Generate new pipes
if current_time - last_pipe > PIPE_FREQUENCY:
pipes.append(Pipe())
last_pipe = current_time
# Update and draw pipes
pipes = [p for p in pipes if p.update()]
for pipe in pipes:
pipe.draw()
if pipe.collide(bird):
game_active = False
# Score logic
if pipe.x + pipe.width < bird.x and not pipe.passed:
score += 1
pipe.passed = True
# Draw bird
bird.draw()
# Check if bird hits the ground or flies too high
if bird.y >= HEIGHT or bird.y <= 0:
game_active = False
# Display score
score_text = font.render(f"Score: {score}", True, BLACK)
screen.blit(score_text, (10, 10))
else:
# Game over screen
game_over_text = font.render("Game Over!", True, BLACK)
restart_text = font.render("Press 'R' to Restart", True, BLACK)
screen.blit(game_over_text, (WIDTH // 2 - 90, HEIGHT // 2 - 50))
screen.blit(restart_text, (WIDTH // 2 - 150, HEIGHT // 2 + 10))
pygame.display.update()
# Start the game
game()š§ Requirements:python
import pygame
import random
import sys
# Initialize Pygame
pygame.init()
# Screen dimensions
WIDTH, HEIGHT = 400, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Flappy Bird")
# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
GREEN = (0, 128, 0)
SKY_BLUE = (135, 206, 235)
# Game settings
GRAVITY = 0.5
FLAP_STRENGTH = -10
PIPE_SPEED = 3
PIPE_GAP = 150
PIPE_FREQUENCY = 1500 # milliseconds
# Bird class
class Bird:
def __init__(self):
self.x = 50
self.y = HEIGHT // 2
self.velocity = 0
self.width = 20
self.height = 20
def flap(self):
self.velocity = FLAP_STRENGTH
def update(self):
self.velocity += GRAVITY
self.y += self.velocity
if self.y < 0:
self.y = 0
if self.y > HEIGHT:
self.y = HEIGHT
def draw(self):
pygame.draw.circle(screen, BLACK, (self.x, int(self.y)), self.width // 2)
# Pipe class
class Pipe:
def __init__(self):
self.x = WIDTH
self.top = random.randint(50, HEIGHT - PIPE_GAP - 50)
self.bottom = self.top + PIPE_GAP
self.width = 50
self.passed = False
def update(self):
self.x -= PIPE_SPEED
return self.x > -self.width
def draw(self):
pygame.draw.rect(screen, GREEN, (self.x, 0, self.width, self.top))
pygame.draw.rect(screen, GREEN, (self.x, self.bottom, self.width, HEIGHT - self.bottom))
def collide(self, bird):
if bird.x + bird.width // 2 > self.x and bird.x - bird.width // 2 < self.x + self.width:
if bird.y - bird.height // 2 < self.top or bird.y + bird.height // 2 > self.bottom:
return True
return False
# Main game loop
def game():
bird = Bird()
pipes = []
score = 0
clock = pygame.time.Clock()
last_pipe = pygame.time.get_ticks()
running = True
game_active = True
font = pygame.font.SysFont(None, 55)
while running:
screen.fill(SKY_BLUE)
dt = clock.tick(60)
current_time = pygame.time.get_ticks()
# Event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE and game_active:
bird.flap()
if event.key == pygame.K_r and not game_active:
game()
if game_active:
# Update bird
bird.update()
# Generate new pipes
if current_time - last_pipe > PIPE_FREQUENCY:
pipes.append(Pipe())
last_pipe = current_time
# Update and draw pipes
pipes = [p for p in pipes if p.update()]
for pipe in pipes:
pipe.draw()
if pipe.collide(bird):
game_active = False
# Score logic
if pipe.x + pipe.width < bird.x and not pipe.passed:
score += 1
pipe.passed = True
# Draw bird
bird.draw()
# Check if bird hits the ground or flies too high
if bird.y >= HEIGHT or bird.y <= 0:
game_active = False
# Display score
score_text = font.render(f"Score: {score}", True, BLACK)
screen.blit(score_text, (10, 10))
else:
# Game over screen
game_over_text = font.render("Game Over!", True, BLACK)
restart_text = font.render("Press 'R' to Restart", True, BLACK)
screen.blit(game_over_text, (WIDTH // 2 - 90, HEIGHT // 2 - 50))
screen.blit(restart_text, (WIDTH // 2 - 150, HEIGHT // 2 + 10))
pygame.display.update()
# Start the game
game()š§ Requirements:python
import pygame
import random
import sys
# Initialize Pygame
pygame.init()
# Screen dimensions
WIDTH, HEIGHT = 400, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Flappy Bird")
# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
GREEN = (0, 128, 0)
SKY_BLUE = (135, 206, 235)
# Game settings
GRAVITY = 0.5
FLAP_STRENGTH = -10
PIPE_SPEED = 3
PIPE_GAP = 150
PIPE_FREQUENCY = 1500 # milliseconds
# Bird class
class Bird:
def __init__(self):
self.x = 50
self.y = HEIGHT // 2
self.velocity = 0
self.width = 20
self.height = 20
def flap(self):
self.velocity = FLAP_STRENGTH
def update(self):
self.velocity += GRAVITY
self.y += self.velocity
if self.y < 0:
self.y = 0
if self.y > HEIGHT:
self.y = HEIGHT
def draw(self):
pygame.draw.circle(screen, BLACK, (self.x, int(self.y)), self.width // 2)
# Pipe class
class Pipe:
def __init__(self):
self.x = WIDTH
self.top = random.randint(50, HEIGHT - PIPE_GAP - 50)
self.bottom = self.top + PIPE_GAP
self.width = 50
self.passed = False
def update(self):
self.x -= PIPE_SPEED
return self.x > -self.width
def draw(self):
pygame.draw.rect(screen, GREEN, (self.x, 0, self.width, self.top))
pygame.draw.rect(screen, GREEN, (self.x, self.bottom, self.width, HEIGHT - self.bottom))
def collide(self, bird):
if bird.x + bird.width // 2 > self.x and bird.x - bird.width // 2 < self.x + self.width:
if bird.y - bird.height // 2 < self.top or bird.y + bird.height // 2 > self.bottom:
return True
return False
# Main game loop
def game():
bird = Bird()
pipes = []
score = 0
clock = pygame.time.Clock()
last_pipe = pygame.time.get_ticks()
running = True
game_active = True
font = pygame.font.SysFont(None, 55)
while running:
screen.fill(SKY_BLUE)
dt = clock.tick(60)
current_time = pygame.time.get_ticks()
# Event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE and game_active:
bird.flap()
if event.key == pygame.K_r and not game_active:
game()
if game_active:
# Update bird
bird.update()
# Generate new pipes
if current_time - last_pipe > PIPE_FREQUENCY:
pipes.append(Pipe())
last_pipe = current_time
# Update and draw pipes
pipes = [p for p in pipes if p.update()]
for pipe in pipes:
pipe.draw()
if pipe.collide(bird):
game_active = False
# Score logic
if pipe.x + pipe.width < bird.x and not pipe.passed:
score += 1
pipe.passed = True
# Draw bird
bird.draw()
# Check if bird hits the ground or flies too high
if bird.y >= HEIGHT or bird.y <= 0:
game_active = False
# Display score
score_text = font.render(f"Score: {score}", True, BLACK)
screen.blit(score_text, (10, 10))
else:
# Game over screen
game_over_text = font.render("Game Over!", True, BLACK)
restart_text = font.render("Press 'R' to Restart", True, BLACK)
screen.blit(game_over_text, (WIDTH // 2 - 90, HEIGHT // 2 - 50))
screen.blit(restart_text, (WIDTH // 2 - 150, HEIGHT // 2 + 10))
pygame.display.update()
# Start the game
game()š§ Requirements:python
import pygame
import random
import sys
# Initialize Pygame
pygame.init()
# Screen dimensions
WIDTH, HEIGHT = 400, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Flappy Bird")
# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
GREEN = (0, 128, 0)
SKY_BLUE = (135, 206, 235)
# Game settings
GRAVITY = 0.5
FLAP_STRENGTH = -10
PIPE_SPEED = 3
PIPE_GAP = 150
PIPE_FREQUENCY = 1500 # milliseconds
# Bird class
class Bird:
def __init__(self):
self.x = 50
self.y = HEIGHT // 2
self.velocity = 0
self.width = 20
self.height = 20
def flap(self):
self.velocity = FLAP_STRENGTH
def update(self):
self.velocity += GRAVITY
self.y += self.velocity
if self.y < 0:
self.y = 0
if self.y > HEIGHT:
self.y = HEIGHT
def draw(self):
pygame.draw.circle(screen, BLACK, (self.x, int(self.y)), self.width // 2)
# Pipe class
class Pipe:
def __init__(self):
self.x = WIDTH
self.top = random.randint(50, HEIGHT - PIPE_GAP - 50)
self.bottom = self.top + PIPE_GAP
self.width = 50
self.passed = False
def update(self):
self.x -= PIPE_SPEED
return self.x > -self.width
def draw(self):
pygame.draw.rect(screen, GREEN, (self.x, 0, self.width, self.top))
pygame.draw.rect(screen, GREEN, (self.x, self.bottom, self.width, HEIGHT - self.bottom))
def collide(self, bird):
if bird.x + bird.width // 2 > self.x and bird.x - bird.width // 2 < self.x + self.width:
if bird.y - bird.height // 2 < self.top or bird.y + bird.height // 2 > self.bottom:
return True
return False
# Main game loop
def game():
bird = Bird()
pipes = []
score = 0
clock = pygame.time.Clock()
last_pipe = pygame.time.get_ticks()
running = True
game_active = True
font = pygame.font.SysFont(None, 55)
while running:
screen.fill(SKY_BLUE)
dt = clock.tick(60)
current_time = pygame.time.get_ticks()
# Event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE and game_active:
bird.flap()
if event.key == pygame.K_r and not game_active:
game()
if game_active:
# Update bird
bird.update()
# Generate new pipes
if current_time - last_pipe > PIPE_FREQUENCY:
pipes.append(Pipe())
last_pipe = current_time
# Update and draw pipes
pipes = [p for p in pipes if p.update()]
for pipe in pipes:
pipe.draw()
if pipe.collide(bird):
game_active = False
# Score logic
if pipe.x + pipe.width < bird.x and not pipe.passed:
score += 1
pipe.passed = True
# Draw bird
bird.draw()
# Check if bird hits the ground or flies too high
if bird.y >= HEIGHT or bird.y <= 0:
game_active = False
# Display score
score_text = font.render(f"Score: {score}", True, BLACK)
screen.blit(score_text, (10, 10))
else:
# Game over screen
game_over_text = font.render("Game Over!", True, BLACK)
restart_text = font.render("Press 'R' to Restart", True, BLACK)
screen.blit(game_over_text, (WIDTH // 2 - 90, HEIGHT // 2 - 50))
screen.blit(restart_text, (WIDTH // 2 - 150, HEIGHT // 2 + 10))
pygame.display.update()
# Start the game
game()š§ Requirements:python
import pygame
import random
import sys
# Initialize Pygame
pygame.init()
# Screen dimensions
WIDTH, HEIGHT = 400, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Flappy Bird")
# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
GREEN = (0, 128, 0)
SKY_BLUE = (135, 206, 235)
# Game settings
GRAVITY = 0.5
FLAP_STRENGTH = -10
PIPE_SPEED = 3
PIPE_GAP = 150
PIPE_FREQUENCY = 1500 # milliseconds
# Bird class
class Bird:
def __init__(self):
self.x = 50
self.y = HEIGHT // 2
self.velocity = 0
self.width = 20
self.height = 20
def flap(self):
self.velocity = FLAP_STRENGTH
def update(self):
self.velocity += GRAVITY
self.y += self.velocity
if self.y < 0:
self.y = 0
if self.y > HEIGHT:
self.y = HEIGHT
def draw(self):
pygame.draw.circle(screen, BLACK, (self.x, int(self.y)), self.width // 2)
# Pipe class
class Pipe:
def __init__(self):
self.x = WIDTH
self.top = random.randint(50, HEIGHT - PIPE_GAP - 50)
self.bottom = self.top + PIPE_GAP
self.width = 50
self.passed = False
def update(self):
self.x -= PIPE_SPEED
return self.x > -self.width
def draw(self):
pygame.draw.rect(screen, GREEN, (self.x, 0, self.width, self.top))
pygame.draw.rect(screen, GREEN, (self.x, self.bottom, self.width, HEIGHT - self.bottom))
def collide(self, bird):
if bird.x + bird.width // 2 > self.x and bird.x - bird.width // 2 < self.x + self.width:
if bird.y - bird.height // 2 < self.top or bird.y + bird.height // 2 > self.bottom:
return True
return False
# Main game loop
def game():
bird = Bird()
pipes = []
score = 0
clock = pygame.time.Clock()
last_pipe = pygame.time.get_ticks()
running = True
game_active = True
font = pygame.font.SysFont(None, 55)
while running:
screen.fill(SKY_BLUE)
dt = clock.tick(60)
current_time = pygame.time.get_ticks()
# Event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE and game_active:
bird.flap()
if event.key == pygame.K_r and not game_active:
game()
if game_active:
# Update bird
bird.update()
# Generate new pipes
if current_time - last_pipe > PIPE_FREQUENCY:
pipes.append(Pipe())
last_pipe = current_time
# Update and draw pipes
pipes = [p for p in pipes if p.update()]
for pipe in pipes:
pipe.draw()
if pipe.collide(bird):
game_active = False
# Score logic
if pipe.x + pipe.width < bird.x and not pipe.passed:
score += 1
pipe.passed = True
# Draw bird
bird.draw()
# Check if bird hits the ground or flies too high
if bird.y >= HEIGHT or bird.y <= 0:
game_active = False
# Display score
score_text = font.render(f"Score: {score}", True, BLACK)
screen.blit(score_text, (10, 10))
else:
# Game over screen
game_over_text = font.render("Game Over!", True, BLACK)
restart_text = font.render("Press 'R' to Restart", True, BLACK)
screen.blit(game_over_text, (WIDTH // 2 - 90, HEIGHT // 2 - 50))
screen.blit(restart_text, (WIDTH // 2 - 150, HEIGHT // 2 + 10))
pygame.display.update()
# Start the game
game()š§ Requirements:python
import pygame
import random
import sys
# Initialize Pygame
pygame.init()
# Screen dimensions
WIDTH, HEIGHT = 400, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Flappy Bird")
# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
GREEN = (0, 128, 0)
SKY_BLUE = (135, 206, 235)
# Game settings
GRAVITY = 0.5
FLAP_STRENGTH = -10
PIPE_SPEED = 3
PIPE_GAP = 150
PIPE_FREQUENCY = 1500 # milliseconds
# Bird class
class Bird:
def __init__(self):
self.x = 50
self.y = HEIGHT // 2
self.velocity = 0
self.width = 20
self.height = 20
def flap(self):
self.velocity = FLAP_STRENGTH
def update(self):
self.velocity += GRAVITY
self.y += self.velocity
if self.y < 0:
self.y = 0
if self.y > HEIGHT:
self.y = HEIGHT
def draw(self):
pygame.draw.circle(screen, BLACK, (self.x, int(self.y)), self.width // 2)
# Pipe class
class Pipe:
def __init__(self):
self.x = WIDTH
self.top = random.randint(50, HEIGHT - PIPE_GAP - 50)
self.bottom = self.top + PIPE_GAP
self.width = 50
self.passed = False
def update(self):
self.x -= PIPE_SPEED
return self.x > -self.width
def draw(self):
pygame.draw.rect(screen, GREEN, (self.x, 0, self.width, self.top))
pygame.draw.rect(screen, GREEN, (self.x, self.bottom, self.width, HEIGHT - self.bottom))
def collide(self, bird):
if bird.x + bird.width // 2 > self.x and bird.x - bird.width // 2 < self.x + self.width:
if bird.y - bird.height // 2 < self.top or bird.y + bird.height // 2 > self.bottom:
return True
return False
# Main game loop
def game():
bird = Bird()
pipes = []
score = 0
clock = pygame.time.Clock()
last_pipe = pygame.time.get_ticks()
running = True
game_active = True
font = pygame.font.SysFont(None, 55)
while running:
screen.fill(SKY_BLUE)
dt = clock.tick(60)
current_time = pygame.time.get_ticks()
# Event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE and game_active:
bird.flap()
if event.key == pygame.K_r and not game_active:
game()
if game_active:
# Update bird
bird.update()
# Generate new pipes
if current_time - last_pipe > PIPE_FREQUENCY:
pipes.append(Pipe())
last_pipe = current_time
# Update and draw pipes
pipes = [p for p in pipes if p.update()]
for pipe in pipes:
pipe.draw()
if pipe.collide(bird):
game_active = False
# Score logic
if pipe.x + pipe.width < bird.x and not pipe.passed:
score += 1
pipe.passed = True
# Draw bird
bird.draw()
# Check if bird hits the ground or flies too high
if bird.y >= HEIGHT or bird.y <= 0:
game_active = False
# Display score
score_text = font.render(f"Score: {score}", True, BLACK)
screen.blit(score_text, (10, 10))
else:
# Game over screen
game_over_text = font.render("Game Over!", True, BLACK)
restart_text = font.render("Press 'R' to Restart", True, BLACK)
screen.blit(game_over_text, (WIDTH // 2 - 90, HEIGHT // 2 - 50))
screen.blit(restart_text, (WIDTH // 2 - 150, HEIGHT // 2 + 10))
pygame.display.update()
# Start the game
game()š§ Requirements:python
import pygame
import random
import sys
# Initialize Pygame
pygame.init()
# Screen dimensions
WIDTH, HEIGHT = 400, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Flappy Bird")
# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
GREEN = (0, 128, 0)
SKY_BLUE = (135, 206, 235)
# Game settings
GRAVITY = 0.5
FLAP_STRENGTH = -10
PIPE_SPEED = 3
PIPE_GAP = 150
PIPE_FREQUENCY = 1500 # milliseconds
# Bird class
class Bird:
def __init__(self):
self.x = 50
self.y = HEIGHT // 2
self.velocity = 0
self.width = 20
self.height = 20
def flap(self):
self.velocity = FLAP_STRENGTH
def update(self):
self.velocity += GRAVITY
self.y += self.velocity
if self.y < 0:
self.y = 0
if self.y > HEIGHT:
self.y = HEIGHT
def draw(self):
pygame.draw.circle(screen, BLACK, (self.x, int(self.y)), self.width // 2)
# Pipe class
class Pipe:
def __init__(self):
self.x = WIDTH
self.top = random.randint(50, HEIGHT - PIPE_GAP - 50)
self.bottom = self.top + PIPE_GAP
self.width = 50
self.passed = False
def update(self):
self.x -= PIPE_SPEED
return self.x > -self.width
def draw(self):
pygame.draw.rect(screen, GREEN, (self.x, 0, self.width, self.top))
pygame.draw.rect(screen, GREEN, (self.x, self.bottom, self.width, HEIGHT - self.bottom))
def collide(self, bird):
if bird.x + bird.width // 2 > self.x and bird.x - bird.width // 2 < self.x + self.width:
if bird.y - bird.height // 2 < self.top or bird.y + bird.height // 2 > self.bottom:
return True
return False
# Main game loop
def game():
bird = Bird()
pipes = []
score = 0
clock = pygame.time.Clock()
last_pipe = pygame.time.get_ticks()
running = True
game_active = True
font = pygame.font.SysFont(None, 55)
while running:
screen.fill(SKY_BLUE)
dt = clock.tick(60)
current_time = pygame.time.get_ticks()
# Event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE and game_active:
bird.flap()
if event.key == pygame.K_r and not game_active:
game()
if game_active:
# Update bird
bird.update()
# Generate new pipes
if current_time - last_pipe > PIPE_FREQUENCY:
pipes.append(Pipe())
last_pipe = current_time
# Update and draw pipes
pipes = [p for p in pipes if p.update()]
for pipe in pipes:
pipe.draw()
if pipe.collide(bird):
game_active = False
# Score logic
if pipe.x + pipe.width < bird.x and not pipe.passed:
score += 1
pipe.passed = True
# Draw bird
bird.draw()
# Check if bird hits the ground or flies too high
if bird.y >= HEIGHT or bird.y <= 0:
game_active = False
# Display score
score_text = font.render(f"Score: {score}", True, BLACK)
screen.blit(score_text, (10, 10))
else:
# Game over screen
game_over_text = font.render("Game Over!", True, BLACK)
restart_text = font.render("Press 'R' to Restart", True, BLACK)
screen.blit(game_over_text, (WIDTH // 2 - 90, HEIGHT // 2 - 50))
screen.blit(restart_text, (WIDTH // 2 - 150, HEIGHT // 2 + 10))
pygame.display.update()
# Start the game
game()š§ Requirements:python
import pygame
import random
import sys
# Initialize Pygame
pygame.init()
# Screen dimensions
WIDTH, HEIGHT = 400, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Flappy Bird")
# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
GREEN = (0, 128, 0)
SKY_BLUE = (135, 206, 235)
# Game settings
GRAVITY = 0.5
FLAP_STRENGTH = -10
PIPE_SPEED = 3
PIPE_GAP = 150
PIPE_FREQUENCY = 1500 # milliseconds
# Bird class
class Bird:
def __init__(self):
self.x = 50
self.y = HEIGHT // 2
self.velocity = 0
self.width = 20
self.height = 20
def flap(self):
self.velocity = FLAP_STRENGTH
def update(self):
self.velocity += GRAVITY
self.y += self.velocity
if self.y < 0:
self.y = 0
if self.y > HEIGHT:
self.y = HEIGHT
def draw(self):
pygame.draw.circle(screen, BLACK, (self.x, int(self.y)), self.width // 2)
# Pipe class
class Pipe:
def __init__(self):
self.x = WIDTH
self.top = random.randint(50, HEIGHT - PIPE_GAP - 50)
self.bottom = self.top + PIPE_GAP
self.width = 50
self.passed = False
def update(self):
self.x -= PIPE_SPEED
return self.x > -self.width
def draw(self):
pygame.draw.rect(screen, GREEN, (self.x, 0, self.width, self.top))
pygame.draw.rect(screen, GREEN, (self.x, self.bottom, self.width, HEIGHT - self.bottom))
def collide(self, bird):
if bird.x + bird.width // 2 > self.x and bird.x - bird.width // 2 < self.x + self.width:
if bird.y - bird.height // 2 < self.top or bird.y + bird.height // 2 > self.bottom:
return True
return False
# Main game loop
def game():
bird = Bird()
pipes = []
score = 0
clock = pygame.time.Clock()
last_pipe = pygame.time.get_ticks()
running = True
game_active = True
font = pygame.font.SysFont(None, 55)
while running:
screen.fill(SKY_BLUE)
dt = clock.tick(60)
current_time = pygame.time.get_ticks()
# Event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE and game_active:
bird.flap()
if event.key == pygame.K_r and not game_active:
game()
if game_active:
# Update bird
bird.update()
# Generate new pipes
if current_time - last_pipe > PIPE_FREQUENCY:
pipes.append(Pipe())
last_pipe = current_time
# Update and draw pipes
pipes = [p for p in pipes if p.update()]
for pipe in pipes:
pipe.draw()
if pipe.collide(bird):
game_active = False
# Score logic
if pipe.x + pipe.width < bird.x and not pipe.passed:
score += 1
pipe.passed = True
# Draw bird
bird.draw()
# Check if bird hits the ground or flies too high
if bird.y >= HEIGHT or bird.y <= 0:
game_active = False
# Display score
score_text = font.render(f"Score: {score}", True, BLACK)
screen.blit(score_text, (10, 10))
else:
# Game over screen
game_over_text = font.render("Game Over!", True, BLACK)
restart_text = font.render("Press 'R' to Restart", True, BLACK)
screen.blit(game_over_text, (WIDTH // 2 - 90, HEIGHT // 2 - 50))
screen.blit(restart_text, (WIDTH // 2 - 150, HEIGHT // 2 + 10))
pygame.display.update()
# Start the game
game()š§ Requirements:python
import pygame
import random
import sys
# Initialize Pygame
pygame.init()
# Screen dimensions
WIDTH, HEIGHT = 400, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Flappy Bird")
# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
GREEN = (0, 128, 0)
SKY_BLUE = (135, 206, 235)
# Game settings
GRAVITY = 0.5
FLAP_STRENGTH = -10
PIPE_SPEED = 3
PIPE_GAP = 150
PIPE_FREQUENCY = 1500 # milliseconds
# Bird class
class Bird:
def __init__(self):
self.x = 50
self.y = HEIGHT // 2
self.velocity = 0
self.width = 20
self.height = 20
def flap(self):
self.velocity = FLAP_STRENGTH
def update(self):
self.velocity += GRAVITY
self.y += self.velocity
if self.y < 0:
self.y = 0
if self.y > HEIGHT:
self.y = HEIGHT
def draw(self):
pygame.draw.circle(screen, BLACK, (self.x, int(self.y)), self.width // 2)
# Pipe class
class Pipe:
def __init__(self):
self.x = WIDTH
self.top = random.randint(50, HEIGHT - PIPE_GAP - 50)
self.bottom = self.top + PIPE_GAP
self.width = 50
self.passed = False
def update(self):
self.x -= PIPE_SPEED
return self.x > -self.width
def draw(self):
pygame.draw.rect(screen, GREEN, (self.x, 0, self.width, self.top))
pygame.draw.rect(screen, GREEN, (self.x, self.bottom, self.width, HEIGHT - self.bottom))
def collide(self, bird):
if bird.x + bird.width // 2 > self.x and bird.x - bird.width // 2 < self.x + self.width:
if bird.y - bird.height // 2 < self.top or bird.y + bird.height // 2 > self.bottom:
return True
return False
# Main game loop
def game():
bird = Bird()
pipes = []
score = 0
clock = pygame.time.Clock()
last_pipe = pygame.time.get_ticks()
running = True
game_active = True
font = pygame.font.SysFont(None, 55)
while running:
screen.fill(SKY_BLUE)
dt = clock.tick(60)
current_time = pygame.time.get_ticks()
# Event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE and game_active:
bird.flap()
if event.key == pygame.K_r and not game_active:
game()
if game_active:
# Update bird
bird.update()
# Generate new pipes
if current_time - last_pipe > PIPE_FREQUENCY:
pipes.append(Pipe())
last_pipe = current_time
# Update and draw pipes
pipes = [p for p in pipes if p.update()]
for pipe in pipes:
pipe.draw()
if pipe.collide(bird):
game_active = False
# Score logic
if pipe.x + pipe.width < bird.x and not pipe.passed:
score += 1
pipe.passed = True
# Draw bird
bird.draw()
# Check if bird hits the ground or flies too high
if bird.y >= HEIGHT or bird.y <= 0:
game_active = False
# Display score
score_text = font.render(f"Score: {score}", True, BLACK)
screen.blit(score_text, (10, 10))
else:
# Game over screen
game_over_text = font.render("Game Over!", True, BLACK)
restart_text = font.render("Press 'R' to Restart", True, BLACK)
screen.blit(game_over_text, (WIDTH // 2 - 90, HEIGHT // 2 - 50))
screen.blit(restart_text, (WIDTH // 2 - 150, HEIGHT // 2 + 10))
pygame.display.update()
# Start the game
game()š§ Requirements:python
import pygame
import random
import sys
# Initialize Pygame
pygame.init()
# Screen dimensions
WIDTH, HEIGHT = 400, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Flappy Bird")
# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
GREEN = (0, 128, 0)
SKY_BLUE = (135, 206, 235)
# Game settings
GRAVITY = 0.5
FLAP_STRENGTH = -10
PIPE_SPEED = 3
PIPE_GAP = 150
PIPE_FREQUENCY = 1500 # milliseconds
# Bird class
class Bird:
def __init__(self):
self.x = 50
self.y = HEIGHT // 2
self.velocity = 0
self.width = 20
self.height = 20
def flap(self):
self.velocity = FLAP_STRENGTH
def update(self):
self.velocity += GRAVITY
self.y += self.velocity
if self.y < 0:
self.y = 0
if self.y > HEIGHT:
self.y = HEIGHT
def draw(self):
pygame.draw.circle(screen, BLACK, (self.x, int(self.y)), self.width // 2)
# Pipe class
class Pipe:
def __init__(self):
self.x = WIDTH
self.top = random.randint(50, HEIGHT - PIPE_GAP - 50)
self.bottom = self.top + PIPE_GAP
self.width = 50
self.passed = False
def update(self):
self.x -= PIPE_SPEED
return self.x > -self.width
def draw(self):
pygame.draw.rect(screen, GREEN, (self.x, 0, self.width, self.top))
pygame.draw.rect(screen, GREEN, (self.x, self.bottom, self.width, HEIGHT - self.bottom))
def collide(self, bird):
if bird.x + bird.width // 2 > self.x and bird.x - bird.width // 2 < self.x + self.width:
if bird.y - bird.height // 2 < self.top or bird.y + bird.height // 2 > self.bottom:
return True
return False
# Main game loop
def game():
bird = Bird()
pipes = []
score = 0
clock = pygame.time.Clock()
last_pipe = pygame.time.get_ticks()
running = True
game_active = True
font = pygame.font.SysFont(None, 55)
while running:
screen.fill(SKY_BLUE)
dt = clock.tick(60)
current_time = pygame.time.get_ticks()
# Event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE and game_active:
bird.flap()
if event.key == pygame.K_r and not game_active:
game()
if game_active:
# Update bird
bird.update()
# Generate new pipes
if current_time - last_pipe > PIPE_FREQUENCY:
pipes.append(Pipe())
last_pipe = current_time
# Update and draw pipes
pipes = [p for p in pipes if p.update()]
for pipe in pipes:
pipe.draw()
if pipe.collide(bird):
game_active = False
# Score logic
if pipe.x + pipe.width < bird.x and not pipe.passed:
score += 1
pipe.passed = True
# Draw bird
bird.draw()
# Check if bird hits the ground or flies too high
if bird.y >= HEIGHT or bird.y <= 0:
game_active = False
# Display score
score_text = font.render(f"Score: {score}", True, BLACK)
screen.blit(score_text, (10, 10))
else:
# Game over screen
game_over_text = font.render("Game Over!", True, BLACK)
restart_text = font.render("Press 'R' to Restart", True, BLACK)
screen.blit(game_over_text, (WIDTH // 2 - 90, HEIGHT // 2 - 50))
screen.blit(restart_text, (WIDTH // 2 - 150, HEIGHT // 2 + 10))
pygame.display.update()
# Start the game
game()š§ Requirements:python
import pygame
import random
import sys
# Initialize Pygame
pygame.init()
# Screen dimensions
WIDTH, HEIGHT = 400, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Flappy Bird")
# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
GREEN = (0, 128, 0)
SKY_BLUE = (135, 206, 235)
# Game settings
GRAVITY = 0.5
FLAP_STRENGTH = -10
PIPE_SPEED = 3
PIPE_GAP = 150
PIPE_FREQUENCY = 1500 # milliseconds
# Bird class
class Bird:
def __init__(self):
self.x = 50
self.y = HEIGHT // 2
self.velocity = 0
self.width = 20
self.height = 20
def flap(self):
self.velocity = FLAP_STRENGTH
def update(self):
self.velocity += GRAVITY
self.y += self.velocity
if self.y < 0:
self.y = 0
if self.y > HEIGHT:
self.y = HEIGHT
def draw(self):
pygame.draw.circle(screen, BLACK, (self.x, int(self.y)), self.width // 2)
# Pipe class
class Pipe:
def __init__(self):
self.x = WIDTH
self.top = random.randint(50, HEIGHT - PIPE_GAP - 50)
self.bottom = self.top + PIPE_GAP
self.width = 50
self.passed = False
def update(self):
self.x -= PIPE_SPEED
return self.x > -self.width
def draw(self):
pygame.draw.rect(screen, GREEN, (self.x, 0, self.width, self.top))
pygame.draw.rect(screen, GREEN, (self.x, self.bottom, self.width, HEIGHT - self.bottom))
def collide(self, bird):
if bird.x + bird.width // 2 > self.x and bird.x - bird.width // 2 < self.x + self.width:
if bird.y - bird.height // 2 < self.top or bird.y + bird.height // 2 > self.bottom:
return True
return False
# Main game loop
def game():
bird = Bird()
pipes = []
score = 0
clock = pygame.time.Clock()
last_pipe = pygame.time.get_ticks()
running = True
game_active = True
font = pygame.font.SysFont(None, 55)
while running:
screen.fill(SKY_BLUE)
dt = clock.tick(60)
current_time = pygame.time.get_ticks()
# Event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE and game_active:
bird.flap()
if event.key == pygame.K_r and not game_active:
game()
if game_active:
# Update bird
bird.update()
# Generate new pipes
if current_time - last_pipe > PIPE_FREQUENCY:
pipes.append(Pipe())
last_pipe = current_time
# Update and draw pipes
pipes = [p for p in pipes if p.update()]
for pipe in pipes:
pipe.draw()
if pipe.collide(bird):
game_active = False
# Score logic
if pipe.x + pipe.width < bird.x and not pipe.passed:
score += 1
pipe.passed = True
# Draw bird
bird.draw()
# Check if bird hits the ground or flies too high
if bird.y >= HEIGHT or bird.y <= 0:
game_active = False
# Display score
score_text = font.render(f"Score: {score}", True, BLACK)
screen.blit(score_text, (10, 10))
else:
# Game over screen
game_over_text = font.render("Game Over!", True, BLACK)
restart_text = font.render("Press 'R' to Restart", True, BLACK)
screen.blit(game_over_text, (WIDTH // 2 - 90, HEIGHT // 2 - 50))
screen.blit(restart_text, (WIDTH // 2 - 150, HEIGHT // 2 + 10))
pygame.display.update()
# Start the game
game()š§ Requirements:python
import pygame
import random
import sys
# Initialize Pygame
pygame.init()
# Screen dimensions
WIDTH, HEIGHT = 400, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Flappy Bird")
# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
GREEN = (0, 128, 0)
SKY_BLUE = (135, 206, 235)
# Game settings
GRAVITY = 0.5
FLAP_STRENGTH = -10
PIPE_SPEED = 3
PIPE_GAP = 150
PIPE_FREQUENCY = 1500 # milliseconds
# Bird class
class Bird:
def __init__(self):
self.x = 50
self.y = HEIGHT // 2
self.velocity = 0
self.width = 20
self.height = 20
def flap(self):
self.velocity = FLAP_STRENGTH
def update(self):
self.velocity += GRAVITY
self.y += self.velocity
if self.y < 0:
self.y = 0
if self.y > HEIGHT:
self.y = HEIGHT
def draw(self):
pygame.draw.circle(screen, BLACK, (self.x, int(self.y)), self.width // 2)
# Pipe class
class Pipe:
def __init__(self):
self.x = WIDTH
self.top = random.randint(50, HEIGHT - PIPE_GAP - 50)
self.bottom = self.top + PIPE_GAP
self.width = 50
self.passed = False
def update(self):
self.x -= PIPE_SPEED
return self.x > -self.width
def draw(self):
pygame.draw.rect(screen, GREEN, (self.x, 0, self.width, self.top))
pygame.draw.rect(screen, GREEN, (self.x, self.bottom, self.width, HEIGHT - self.bottom))
def collide(self, bird):
if bird.x + bird.width // 2 > self.x and bird.x - bird.width // 2 < self.x + self.width:
if bird.y - bird.height // 2 < self.top or bird.y + bird.height // 2 > self.bottom:
return True
return False
# Main game loop
def game():
bird = Bird()
pipes = []
score = 0
clock = pygame.time.Clock()
last_pipe = pygame.time.get_ticks()
running = True
game_active = True
font = pygame.font.SysFont(None, 55)
while running:
screen.fill(SKY_BLUE)
dt = clock.tick(60)
current_time = pygame.time.get_ticks()
# Event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE and game_active:
bird.flap()
if event.key == pygame.K_r and not game_active:
game()
if game_active:
# Update bird
bird.update()
# Generate new pipes
if current_time - last_pipe > PIPE_FREQUENCY:
pipes.append(Pipe())
last_pipe = current_time
# Update and draw pipes
pipes = [p for p in pipes if p.update()]
for pipe in pipes:
pipe.draw()
if pipe.collide(bird):
game_active = False
# Score logic
if pipe.x + pipe.width < bird.x and not pipe.passed:
score += 1
pipe.passed = True
# Draw bird
bird.draw()
# Check if bird hits the ground or flies too high
if bird.y >= HEIGHT or bird.y <= 0:
game_active = False
# Display score
score_text = font.render(f"Score: {score}", True, BLACK)
screen.blit(score_text, (10, 10))
else:
# Game over screen
game_over_text = font.render("Game Over!", True, BLACK)
restart_text = font.render("Press 'R' to Restart", True, BLACK)
screen.blit(game_over_text, (WIDTH // 2 - 90, HEIGHT // 2 - 50))
screen.blit(restart_text, (WIDTH // 2 - 150, HEIGHT // 2 + 10))
pygame.display.update()
# Start the game
game()š§ Requirements:python
import pygame
import random
import sys
# Initialize Pygame
pygame.init()
# Screen dimensions
WIDTH, HEIGHT = 400, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Flappy Bird")
# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
GREEN = (0, 128, 0)
SKY_BLUE = (135, 206, 235)
# Game settings
GRAVITY = 0.5
FLAP_STRENGTH = -10
PIPE_SPEED = 3
PIPE_GAP = 150
PIPE_FREQUENCY = 1500 # milliseconds
# Bird class
class Bird:
def __init__(self):
self.x = 50
self.y = HEIGHT // 2
self.velocity = 0
self.width = 20
self.height = 20
def flap(self):
self.velocity = FLAP_STRENGTH
def update(self):
self.velocity += GRAVITY
self.y += self.velocity
if self.y < 0:
self.y = 0
if self.y > HEIGHT:
self.y = HEIGHT
def draw(self):
pygame.draw.circle(screen, BLACK, (self.x, int(self.y)), self.width // 2)
# Pipe class
class Pipe:
def __init__(self):
self.x = WIDTH
self.top = random.randint(50, HEIGHT - PIPE_GAP - 50)
self.bottom = self.top + PIPE_GAP
self.width = 50
self.passed = False
def update(self):
self.x -= PIPE_SPEED
return self.x > -self.width
def draw(self):
pygame.draw.rect(screen, GREEN, (self.x, 0, self.width, self.top))
pygame.draw.rect(screen, GREEN, (self.x, self.bottom, self.width, HEIGHT - self.bottom))
def collide(self, bird):
if bird.x + bird.width // 2 > self.x and bird.x - bird.width // 2 < self.x + self.width:
if bird.y - bird.height // 2 < self.top or bird.y + bird.height // 2 > self.bottom:
return True
return False
# Main game loop
def game():
bird = Bird()
pipes = []
score = 0
clock = pygame.time.Clock()
last_pipe = pygame.time.get_ticks()
running = True
game_active = True
font = pygame.font.SysFont(None, 55)
while running:
screen.fill(SKY_BLUE)
dt = clock.tick(60)
current_time = pygame.time.get_ticks()
# Event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE and game_active:
bird.flap()
if event.key == pygame.K_r and not game_active:
game()
if game_active:
# Update bird
bird.update()
# Generate new pipes
if current_time - last_pipe > PIPE_FREQUENCY:
pipes.append(Pipe())
last_pipe = current_time
# Update and draw pipes
pipes = [p for p in pipes if p.update()]
for pipe in pipes:
pipe.draw()
if pipe.collide(bird):
game_active = False
# Score logic
if pipe.x + pipe.width < bird.x and not pipe.passed:
score += 1
pipe.passed = True
# Draw bird
bird.draw()
# Check if bird hits the ground or flies too high
if bird.y >= HEIGHT or bird.y <= 0:
game_active = False
# Display score
score_text = font.render(f"Score: {score}", True, BLACK)
screen.blit(score_text, (10, 10))
else:
# Game over screen
game_over_text = font.render("Game Over!", True, BLACK)
restart_text = font.render("Press 'R' to Restart", True, BLACK)
screen.blit(game_over_text, (WIDTH // 2 - 90, HEIGHT // 2 - 50))
screen.blit(restart_text, (WIDTH // 2 - 150, HEIGHT // 2 + 10))
pygame.display.update()
# Start the game
game()š§ Requirements:python
import pygame
import random
import sys
# Initialize Pygame
pygame.init()
# Screen dimensions
WIDTH, HEIGHT = 400, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Flappy Bird")
# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
GREEN = (0, 128, 0)
SKY_BLUE = (135, 206, 235)
# Game settings
GRAVITY = 0.5
FLAP_STRENGTH = -10
PIPE_SPEED = 3
PIPE_GAP = 150
PIPE_FREQUENCY = 1500 # milliseconds
# Bird class
class Bird:
def __init__(self):
self.x = 50
self.y = HEIGHT // 2
self.velocity = 0
self.width = 20
self.height = 20
def flap(self):
self.velocity = FLAP_STRENGTH
def update(self):
self.velocity += GRAVITY
self.y += self.velocity
if self.y < 0:
self.y = 0
if self.y > HEIGHT:
self.y = HEIGHT
def draw(self):
pygame.draw.circle(screen, BLACK, (self.x, int(self.y)), self.width // 2)
# Pipe class
class Pipe:
def __init__(self):
self.x = WIDTH
self.top = random.randint(50, HEIGHT - PIPE_GAP - 50)
self.bottom = self.top + PIPE_GAP
self.width = 50
self.passed = False
def update(self):
self.x -= PIPE_SPEED
return self.x > -self.width
def draw(self):
pygame.draw.rect(screen, GREEN, (self.x, 0, self.width, self.top))
pygame.draw.rect(screen, GREEN, (self.x, self.bottom, self.width, HEIGHT - self.bottom))
def collide(self, bird):
if bird.x + bird.width // 2 > self.x and bird.x - bird.width // 2 < self.x + self.width:
if bird.y - bird.height // 2 < self.top or bird.y + bird.height // 2 > self.bottom:
return True
return False
# Main game loop
def game():
bird = Bird()
pipes = []
score = 0
clock = pygame.time.Clock()
last_pipe = pygame.time.get_ticks()
running = True
game_active = True
font = pygame.font.SysFont(None, 55)
while running:
screen.fill(SKY_BLUE)
dt = clock.tick(60)
current_time = pygame.time.get_ticks()
# Event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE and game_active:
bird.flap()
if event.key == pygame.K_r and not game_active:
game()
if game_active:
# Update bird
bird.update()
# Generate new pipes
if current_time - last_pipe > PIPE_FREQUENCY:
pipes.append(Pipe())
last_pipe = current_time
# Update and draw pipes
pipes = [p for p in pipes if p.update()]
for pipe in pipes:
pipe.draw()
if pipe.collide(bird):
game_active = False
# Score logic
if pipe.x + pipe.width < bird.x and not pipe.passed:
score += 1
pipe.passed = True
# Draw bird
bird.draw()
# Check if bird hits the ground or flies too high
if bird.y >= HEIGHT or bird.y <= 0:
game_active = False
# Display score
score_text = font.render(f"Score: {score}", True, BLACK)
screen.blit(score_text, (10, 10))
else:
# Game over screen
game_over_text = font.render("Game Over!", True, BLACK)
restart_text = font.render("Press 'R' to Restart", True, BLACK)
screen.blit(game_over_text, (WIDTH // 2 - 90, HEIGHT // 2 - 50))
screen.blit(restart_text, (WIDTH // 2 - 150, HEIGHT // 2 + 10))
pygame.display.update()
# Start the game
game()š§ Requirements:python
import pygame
import random
import sys
# Initialize Pygame
pygame.init()
# Screen dimensions
WIDTH, HEIGHT = 400, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Flappy Bird")
# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
GREEN = (0, 128, 0)
SKY_BLUE = (135, 206, 235)
# Game settings
GRAVITY = 0.5
FLAP_STRENGTH = -10
PIPE_SPEED = 3
PIPE_GAP = 150
PIPE_FREQUENCY = 1500 # milliseconds
# Bird class
class Bird:
def __init__(self):
self.x = 50
self.y = HEIGHT // 2
self.velocity = 0
self.width = 20
self.height = 20
def flap(self):
self.velocity = FLAP_STRENGTH
def update(self):
self.velocity += GRAVITY
self.y += self.velocity
if self.y < 0:
self.y = 0
if self.y > HEIGHT:
self.y = HEIGHT
def draw(self):
pygame.draw.circle(screen, BLACK, (self.x, int(self.y)), self.width // 2)
# Pipe class
class Pipe:
def __init__(self):
self.x = WIDTH
self.top = random.randint(50, HEIGHT - PIPE_GAP - 50)
self.bottom = self.top + PIPE_GAP
self.width = 50
self.passed = False
def update(self):
self.x -= PIPE_SPEED
return self.x > -self.width
def draw(self):
pygame.draw.rect(screen, GREEN, (self.x, 0, self.width, self.top))
pygame.draw.rect(screen, GREEN, (self.x, self.bottom, self.width, HEIGHT - self.bottom))
def collide(self, bird):
if bird.x + bird.width // 2 > self.x and bird.x - bird.width // 2 < self.x + self.width:
if bird.y - bird.height // 2 < self.top or bird.y + bird.height // 2 > self.bottom:
return True
return False
# Main game loop
def game():
bird = Bird()
pipes = []
score = 0
clock = pygame.time.Clock()
last_pipe = pygame.time.get_ticks()
running = True
game_active = True
font = pygame.font.SysFont(None, 55)
while running:
screen.fill(SKY_BLUE)
dt = clock.tick(60)
current_time = pygame.time.get_ticks()
# Event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE and game_active:
bird.flap()
if event.key == pygame.K_r and not game_active:
game()
if game_active:
# Update bird
bird.update()
# Generate new pipes
if current_time - last_pipe > PIPE_FREQUENCY:
pipes.append(Pipe())
last_pipe = current_time
# Update and draw pipes
pipes = [p for p in pipes if p.update()]
for pipe in pipes:
pipe.draw()
if pipe.collide(bird):
game_active = False
# Score logic
if pipe.x + pipe.width < bird.x and not pipe.passed:
score += 1
pipe.passed = True
# Draw bird
bird.draw()
# Check if bird hits the ground or flies too high
if bird.y >= HEIGHT or bird.y <= 0:
game_active = False
# Display score
score_text = font.render(f"Score: {score}", True, BLACK)
screen.blit(score_text, (10, 10))
else:
# Game over screen
game_over_text = font.render("Game Over!", True, BLACK)
restart_text = font.render("Press 'R' to Restart", True, BLACK)
screen.blit(game_over_text, (WIDTH // 2 - 90, HEIGHT // 2 - 50))
screen.blit(restart_text, (WIDTH // 2 - 150, HEIGHT // 2 + 10))
pygame.display.update()
# Start the game
game()š§ Requirements:python
import pygame
import random
import sys
# Initialize Pygame
pygame.init()
# Screen dimensions
WIDTH, HEIGHT = 400, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Flappy Bird")
# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
GREEN = (0, 128, 0)
SKY_BLUE = (135, 206, 235)
# Game settings
GRAVITY = 0.5
FLAP_STRENGTH = -10
PIPE_SPEED = 3
PIPE_GAP = 150
PIPE_FREQUENCY = 1500 # milliseconds
# Bird class
class Bird:
def __init__(self):
self.x = 50
self.y = HEIGHT // 2
self.velocity = 0
self.width = 20
self.height = 20
def flap(self):
self.velocity = FLAP_STRENGTH
def update(self):
self.velocity += GRAVITY
self.y += self.velocity
if self.y < 0:
self.y = 0
if self.y > HEIGHT:
self.y = HEIGHT
def draw(self):
pygame.draw.circle(screen, BLACK, (self.x, int(self.y)), self.width // 2)
# Pipe class
class Pipe:
def __init__(self):
self.x = WIDTH
self.top = random.randint(50, HEIGHT - PIPE_GAP - 50)
self.bottom = self.top + PIPE_GAP
self.width = 50
self.passed = False
def update(self):
self.x -= PIPE_SPEED
return self.x > -self.width
def draw(self):
pygame.draw.rect(screen, GREEN, (self.x, 0, self.width, self.top))
pygame.draw.rect(screen, GREEN, (self.x, self.bottom, self.width, HEIGHT - self.bottom))
def collide(self, bird):
if bird.x + bird.width // 2 > self.x and bird.x - bird.width // 2 < self.x + self.width:
if bird.y - bird.height // 2 < self.top or bird.y + bird.height // 2 > self.bottom:
return True
return False
# Main game loop
def game():
bird = Bird()
pipes = []
score = 0
clock = pygame.time.Clock()
last_pipe = pygame.time.get_ticks()
running = True
game_active = True
font = pygame.font.SysFont(None, 55)
while running:
screen.fill(SKY_BLUE)
dt = clock.tick(60)
current_time = pygame.time.get_ticks()
# Event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE and game_active:
bird.flap()
if event.key == pygame.K_r and not game_active:
game()
if game_active:
# Update bird
bird.update()
# Generate new pipes
if current_time - last_pipe > PIPE_FREQUENCY:
pipes.append(Pipe())
last_pipe = current_time
# Update and draw pipes
pipes = [p for p in pipes if p.update()]
for pipe in pipes:
pipe.draw()
if pipe.collide(bird):
game_active = False
# Score logic
if pipe.x + pipe.width < bird.x and not pipe.passed:
score += 1
pipe.passed = True
# Draw bird
bird.draw()
# Check if bird hits the ground or flies too high
if bird.y >= HEIGHT or bird.y <= 0:
game_active = False
# Display score
score_text = font.render(f"Score: {score}", True, BLACK)
screen.blit(score_text, (10, 10))
else:
# Game over screen
game_over_text = font.render("Game Over!", True, BLACK)
restart_text = font.render("Press 'R' to Restart", True, BLACK)
screen.blit(game_over_text, (WIDTH // 2 - 90, HEIGHT // 2 - 50))
screen.blit(restart_text, (WIDTH // 2 - 150, HEIGHT // 2 + 10))
pygame.display.update()
# Start the game
game()š§ Requirements:python
import pygame
import random
import sys
# Initialize Pygame
pygame.init()
# Screen dimensions
WIDTH, HEIGHT = 400, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Flappy Bird")
# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
GREEN = (0, 128, 0)
SKY_BLUE = (135, 206, 235)
# Game settings
GRAVITY = 0.5
FLAP_STRENGTH = -10
PIPE_SPEED = 3
PIPE_GAP = 150
PIPE_FREQUENCY = 1500 # milliseconds
# Bird class
class Bird:
def __init__(self):
self.x = 50
self.y = HEIGHT // 2
self.velocity = 0
self.width = 20
self.height = 20
def flap(self):
self.velocity = FLAP_STRENGTH
def update(self):
self.velocity += GRAVITY
self.y += self.velocity
if self.y < 0:
self.y = 0
if self.y > HEIGHT:
self.y = HEIGHT
def draw(self):
pygame.draw.circle(screen, BLACK, (self.x, int(self.y)), self.width // 2)
# Pipe class
class Pipe:
def __init__(self):
self.x = WIDTH
self.top = random.randint(50, HEIGHT - PIPE_GAP - 50)
self.bottom = self.top + PIPE_GAP
self.width = 50
self.passed = False
def update(self):
self.x -= PIPE_SPEED
return self.x > -self.width
def draw(self):
pygame.draw.rect(screen, GREEN, (self.x, 0, self.width, self.top))
pygame.draw.rect(screen, GREEN, (self.x, self.bottom, self.width, HEIGHT - self.bottom))
def collide(self, bird):
if bird.x + bird.width // 2 > self.x and bird.x - bird.width // 2 < self.x + self.width:
if bird.y - bird.height // 2 < self.top or bird.y + bird.height // 2 > self.bottom:
return True
return False
# Main game loop
def game():
bird = Bird()
pipes = []
score = 0
clock = pygame.time.Clock()
last_pipe = pygame.time.get_ticks()
running = True
game_active = True
font = pygame.font.SysFont(None, 55)
while running:
screen.fill(SKY_BLUE)
dt = clock.tick(60)
current_time = pygame.time.get_ticks()
# Event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE and game_active:
bird.flap()
if event.key == pygame.K_r and not game_active:
game()
if game_active:
# Update bird
bird.update()
# Generate new pipes
if current_time - last_pipe > PIPE_FREQUENCY:
pipes.append(Pipe())
last_pipe = current_time
# Update and draw pipes
pipes = [p for p in pipes if p.update()]
for pipe in pipes:
pipe.draw()
if pipe.collide(bird):
game_active = False
# Score logic
if pipe.x + pipe.width < bird.x and not pipe.passed:
score += 1
pipe.passed = True
# Draw bird
bird.draw()
# Check if bird hits the ground or flies too high
if bird.y >= HEIGHT or bird.y <= 0:
game_active = False
# Display score
score_text = font.render(f"Score: {score}", True, BLACK)
screen.blit(score_text, (10, 10))
else:
# Game over screen
game_over_text = font.render("Game Over!", True, BLACK)
restart_text = font.render("Press 'R' to Restart", True, BLACK)
screen.blit(game_over_text, (WIDTH // 2 - 90, HEIGHT // 2 - 50))
screen.blit(restart_text, (WIDTH // 2 - 150, HEIGHT // 2 + 10))
pygame.display.update()
# Start the game
game()š§ Requirements:python
import pygame
import random
import sys
# Initialize Pygame
pygame.init()
# Screen dimensions
WIDTH, HEIGHT = 400, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Flappy Bird")
# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
GREEN = (0, 128, 0)
SKY_BLUE = (135, 206, 235)
# Game settings
GRAVITY = 0.5
FLAP_STRENGTH = -10
PIPE_SPEED = 3
PIPE_GAP = 150
PIPE_FREQUENCY = 1500 # milliseconds
# Bird class
class Bird:
def __init__(self):
self.x = 50
self.y = HEIGHT // 2
self.velocity = 0
self.width = 20
self.height = 20
def flap(self):
self.velocity = FLAP_STRENGTH
def update(self):
self.velocity += GRAVITY
self.y += self.velocity
if self.y < 0:
self.y = 0
if self.y > HEIGHT:
self.y = HEIGHT
def draw(self):
pygame.draw.circle(screen, BLACK, (self.x, int(self.y)), self.width // 2)
# Pipe class
class Pipe:
def __init__(self):
self.x = WIDTH
self.top = random.randint(50, HEIGHT - PIPE_GAP - 50)
self.bottom = self.top + PIPE_GAP
self.width = 50
self.passed = False
def update(self):
self.x -= PIPE_SPEED
return self.x > -self.width
def draw(self):
pygame.draw.rect(screen, GREEN, (self.x, 0, self.width, self.top))
pygame.draw.rect(screen, GREEN, (self.x, self.bottom, self.width, HEIGHT - self.bottom))
def collide(self, bird):
if bird.x + bird.width // 2 > self.x and bird.x - bird.width // 2 < self.x + self.width:
if bird.y - bird.height // 2 < self.top or bird.y + bird.height // 2 > self.bottom:
return True
return False
# Main game loop
def game():
bird = Bird()
pipes = []
score = 0
clock = pygame.time.Clock()
last_pipe = pygame.time.get_ticks()
running = True
game_active = True
font = pygame.font.SysFont(None, 55)
while running:
screen.fill(SKY_BLUE)
dt = clock.tick(60)
current_time = pygame.time.get_ticks()
# Event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE and game_active:
bird.flap()
if event.key == pygame.K_r and not game_active:
game()
if game_active:
# Update bird
bird.update()
# Generate new pipes
if current_time - last_pipe > PIPE_FREQUENCY:
pipes.append(Pipe())
last_pipe = current_time
# Update and draw pipes
pipes = [p for p in pipes if p.update()]
for pipe in pipes:
pipe.draw()
if pipe.collide(bird):
game_active = False
# Score logic
if pipe.x + pipe.width < bird.x and not pipe.passed:
score += 1
pipe.passed = True
# Draw bird
bird.draw()
# Check if bird hits the ground or flies too high
if bird.y >= HEIGHT or bird.y <= 0:
game_active = False
# Display score
score_text = font.render(f"Score: {score}", True, BLACK)
screen.blit(score_text, (10, 10))
else:
# Game over screen
game_over_text = font.render("Game Over!", True, BLACK)
restart_text = font.render("Press 'R' to Restart", True, BLACK)
screen.blit(game_over_text, (WIDTH // 2 - 90, HEIGHT // 2 - 50))
screen.blit(restart_text, (WIDTH // 2 - 150, HEIGHT // 2 + 10))
pygame.display.update()
# Start the game
game()š§ Requirements:python
import pygame
import random
import sys
# Initialize Pygame
pygame.init()
# Screen dimensions
WIDTH, HEIGHT = 400, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Flappy Bird")
# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
GREEN = (0, 128, 0)
SKY_BLUE = (135, 206, 235)
# Game settings
GRAVITY = 0.5
FLAP_STRENGTH = -10
PIPE_SPEED = 3
PIPE_GAP = 150
PIPE_FREQUENCY = 1500 # milliseconds
# Bird class
class Bird:
def __init__(self):
self.x = 50
self.y = HEIGHT // 2
self.velocity = 0
self.width = 20
self.height = 20
def flap(self):
self.velocity = FLAP_STRENGTH
def update(self):
self.velocity += GRAVITY
self.y += self.velocity
if self.y < 0:
self.y = 0
if self.y > HEIGHT:
self.y = HEIGHT
def draw(self):
pygame.draw.circle(screen, BLACK, (self.x, int(self.y)), self.width // 2)
# Pipe class
class Pipe:
def __init__(self):
self.x = WIDTH
self.top = random.randint(50, HEIGHT - PIPE_GAP - 50)
self.bottom = self.top + PIPE_GAP
self.width = 50
self.passed = False
def update(self):
self.x -= PIPE_SPEED
return self.x > -self.width
def draw(self):
pygame.draw.rect(screen, GREEN, (self.x, 0, self.width, self.top))
pygame.draw.rect(screen, GREEN, (self.x, self.bottom, self.width, HEIGHT - self.bottom))
def collide(self, bird):
if bird.x + bird.width // 2 > self.x and bird.x - bird.width // 2 < self.x + self.width:
if bird.y - bird.height // 2 < self.top or bird.y + bird.height // 2 > self.bottom:
return True
return False
# Main game loop
def game():
bird = Bird()
pipes = []
score = 0
clock = pygame.time.Clock()
last_pipe = pygame.time.get_ticks()
running = True
game_active = True
font = pygame.font.SysFont(None, 55)
while running:
screen.fill(SKY_BLUE)
dt = clock.tick(60)
current_time = pygame.time.get_ticks()
# Event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE and game_active:
bird.flap()
if event.key == pygame.K_r and not game_active:
game()
if game_active:
# Update bird
bird.update()
# Generate new pipes
if current_time - last_pipe > PIPE_FREQUENCY:
pipes.append(Pipe())
last_pipe = current_time
# Update and draw pipes
pipes = [p for p in pipes if p.update()]
for pipe in pipes:
pipe.draw()
if pipe.collide(bird):
game_active = False
# Score logic
if pipe.x + pipe.width < bird.x and not pipe.passed:
score += 1
pipe.passed = True
# Draw bird
bird.draw()
# Check if bird hits the ground or flies too high
if bird.y >= HEIGHT or bird.y <= 0:
game_active = False
# Display score
score_text = font.render(f"Score: {score}", True, BLACK)
screen.blit(score_text, (10, 10))
else:
# Game over screen
game_over_text = font.render("Game Over!", True, BLACK)
restart_text = font.render("Press 'R' to Restart", True, BLACK)
screen.blit(game_over_text, (WIDTH // 2 - 90, HEIGHT // 2 - 50))
screen.blit(restart_text, (WIDTH // 2 - 150, HEIGHT // 2 + 10))
pygame.display.update()
# Start the game
game()š§ Requirements:python
import pygame
import random
import sys
# Initialize Pygame
pygame.init()
# Screen dimensions
WIDTH, HEIGHT = 400, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Flappy Bird")
# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
GREEN = (0, 128, 0)
SKY_BLUE = (135, 206, 235)
# Game settings
GRAVITY = 0.5
FLAP_STRENGTH = -10
PIPE_SPEED = 3
PIPE_GAP = 150
PIPE_FREQUENCY = 1500 # milliseconds
# Bird class
class Bird:
def __init__(self):
self.x = 50
self.y = HEIGHT // 2
self.velocity = 0
self.width = 20
self.height = 20
def flap(self):
self.velocity = FLAP_STRENGTH
def update(self):
self.velocity += GRAVITY
self.y += self.velocity
if self.y < 0:
self.y = 0
if self.y > HEIGHT:
self.y = HEIGHT
def draw(self):
pygame.draw.circle(screen, BLACK, (self.x, int(self.y)), self.width // 2)
# Pipe class
class Pipe:
def __init__(self):
self.x = WIDTH
self.top = random.randint(50, HEIGHT - PIPE_GAP - 50)
self.bottom = self.top + PIPE_GAP
self.width = 50
self.passed = False
def update(self):
self.x -= PIPE_SPEED
return self.x > -self.width
def draw(self):
pygame.draw.rect(screen, GREEN, (self.x, 0, self.width, self.top))
pygame.draw.rect(screen, GREEN, (self.x, self.bottom, self.width, HEIGHT - self.bottom))
def collide(self, bird):
if bird.x + bird.width // 2 > self.x and bird.x - bird.width // 2 < self.x + self.width:
if bird.y - bird.height // 2 < self.top or bird.y + bird.height // 2 > self.bottom:
return True
return False
# Main game loop
def game():
bird = Bird()
pipes = []
score = 0
clock = pygame.time.Clock()
last_pipe = pygame.time.get_ticks()
running = True
game_active = True
font = pygame.font.SysFont(None, 55)
while running:
screen.fill(SKY_BLUE)
dt = clock.tick(60)
current_time = pygame.time.get_ticks()
# Event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE and game_active:
bird.flap()
if event.key == pygame.K_r and not game_active:
game()
if game_active:
# Update bird
bird.update()
# Generate new pipes
if current_time - last_pipe > PIPE_FREQUENCY:
pipes.append(Pipe())
last_pipe = current_time
# Update and draw pipes
pipes = [p for p in pipes if p.update()]
for pipe in pipes:
pipe.draw()
if pipe.collide(bird):
game_active = False
# Score logic
if pipe.x + pipe.width < bird.x and not pipe.passed:
score += 1
pipe.passed = True
# Draw bird
bird.draw()
# Check if bird hits the ground or flies too high
if bird.y >= HEIGHT or bird.y <= 0:
game_active = False
# Display score
score_text = font.render(f"Score: {score}", True, BLACK)
screen.blit(score_text, (10, 10))
else:
# Game over screen
game_over_text = font.render("Game Over!", True, BLACK)
restart_text = font.render("Press 'R' to Restart", True, BLACK)
screen.blit(game_over_text, (WIDTH // 2 - 90, HEIGHT // 2 - 50))
screen.blit(restart_text, (WIDTH // 2 - 150, HEIGHT // 2 + 10))
pygame.display.update()
# Start the game
game()š§ Requirements:python
import pygame
import random
import sys
# Initialize Pygame
pygame.init()
# Screen dimensions
WIDTH, HEIGHT = 400, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Flappy Bird")
# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
GREEN = (0, 128, 0)
SKY_BLUE = (135, 206, 235)
# Game settings
GRAVITY = 0.5
FLAP_STRENGTH = -10
PIPE_SPEED = 3
PIPE_GAP = 150
PIPE_FREQUENCY = 1500 # milliseconds
# Bird class
class Bird:
def __init__(self):
self.x = 50
self.y = HEIGHT // 2
self.velocity = 0
self.width = 20
self.height = 20
def flap(self):
self.velocity = FLAP_STRENGTH
def update(self):
self.velocity += GRAVITY
self.y += self.velocity
if self.y < 0:
self.y = 0
if self.y > HEIGHT:
self.y = HEIGHT
def draw(self):
pygame.draw.circle(screen, BLACK, (self.x, int(self.y)), self.width // 2)
# Pipe class
class Pipe:
def __init__(self):
self.x = WIDTH
self.top = random.randint(50, HEIGHT - PIPE_GAP - 50)
self.bottom = self.top + PIPE_GAP
self.width = 50
self.passed = False
def update(self):
self.x -= PIPE_SPEED
return self.x > -self.width
def draw(self):
pygame.draw.rect(screen, GREEN, (self.x, 0, self.width, self.top))
pygame.draw.rect(screen, GREEN, (self.x, self.bottom, self.width, HEIGHT - self.bottom))
def collide(self, bird):
if bird.x + bird.width // 2 > self.x and bird.x - bird.width // 2 < self.x + self.width:
if bird.y - bird.height // 2 < self.top or bird.y + bird.height // 2 > self.bottom:
return True
return False
# Main game loop
def game():
bird = Bird()
pipes = []
score = 0
clock = pygame.time.Clock()
last_pipe = pygame.time.get_ticks()
running = True
game_active = True
font = pygame.font.SysFont(None, 55)
while running:
screen.fill(SKY_BLUE)
dt = clock.tick(60)
current_time = pygame.time.get_ticks()
# Event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE and game_active:
bird.flap()
if event.key == pygame.K_r and not game_active:
game()
if game_active:
# Update bird
bird.update()
# Generate new pipes
if current_time - last_pipe > PIPE_FREQUENCY:
pipes.append(Pipe())
last_pipe = current_time
# Update and draw pipes
pipes = [p for p in pipes if p.update()]
for pipe in pipes:
pipe.draw()
if pipe.collide(bird):
game_active = False
# Score logic
if pipe.x + pipe.width < bird.x and not pipe.passed:
score += 1
pipe.passed = True
# Draw bird
bird.draw()
# Check if bird hits the ground or flies too high
if bird.y >= HEIGHT or bird.y <= 0:
game_active = False
# Display score
score_text = font.render(f"Score: {score}", True, BLACK)
screen.blit(score_text, (10, 10))
else:
# Game over screen
game_over_text = font.render("Game Over!", True, BLACK)
restart_text = font.render("Press 'R' to Restart", True, BLACK)
screen.blit(game_over_text, (WIDTH // 2 - 90, HEIGHT // 2 - 50))
screen.blit(restart_text, (WIDTH // 2 - 150, HEIGHT // 2 + 10))
pygame.display.update()
# Start the game
game()š§ Requirements:python
import pygame
import random
import sys
# Initialize Pygame
pygame.init()
# Screen dimensions
WIDTH, HEIGHT = 400, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Flappy Bird")
# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
GREEN = (0, 128, 0)
SKY_BLUE = (135, 206, 235)
# Game settings
GRAVITY = 0.5
FLAP_STRENGTH = -10
PIPE_SPEED = 3
PIPE_GAP = 150
PIPE_FREQUENCY = 1500 # milliseconds
# Bird class
class Bird:
def __init__(self):
self.x = 50
self.y = HEIGHT // 2
self.velocity = 0
self.width = 20
self.height = 20
def flap(self):
self.velocity = FLAP_STRENGTH
def update(self):
self.velocity += GRAVITY
self.y += self.velocity
if self.y < 0:
self.y = 0
if self.y > HEIGHT:
self.y = HEIGHT
def draw(self):
pygame.draw.circle(screen, BLACK, (self.x, int(self.y)), self.width // 2)
# Pipe class
class Pipe:
def __init__(self):
self.x = WIDTH
self.top = random.randint(50, HEIGHT - PIPE_GAP - 50)
self.bottom = self.top + PIPE_GAP
self.width = 50
self.passed = False
def update(self):
self.x -= PIPE_SPEED
return self.x > -self.width
def draw(self):
pygame.draw.rect(screen, GREEN, (self.x, 0, self.width, self.top))
pygame.draw.rect(screen, GREEN, (self.x, self.bottom, self.width, HEIGHT - self.bottom))
def collide(self, bird):
if bird.x + bird.width // 2 > self.x and bird.x - bird.width // 2 < self.x + self.width:
if bird.y - bird.height // 2 < self.top or bird.y + bird.height // 2 > self.bottom:
return True
return False
# Main game loop
def game():
bird = Bird()
pipes = []
score = 0
clock = pygame.time.Clock()
last_pipe = pygame.time.get_ticks()
running = True
game_active = True
font = pygame.font.SysFont(None, 55)
while running:
screen.fill(SKY_BLUE)
dt = clock.tick(60)
current_time = pygame.time.get_ticks()
# Event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE and game_active:
bird.flap()
if event.key == pygame.K_r and not game_active:
game()
if game_active:
# Update bird
bird.update()
# Generate new pipes
if current_time - last_pipe > PIPE_FREQUENCY:
pipes.append(Pipe())
last_pipe = current_time
# Update and draw pipes
pipes = [p for p in pipes if p.update()]
for pipe in pipes:
pipe.draw()
if pipe.collide(bird):
game_active = False
# Score logic
if pipe.x + pipe.width < bird.x and not pipe.passed:
score += 1
pipe.passed = True
# Draw bird
bird.draw()
# Check if bird hits the ground or flies too high
if bird.y >= HEIGHT or bird.y <= 0:
game_active = False
# Display score
score_text = font.render(f"Score: {score}", True, BLACK)
screen.blit(score_text, (10, 10))
else:
# Game over screen
game_over_text = font.render("Game Over!", True, BLACK)
restart_text = font.render("Press 'R' to Restart", True, BLACK)
screen.blit(game_over_text, (WIDTH // 2 - 90, HEIGHT // 2 - 50))
screen.blit(restart_text, (WIDTH // 2 - 150, HEIGHT // 2 + 10))
pygame.display.update()
# Start the game
game()š§ Requirements:python
import pygame
import random
import sys
# Initialize Pygame
pygame.init()
# Screen dimensions
WIDTH, HEIGHT = 400, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Flappy Bird")
# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
GREEN = (0, 128, 0)
SKY_BLUE = (135, 206, 235)
# Game settings
GRAVITY = 0.5
FLAP_STRENGTH = -10
PIPE_SPEED = 3
PIPE_GAP = 150
PIPE_FREQUENCY = 1500 # milliseconds
# Bird class
class Bird:
def __init__(self):
self.x = 50
self.y = HEIGHT // 2
self.velocity = 0
self.width = 20
self.height = 20
def flap(self):
self.velocity = FLAP_STRENGTH
def update(self):
self.velocity += GRAVITY
self.y += self.velocity
if self.y < 0:
self.y = 0
if self.y > HEIGHT:
self.y = HEIGHT
def draw(self):
pygame.draw.circle(screen, BLACK, (self.x, int(self.y)), self.width // 2)
# Pipe class
class Pipe:
def __init__(self):
self.x = WIDTH
self.top = random.randint(50, HEIGHT - PIPE_GAP - 50)
self.bottom = self.top + PIPE_GAP
self.width = 50
self.passed = False
def update(self):
self.x -= PIPE_SPEED
return self.x > -self.width
def draw(self):
pygame.draw.rect(screen, GREEN, (self.x, 0, self.width, self.top))
pygame.draw.rect(screen, GREEN, (self.x, self.bottom, self.width, HEIGHT - self.bottom))
def collide(self, bird):
if bird.x + bird.width // 2 > self.x and bird.x - bird.width // 2 < self.x + self.width:
if bird.y - bird.height // 2 < self.top or bird.y + bird.height // 2 > self.bottom:
return True
return False
# Main game loop
def game():
bird = Bird()
pipes = []
score = 0
clock = pygame.time.Clock()
last_pipe = pygame.time.get_ticks()
running = True
game_active = True
font = pygame.font.SysFont(None, 55)
while running:
screen.fill(SKY_BLUE)
dt = clock.tick(60)
current_time = pygame.time.get_ticks()
# Event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE and game_active:
bird.flap()
if event.key == pygame.K_r and not game_active:
game()
if game_active:
# Update bird
bird.update()
# Generate new pipes
if current_time - last_pipe > PIPE_FREQUENCY:
pipes.append(Pipe())
last_pipe = current_time
# Update and draw pipes
pipes = [p for p in pipes if p.update()]
for pipe in pipes:
pipe.draw()
if pipe.collide(bird):
game_active = False
# Score logic
if pipe.x + pipe.width < bird.x and not pipe.passed:
score += 1
pipe.passed = True
# Draw bird
bird.draw()
# Check if bird hits the ground or flies too high
if bird.y >= HEIGHT or bird.y <= 0:
game_active = False
# Display score
score_text = font.render(f"Score: {score}", True, BLACK)
screen.blit(score_text, (10, 10))
else:
# Game over screen
game_over_text = font.render("Game Over!", True, BLACK)
restart_text = font.render("Press 'R' to Restart", True, BLACK)
screen.blit(game_over_text, (WIDTH // 2 - 90, HEIGHT // 2 - 50))
screen.blit(restart_text, (WIDTH // 2 - 150, HEIGHT // 2 + 10))
pygame.display.update()
# Start the game
game()š§ Requirements:python
import pygame
import random
import sys
# Initialize Pygame
pygame.init()
# Screen dimensions
WIDTH, HEIGHT = 400, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Flappy Bird")
# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
GREEN = (0, 128, 0)
SKY_BLUE = (135, 206, 235)
# Game settings
GRAVITY = 0.5
FLAP_STRENGTH = -10
PIPE_SPEED = 3
PIPE_GAP = 150
PIPE_FREQUENCY = 1500 # milliseconds
# Bird class
class Bird:
def __init__(self):
self.x = 50
self.y = HEIGHT // 2
self.velocity = 0
self.width = 20
self.height = 20
def flap(self):
self.velocity = FLAP_STRENGTH
def update(self):
self.velocity += GRAVITY
self.y += self.velocity
if self.y < 0:
self.y = 0
if self.y > HEIGHT:
self.y = HEIGHT
def draw(self):
pygame.draw.circle(screen, BLACK, (self.x, int(self.y)), self.width // 2)
# Pipe class
class Pipe:
def __init__(self):
self.x = WIDTH
self.top = random.randint(50, HEIGHT - PIPE_GAP - 50)
self.bottom = self.top + PIPE_GAP
self.width = 50
self.passed = False
def update(self):
self.x -= PIPE_SPEED
return self.x > -self.width
def draw(self):
pygame.draw.rect(screen, GREEN, (self.x, 0, self.width, self.top))
pygame.draw.rect(screen, GREEN, (self.x, self.bottom, self.width, HEIGHT - self.bottom))
def collide(self, bird):
if bird.x + bird.width // 2 > self.x and bird.x - bird.width // 2 < self.x + self.width:
if bird.y - bird.height // 2 < self.top or bird.y + bird.height // 2 > self.bottom:
return True
return False
# Main game loop
def game():
bird = Bird()
pipes = []
score = 0
clock = pygame.time.Clock()
last_pipe = pygame.time.get_ticks()
running = True
game_active = True
font = pygame.font.SysFont(None, 55)
while running:
screen.fill(SKY_BLUE)
dt = clock.tick(60)
current_time = pygame.time.get_ticks()
# Event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE and game_active:
bird.flap()
if event.key == pygame.K_r and not game_active:
game()
if game_active:
# Update bird
bird.update()
# Generate new pipes
if current_time - last_pipe > PIPE_FREQUENCY:
pipes.append(Pipe())
last_pipe = current_time
# Update and draw pipes
pipes = [p for p in pipes if p.update()]
for pipe in pipes:
pipe.draw()
if pipe.collide(bird):
game_active = False
# Score logic
if pipe.x + pipe.width < bird.x and not pipe.passed:
score += 1
pipe.passed = True
# Draw bird
bird.draw()
# Check if bird hits the ground or flies too high
if bird.y >= HEIGHT or bird.y <= 0:
game_active = False
# Display score
score_text = font.render(f"Score: {score}", True, BLACK)
screen.blit(score_text, (10, 10))
else:
# Game over screen
game_over_text = font.render("Game Over!", True, BLACK)
restart_text = font.render("Press 'R' to Restart", True, BLACK)
screen.blit(game_over_text, (WIDTH // 2 - 90, HEIGHT // 2 - 50))
screen.blit(restart_text, (WIDTH // 2 - 150, HEIGHT // 2 + 10))
pygame.display.update()
# Start the game
game()š§ Requirements:python
import pygame
import random
import sys
# Initialize Pygame
pygame.init()
# Screen dimensions
WIDTH, HEIGHT = 400, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Flappy Bird")
# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
GREEN = (0, 128, 0)
SKY_BLUE = (135, 206, 235)
# Game settings
GRAVITY = 0.5
FLAP_STRENGTH = -10
PIPE_SPEED = 3
PIPE_GAP = 150
PIPE_FREQUENCY = 1500 # milliseconds
# Bird class
class Bird:
def __init__(self):
self.x = 50
self.y = HEIGHT // 2
self.velocity = 0
self.width = 20
self.height = 20
def flap(self):
self.velocity = FLAP_STRENGTH
def update(self):
self.velocity += GRAVITY
self.y += self.velocity
if self.y < 0:
self.y = 0
if self.y > HEIGHT:
self.y = HEIGHT
def draw(self):
pygame.draw.circle(screen, BLACK, (self.x, int(self.y)), self.width // 2)
# Pipe class
class Pipe:
def __init__(self):
self.x = WIDTH
self.top = random.randint(50, HEIGHT - PIPE_GAP - 50)
self.bottom = self.top + PIPE_GAP
self.width = 50
self.passed = False
def update(self):
self.x -= PIPE_SPEED
return self.x > -self.width
def draw(self):
pygame.draw.rect(screen, GREEN, (self.x, 0, self.width, self.top))
pygame.draw.rect(screen, GREEN, (self.x, self.bottom, self.width, HEIGHT - self.bottom))
def collide(self, bird):
if bird.x + bird.width // 2 > self.x and bird.x - bird.width // 2 < self.x + self.width:
if bird.y - bird.height // 2 < self.top or bird.y + bird.height // 2 > self.bottom:
return True
return False
# Main game loop
def game():
bird = Bird()
pipes = []
score = 0
clock = pygame.time.Clock()
last_pipe = pygame.time.get_ticks()
running = True
game_active = True
font = pygame.font.SysFont(None, 55)
while running:
screen.fill(SKY_BLUE)
dt = clock.tick(60)
current_time = pygame.time.get_ticks()
# Event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE and game_active:
bird.flap()
if event.key == pygame.K_r and not game_active:
game()
if game_active:
# Update bird
bird.update()
# Generate new pipes
if current_time - last_pipe > PIPE_FREQUENCY:
pipes.append(Pipe())
last_pipe = current_time
# Update and draw pipes
pipes = [p for p in pipes if p.update()]
for pipe in pipes:
pipe.draw()
if pipe.collide(bird):
game_active = False
# Score logic
if pipe.x + pipe.width < bird.x and not pipe.passed:
score += 1
pipe.passed = True
# Draw bird
bird.draw()
# Check if bird hits the ground or flies too high
if bird.y >= HEIGHT or bird.y <= 0:
game_active = False
# Display score
score_text = font.render(f"Score: {score}", True, BLACK)
screen.blit(score_text, (10, 10))
else:
# Game over screen
game_over_text = font.render("Game Over!", True, BLACK)
restart_text = font.render("Press 'R' to Restart", True, BLACK)
screen.blit(game_over_text, (WIDTH // 2 - 90, HEIGHT // 2 - 50))
screen.blit(restart_text, (WIDTH // 2 - 150, HEIGHT // 2 + 10))
pygame.display.update()
# Start the game
game()š§ Requirements:python
import pygame
import random
import sys
# Initialize Pygame
pygame.init()
# Screen dimensions
WIDTH, HEIGHT = 400, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Flappy Bird")
# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
GREEN = (0, 128, 0)
SKY_BLUE = (135, 206, 235)
# Game settings
GRAVITY = 0.5
FLAP_STRENGTH = -10
PIPE_SPEED = 3
PIPE_GAP = 150
PIPE_FREQUENCY = 1500 # milliseconds
# Bird class
class Bird:
def __init__(self):
self.x = 50
self.y = HEIGHT // 2
self.velocity = 0
self.width = 20
self.height = 20
def flap(self):
self.velocity = FLAP_STRENGTH
def update(self):
self.velocity += GRAVITY
self.y += self.velocity
if self.y < 0:
self.y = 0
if self.y > HEIGHT:
self.y = HEIGHT
def draw(self):
pygame.draw.circle(screen, BLACK, (self.x, int(self.y)), self.width // 2)
# Pipe class
class Pipe:
def __init__(self):
self.x = WIDTH
self.top = random.randint(50, HEIGHT - PIPE_GAP - 50)
self.bottom = self.top + PIPE_GAP
self.width = 50
self.passed = False
def update(self):
self.x -= PIPE_SPEED
return self.x > -self.width
def draw(self):
pygame.draw.rect(screen, GREEN, (self.x, 0, self.width, self.top))
pygame.draw.rect(screen, GREEN, (self.x, self.bottom, self.width, HEIGHT - self.bottom))
def collide(self, bird):
if bird.x + bird.width // 2 > self.x and bird.x - bird.width // 2 < self.x + self.width:
if bird.y - bird.height // 2 < self.top or bird.y + bird.height // 2 > self.bottom:
return True
return False
# Main game loop
def game():
bird = Bird()
pipes = []
score = 0
clock = pygame.time.Clock()
last_pipe = pygame.time.get_ticks()
running = True
game_active = True
font = pygame.font.SysFont(None, 55)
while running:
screen.fill(SKY_BLUE)
dt = clock.tick(60)
current_time = pygame.time.get_ticks()
# Event handling
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE and game_active:
bird.flap()
if event.key == pygame.K_r and not game_active:
game()
if game_active:
# Update bird
bird.update()
# Generate new pipes
if current_time - last_pipe > PIPE_FREQUENCY:
pipes.append(Pipe())
last_pipe = current_time
# Update and draw pipes
pipes = [p for p in pipes if p.update()]
for pipe in pipes:
pipe.draw()
if pipe.collide(bird):
game_active = False
# Score logic
if pipe.x + pipe.width < bird.x and not pipe.passed:
score += 1
pipe.passed = True
# Draw bird
bird.draw()
# Check if bird hits the ground or flies too high
if bird.y >= HEIGHT or bird.y <= 0:
game_active = False
# Display score
score_text = font.render(f"Score: {score}", True, BLACK)
screen.blit(score_text, (10, 10))
else:
# Game over screen
game_over_text = font.render("Game Over!", True, BLACK)
restart_text = font.render("Press 'R' to Restart", True, BLACK)
screen.blit(game_over_text, (WIDTH // 2 - 90, HEIGHT // 2 - 50))
screen.blit(restart_text, (WIDTH // 2 - 150, HEIGHT // 2 + 10))
pygame.display.update()
# Start the game
game()Deploy This Model
Production-ready deployment in minutes
Together.ai
Instant API access to this model
Production-ready inference API. Start free, scale to millions.
Try Free APIReplicate
One-click model deployment
Run models in the cloud with simple API. No DevOps required.
Deploy NowDisclosure: We may earn a commission from these partners. This helps keep LLMYourWay free.