-
Notifications
You must be signed in to change notification settings - Fork 3
Update incomplete =patch.py #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: adwaitrawat-patch-1
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| import pygame, random ,threading | ||
|
|
||
| size = width, height = 1000, 1000 | ||
| size = width, height = 1000, 800 | ||
| pixel = 5 | ||
| speed = [pixel,0] | ||
| head = [500,400] | ||
|
|
@@ -12,7 +12,7 @@ | |
| BLUE = (0,0,255) | ||
| YELLOW = (0,255,255) | ||
| BLACK = (0,0,0) | ||
| fps=15 | ||
| fps=20 | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 : | ||
|
|
@@ -73,7 +73,7 @@ def move(): | |
|
|
||
|
|
||
| def wall(): | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
@@ -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 | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() | ||
|
|
@@ -115,3 +117,4 @@ def new_food(): | |
| direction() | ||
| eat() | ||
|
|
||
|
|
||
There was a problem hiding this comment.
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