Snake Game On Python
Snake Game On Python
Snake Game On Python
import time
import random
pygame.init()
white = (255, 255, 255) #ikut rgb, ni untuk nk input colour supaya tu colour yg
kite nak
yellow = (255, 255, 102)
black = (0, 0, 0)
red = (255, 105, 97)
green = (190, 229, 176)
blue = (174, 198, 207)
pink = (255, 192, 203) #pink cantik
clock = pygame.time.Clock()
def Your_score(score):
value = score_font.render("Your Score: " + str(score), True, yellow) #yellow tu
colour display score
dis.blit(value, [0, 0])
def gameLoop():
game_over = False
game_close = False
snake_List = []
Length_of_snake = 1 #pnjng snake ialah 1 block
while game_close == True: #klw game over, display blue and ckp haha kalah
dis.fill(blue)
message("Haha kalah! Press C-Play Again or Q-Quit", red) #gelakkan org
yg kalah
Your_score(Length_of_snake - 1) #score = panjang snake tolak 1
pygame.display.update()
pygame.display.update() #dia akn update screen setiap kali kita mkn mknn,
so snake pnjng 1, makan 1 mknn, pnjng snake akn 2, jadi score ialah 1
clock.tick(snake_speed)
pygame.quit()
quit() #utk stop semua