Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions incomplete patch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pygame, random ,threading

size = width, height = 1000, 1000
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i left out the extra part for the score board

size = width, height = 1000, 800
pixel = 5
speed = [pixel,0]
head = [500,400]
Expand All @@ -12,7 +12,7 @@
BLUE = (0,0,255)
YELLOW = (0,255,255)
BLACK = (0,0,0)
fps=15
fps=20
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does not actually change anything (untill its less than 5)


def direction():
if event.type == pygame.KEYDOWN :
Expand Down Expand Up @@ -73,7 +73,7 @@ def move():


def wall():
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for the wall function anymore

if head[0] + pixel >= 1000 or head[1] + pixel >= 800 or head[0] <= pixel*2 - 2 or head[1] + pixel <= pixel*2 - 2 :
if head[0] + 2*pixel >= 1000 or head[1] + 2*pixel >= 800 or head[0] <= 0 or head[1] <= 0 :
return 0
else:
return 1
Expand All @@ -96,14 +96,16 @@ def eat():

def new_food():
display()
food[0]=random.randint(0,1000-pixel)
food[1]=random.randint(0,800-pixel)
food[0]=random.randint(0+pixel,1000-pixel)
food[1]=random.randint(0+pixel,800-pixel)
pygame.draw.circle(screen, YELLOW, (food[0], food[1]), pixel)
pygame.display.update()
pass

screen = pygame.display.set_mode(size)
clock = pygame.time.Clock()
timer_event = pygame.USEREVENT + 1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think this is necessary since i added threading to the program and it takes care of that problem

pygame.time.set_timer(timer_event, 250) #Adds continuos mobility to the head
pygame.init()
display()
new_food()
Expand All @@ -115,3 +117,4 @@ def new_food():
direction()
eat()