Posts

Showing posts from October, 2022

🐍 SNAKE GAME USING PYTHON🐍

Image
                      Code:- import pygame import random # initializing pygame pygame.init() # Colors white = ( 255 , 255 , 255 ) # rgb format red = ( 255 , 0 , 0 ) black = ( 0 , 0 , 0 ) # Creating window screen_width = 900 screen_height = 600 gameWindow = pygame.display.set_mode((screen_width , screen_height)) # Game Title pygame.display.set_caption( "Tech Solutions" ) pygame.display.update() clock = pygame.time.Clock() font = pygame.font.SysFont( None, 55 ) def text_screen (text , color , x , y): screen_text = font.render(text , True, color) gameWindow.blit(screen_text , [x , y]) def plot_snake (gameWindow , color , snk_list , snake_size): for x , y in snk_list: pygame.draw.rect(gameWindow , color , [x , y , snake_size , snake_size]) # Game Loop def gameloop (): exit_game = False game_over = False snake_x = 45 snake_y = 55 velocity_x = 0 velocity_y = 0 snk_list = [] snk_length = ...