December 16, 2024
Your Ultimate Guide to Epic Online Adventures
snake game
LIVE FEATURED

snake game

4.4 (1011 reviews)
5★
70%
4★
20%
3★
7%
2★
2%
1★
1%
Fantasy MMORPG PvE Raids Guilds

Snake Game

Here's a simple implementation of the classic Snake game in Python using Pygame:

import pygame
import time
import random

pygame.init()

# Colors
white = (255, 255, 255)
black = (0, 0, 0)
red = (213, 50, 80)
green = (0, 255, 0)
blue = (50, 153, 213)

# Screen dimensions
dis_width = 800
dis_height = 600

# Initialize game
dis = pygame.display.set_mode((dis_width, dis_height))
pygame.display.set_caption('Snake Game')

clock = pygame.time.Clock()
snake_block = 10
snake_speed = 15

font_style = pygame.font.SysFont("bahnschrift", 25)
score_font = pygame.font.SysFont("comicsansms", 35)

def your_score(score):
    value = score_font.render("Your Score: " + str(score), True, black)
    dis.blit(value, [0, 0])

def our_snake(snake_block, snake_list):
    for x in snake_list:
        pygame.draw.rect(dis, green, [x[0], x[1], snake_block, snake_block)

def message(msg, color):
    mesg = font_style.render(msg, True, color)
    dis.blit(mesg, [dis_width / 6, dis_height / 3])

def gameLoop():
    game_over = False
    game_close = False

    x1 = dis_width / 2
    y1 = dis_height / 2

    x1_change = 0
    y1_change = 0

    snake_List = []
    Length_of_snake = 1

    foodx = round(random.randrange(0, dis_width - snake_block) / 10.0) * 10.0
    foody = round(random.randrange(0, dis_height - snake_block) / 10.0) * 10.0

    while not game_over:

        while game_close == True:
            dis.fill(white)
            message("You Lost! Press Q-Quit or C-Play Again", red)
            your_score(Length_of_snake - 1)
            pygame.display.update()

            for event in pygame.event.get():
                if event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_q:
                        game_over = True
                        game_close = False
                    if event.key == pygame.K_c:
                        gameLoop()

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                game_over = True
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_LEFT:
                    x1_change = -snake_block
                    y1_change = 0
                elif event.key == pygame.K_RIGHT:
                    x1_change = snake_block
                    y1_change = 0
                elif event.key == pygame.K_UP:
                    y1_change = -snake_block
                    x1_change = 0
                elif event.key == pygame.K_DOWN:
                    y1_change = snake_block
                    x1_change = 0

        if x1 >= dis_width or x1 < 0 or y1 >= dis_height or y1 < 0:
            game_close = True
        x1 += x1_change
        y1 += y1_change
        dis.fill(white)
        pygame.draw.rect(dis, red, [foodx, foody, snake_block, snake_block])

        snake_Head = []
        snake_Head.append(x1)
        snake_Head.append(y1)
        snake_List.append(snake_Head)
        if len(snake_List) > Length_of_snake:
            del snake_List[0]

        for x in snake_List[:-1]:
            if x == snake_Head:
                game_close = True

        our_snake(snake_block, snake_List)
        your_score(Length_of_snake - 1)

        pygame.display.update()

        if x1 == foodx and y1 == foody:
            foodx = round(random.randrange(0, dis_width - snake_block) / 10.0) * 10.0
            foody = round(random.randrange(0, dis_height - snake_block) / 10.0) * 10.0
            Length_of_snake += 1

        clock.tick(snake_speed)

    pygame.quit()
    quit()

gameLoop()

How to Play:

  1. Use arrow keys to control the snake (Up, Down, Left, Right)
  2. Eat the red food to grow longer
  3. Avoid hitting the walls or yourself
  4. The game ends if you collide with the wall or yourself

Requirements:

  • Python 3.x
  • Pygame library (install with pip install pygame)

Would you like me to explain any part of the code in more detail or suggest modifications?

2.1M
Online Players
2022
Release Date
PC/Mac
Platforms
Multi
Languages

About This Game

Snake Game Here's a simple implementation of the classic Snake game in Python using Pygame: import pygame import time im...

Key Features

  • Massive open world with diverse environments
  • Rich storyline spanning multiple expansions
  • Challenging dungeons and raids
  • Player vs Player combat systems
  • Guild system for team play
  • Extensive character customization
  • Regular content updates

Latest Expansion: The War Within

Venture into the depths of Azeroth itself in this groundbreaking expansion. Face new threats emerging from the planet's core, explore mysterious underground realms, and uncover secrets that will reshape your understanding of the Warcraft universe forever.

Game Information

Developer: Blizzard Entertainment
Publisher: Activision Blizzard
Release Date: November 23, 2004
Genre: MMORPG
Players: Massively Multiplayer

Subscription Plans

$14.99/month Monthly
$41.97/3 months Quarterly
Screenshot 1
Screenshot 2
Screenshot 3
Screenshot 4
Screenshot 5
Screenshot 6

Minimum Requirements

OS: Windows 10 64-bit
Processor: Intel Core i5-3450 / AMD FX 8300
Memory: 4 GB RAM
Graphics: NVIDIA GeForce GTX 760 / AMD Radeon RX 560
DirectX: Version 12
Storage: 70 GB available space

Recommended Requirements

OS: Windows 11 64-bit
Processor: Intel Core i7-6700K / AMD Ryzen 7 2700X
Memory: 8 GB RAM
Graphics: NVIDIA GeForce GTX 1080 / AMD Radeon RX 5700 XT
DirectX: Version 12
Storage: 70 GB SSD space

Player Reviews

EpicGamer42
December 15, 2024
5.0

Amazing expansion!

The War Within brings so much fresh content to WoW. The new zones are absolutely stunning and the storyline is engaging. Been playing for 15 years and this expansion reignited my passion for the game.

RaidLeader99
December 12, 2024
4.0

Great raids, some bugs

The new raid content is fantastic with challenging mechanics. However, there are still some bugs that need to be ironed out. Overall a solid expansion that keeps me coming back for more.

Prev:bdg game

Next:xbox game pass

Latest News & Updates

News

Patch 11.0.5 Now Live

Major balance changes to all classes, new dungeon difficulty, and holiday events are now available. Check out the full patch notes for details.

December 14, 2024 Blizzard Entertainment
News

Holiday Event: Winter's Veil

Celebrate the season with special quests, unique rewards, and festive activities throughout Azeroth. Event runs until January 2nd.

December 10, 2024 Community Team