MAKE SNAKE GAME USING PYTHON WITH JUST FEW LINES OF CODES CREDIT: AVI SOURCE CODE: import pygame import time import random pygame.init() white = ( 255 , 255 , 255 ) yellow = ( 255 , 255 , 102 ) black = ( 0 , 0 , 0 ) red = ( 213 , 50 , 80 ) green = ( 0 , 255 , 0 ) blue = ( 50 , 153 , 213 ) dis_width = 800 dis_height = 600 dis = pygame.display.set_mode((dis_width, dis_height)) pygame.display.set_caption( 'Snake Game by Avi' ) clock = pygame.time.Clock() snake_block = 10 snake_speed = 10 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 , yellow) dis.blit(value, [ 0 , 0 ]) def our_snake ( snake_block , snake_list ): for x in snake_list: pygame.draw.rect(dis, black, [x[ 0 ], x[ 1 ], snake_block, snake_block]) def message ( msg , color ): mesg = font_style.render(msg, Tru
Comments
Post a Comment