Anoop Velivela

About Candidate

import time

print(“Who’s the best?”)
for i in range(3, 0, -1):
print(i)
time.sleep(1)

print(“Anoop Velivela”)

Free snake game code in python:
import pygame
import random
import sys

pygame.init()

WIDTH, HEIGHT = 600, 400
GRID_SIZE = 20
GRID_WIDTH = WIDTH // GRID_SIZE
GRID_HEIGHT = HEIGHT // GRID_SIZE

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

screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption(“Snake Game”)
clock = pygame.time.Clock()

def draw_snake(snake):
for segment in snake:
pygame.draw.rect(screen, GREEN, (segment[0] * GRID_SIZE, segment[1] * GRID_SIZE, GRID_SIZE, GRID_SIZE))

def draw_food(food):
pygame.draw.rect(screen, RED, (food[0] * GRID_SIZE, food[1] * GRID_SIZE, GRID_SIZE, GRID_SIZE))

def main():
snake = [(GRID_WIDTH // 2, GRID_HEIGHT // 2)]
direction = (1, 0)
food = (random.randint(0, GRID_WIDTH – 1), random.randint(0, GRID_HEIGHT – 1))
score = 0

font = pygame.font.Font(None, 36)

running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_UP and direction != (0, 1):
direction = (0, -1)
elif event.key == pygame.K_DOWN and direction != (0, -1):
direction = (0, 1)
elif event.key == pygame.K_LEFT and direction != (1, 0):
direction = (-1, 0)
elif event.key == pygame.K_RIGHT and direction != (-1, 0):
direction = (1, 0)

head = snake[0]
new_head = ((head[0] + direction[0]) % GRID_WIDTH, (head[1] + direction[1]) % GRID_HEIGHT)

if new_head in snake:
print(f”Game Over! Final Score: {score}”)
running = False
continue

snake.insert(0, new_head)

if new_head == food:
score += 1
food = (random.randint(0, GRID_WIDTH – 1), random.randint(0, GRID_HEIGHT – 1))
while food in snake:
food = (random.randint(0, GRID_WIDTH – 1), random.randint(0, GRID_HEIGHT – 1))
else:
snake.pop()

screen.fill(BLACK)
draw_snake(snake)
draw_food(food)

score_text = font.render(f”Score: {score}”, True, WHITE)
screen.blit(score_text, (10, 10))

pygame.display.flip()
clock.tick(10)

pygame.quit()

if __name__ == “__main__”:
main()

Location

Be the first to review “Anoop Velivela”

Your Rating for this listing