- 36 pygame.transform 179. Python Module Index 191 ii. CHAPTER 1 pygame.camera pygame module for camera use. Pygame Documentation, Release 1.9.2.
- How do I download Pygame for Python 3.6.2? Update Cancel. A d b y J i r a S o f t w a r e, A t l a s s i a n. Jira official site. One tool to track issues & release great software. Pip install pygame this should download pygame for your system. Or if you want to download it manually,check your computer properties at.
Sep 3, 2017 - (I installed Python through Anaconda but this should also work if you used python.org.). Pip install pygame-1.9.3-cp36-cp36m-win_amd64.whl. Apr 18, 2018 - This guide provides the steps needed to install Pygame for Python 3.6 on. Waka flocka no hands download. Folder, and double-click on the Python folder (i.e.
Posted by2 years ago
Archived
installing 64 bit pygame for windows 10 Python 3.6.0
I have so many versions of python installed I had trouble getting pygame imported into the new python. I finally figured it out the long way from here http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame and typed from a command prompt in folder: C:UsersUSERNAMEAppDataLocalProgramsPythonPython36>
scriptspip.exe install c:usersUSERNAMEdownloadspygame-1.9.2-cp36-cp36m-win_amd64.whl
which resulted in:
Processing c:usersUSERNAMEdownloadspygame-1.9.2-cp36-cp36m-win_amd64.whl
Installing collected packages: pygame
Successfully installed pygame-1.9.2
Hope it works for you too. Of course replace USERNAME above with your windows 10 username.
scriptspip.exe install c:usersUSERNAMEdownloadspygame-1.9.2-cp36-cp36m-win_amd64.whl
which resulted in:
Processing c:usersUSERNAMEdownloadspygame-1.9.2-cp36-cp36m-win_amd64.whl
Installing collected packages: pygame
Successfully installed pygame-1.9.2
Hope it works for you too. Of course replace USERNAME above with your windows 10 username.
67% Upvoted
nsnake.py
import sys,os,pygame,random,math |
pygame.init() |
pygame.display.set_caption('Nsnake v1.0') |
pygame.font.init() |
random.seed() |
#Global constant definitions |
SPEED=0.36 |
SNAKE_SIZE=9 |
APPLE_SIZE=SNAKE_SIZE |
SEPARATION=10 |
SCREEN_HEIGHT=600 |
SCREEN_WIDTH=800 |
FPS=25 |
KEY= {'UP':1,'DOWN':2,'LEFT':3,'RIGHT':4} |
#Screen initialization |
screen = pygame.display.set_mode((SCREEN_WIDTH,SCREEN_HEIGHT),pygame.HWSURFACE) |
#Resources |
score_font = pygame.font.Font(None,38) |
score_numb_font = pygame.font.Font(None,28) |
game_over_font = pygame.font.Font(None,46) |
play_again_font = score_numb_font |
score_msg = score_font.render('Score:',1,pygame.Color('green')) |
score_msg_size = score_font.size('Score') |
#icon = pygame.image.load('nsnake32.png') |
#pygame.display.set_icon(icon) |
background_color = pygame.Color(74,74,74) |
black = pygame.Color(0,0,0) |
#Clock |
gameClock = pygame.time.Clock() |
defcheckCollision(posA,As,posB,Bs): |
#As size of a | Bs size of B |
if(posA.x < posB.x+Bs and posA.x+As > posB.x and posA.y < posB.y + Bs and posA.y+As > posB.y): |
returnTrue |
returnFalse |
defcheckLimits(entity): |
if(entity.x >SCREEN_WIDTH): |
entity.x =SNAKE_SIZE |
if(entity.x <0): |
entity.x =SCREEN_WIDTH-SNAKE_SIZE |
if(entity.y >SCREEN_HEIGHT): |
entity.y =SNAKE_SIZE |
if(entity.y <0): |
entity.y =SCREEN_HEIGHT-SNAKE_SIZE |
classApple: |
def__init__(self,x,y,state): |
self.x = x |
self.y = y |
self.state = state |
self.color = pygame.color.Color('red') |
defdraw(self,screen): |
pygame.draw.rect(screen,self.color,(self.x,self.y,APPLE_SIZE,APPLE_SIZE),0) |
classSegment: |
def__init__(self,x,y): |
self.x = x |
self.y = y |
self.direction =KEY['UP'] |
self.color ='white' |
classSnake: |
def__init__(self,x,y): |
self.x = x |
self.y = y |
self.direction =KEY['UP'] |
self.stack = [] |
self.stack.append(self) |
blackBox = Segment(self.x,self.y +SEPARATION) |
blackBox.direction =KEY['UP'] |
blackBox.color ='NULL' |
self.stack.append(blackBox) |
defmove(self): |
last_element =len(self.stack)-1 |
while(last_element !=0): |
self.stack[last_element].direction =self.stack[last_element-1].direction |
self.stack[last_element].x =self.stack[last_element-1].x |
self.stack[last_element].y =self.stack[last_element-1].y |
last_element-=1 |
if(len(self.stack)<2): |
last_segment =self |
else: |
last_segment =self.stack.pop(last_element) |
last_segment.direction =self.stack[0].direction |
if(self.stack[0].direction KEY['UP']): |
last_segment.y =self.stack[0].y - (SPEED*FPS) |
elif(self.stack[0].direction KEY['DOWN']): |
last_segment.y =self.stack[0].y + (SPEED*FPS) |
elif(self.stack[0].direction KEY['LEFT']): |
last_segment.x =self.stack[0].x - (SPEED*FPS) |
elif(self.stack[0].direction KEY['RIGHT']): |
last_segment.x =self.stack[0].x + (SPEED*FPS) |
self.stack.insert(0,last_segment) |
defgetHead(self): |
return(self.stack[0]) |
defgrow(self): |
last_element =len(self.stack)-1 |
self.stack[last_element].direction =self.stack[last_element].direction |
if(self.stack[last_element].direction KEY['UP']): |
newSegment = Segment(self.stack[last_element].x,self.stack[last_element].y-SNAKE_SIZE) |
blackBox = Segment(newSegment.x,newSegment.y-SEPARATION) |
elif(self.stack[last_element].direction KEY['DOWN']): |
newSegment = Segment(self.stack[last_element].x,self.stack[last_element].y+SNAKE_SIZE) |
blackBox = Segment(newSegment.x,newSegment.y+SEPARATION) |
elif(self.stack[last_element].direction KEY['LEFT']): |
newSegment = Segment(self.stack[last_element].x-SNAKE_SIZE,self.stack[last_element].y) |
blackBox = Segment(newSegment.x-SEPARATION,newSegment.y) |
elif(self.stack[last_element].direction KEY['RIGHT']): |
newSegment = Segment(self.stack[last_element].x+SNAKE_SIZE,self.stack[last_element].y) |
blackBox = Segment(newSegment.x+SEPARATION,newSegment.y) |
blackBox.color ='NULL' |
self.stack.append(newSegment) |
self.stack.append(blackBox) |
defiterateSegments(self,delta): |
pass |
defsetDirection(self,direction): |
if(self.direction KEY['RIGHT'] and direction KEY['LEFT'] orself.direction KEY['LEFT'] and direction KEY['RIGHT']): |
pass |
elif(self.direction KEY['UP'] and direction KEY['DOWN'] orself.direction KEY['DOWN'] and direction KEY['UP']): |
pass |
else: |
self.direction = direction |
defget_rect(self): |
rect = (self.x,self.y) |
return rect |
defgetX(self): |
returnself.x |
defgetY(self): |
returnself.y |
defsetX(self,x): |
self.x = x |
defsetY(self,y): |
self.y = y |
defcheckCrash(self): |
counter =1 |
while(counter <len(self.stack)-1): |
if(checkCollision(self.stack[0],SNAKE_SIZE,self.stack[counter],SNAKE_SIZE)andself.stack[counter].color !='NULL'): |
returnTrue |
counter+=1 |
returnFalse |
defdraw(self,screen): |
pygame.draw.rect(screen,pygame.color.Color('yellow'),(self.stack[0].x,self.stack[0].y,SNAKE_SIZE,SNAKE_SIZE),0) |
counter =1 |
while(counter <len(self.stack)): |
if(self.stack[counter].color 'NULL'): |
counter+=1 |
continue |
pygame.draw.rect(screen,pygame.color.Color('white'),(self.stack[counter].x,self.stack[counter].y,SNAKE_SIZE,SNAKE_SIZE),0) |
counter+=1 |
defgetKey(): |
for event in pygame.event.get(): |
if event.type pygame.KEYDOWN: |
if event.key pygame.K_UP: |
returnKEY['UP'] |
elif event.key pygame.K_DOWN: |
returnKEY['DOWN'] |
elif event.key pygame.K_LEFT: |
returnKEY['LEFT'] |
elif event.key pygame.K_RIGHT: |
returnKEY['RIGHT'] |
elif event.key pygame.K_ESCAPE: |
return'exit' |
elif event.key pygame.K_y: |
return'yes' |
elif event.key pygame.K_n: |
return'no' |
if event.type pygame.QUIT: |
sys.exit() |
defrespawnApple(apples,index,sx,sy): |
radius = math.sqrt((SCREEN_WIDTH/2*SCREEN_WIDTH/2+SCREEN_HEIGHT/2*SCREEN_HEIGHT/2))/2 |
angle =999 |
while(angle > radius): |
angle = random.uniform(0,800)*math.pi*2 |
x =SCREEN_WIDTH/2+ radius * math.cos(angle) |
y =SCREEN_HEIGHT/2+ radius * math.sin(angle) |
if(x sx and y sy): |
continue |
newApple = Apple(x,y,1) |
apples[index] = newApple |
defrespawnApples(apples,quantity,sx,sy): |
counter =0 |
del apples[:] |
radius = math.sqrt((SCREEN_WIDTH/2*SCREEN_WIDTH/2+SCREEN_HEIGHT/2*SCREEN_HEIGHT/2))/2 |
angle =999 |
while(counter < quantity): |
while(angle > radius): |
angle = random.uniform(0,800)*math.pi*2 |
x =SCREEN_WIDTH/2+ radius * math.cos(angle) |
y =SCREEN_HEIGHT/2+ radius * math.sin(angle) |
if( (x-APPLE_SIZE sx or x+APPLE_SIZE sx) and (y-APPLE_SIZE sy or y+APPLE_SIZE sy) or radius - angle <=10): |
continue |
apples.append(Apple(x,y,1)) |
angle =999 |
counter+=1 |
defendGame(): |
message = game_over_font.render('Game Over',1,pygame.Color('white')) |
message_play_again = play_again_font.render('Play Again? Y/N',1,pygame.Color('green')) |
screen.blit(message,(320,240)) |
screen.blit(message_play_again,(320+12,240+40)) |
pygame.display.flip() |
pygame.display.update() |
myKey = getKey() |
while(myKey !='exit'): |
if(myKey 'yes'): |
main() |
elif(myKey 'no'): |
break |
myKey = getKey() |
gameClock.tick(FPS) |
sys.exit() |
defdrawScore(score): |
score_numb = score_numb_font.render(str(score),1,pygame.Color('red')) |
screen.blit(score_msg, (SCREEN_WIDTH-score_msg_size[0]-60,10) ) |
screen.blit(score_numb,(SCREEN_WIDTH-45,14)) |
defdrawGameTime(gameTime): |
game_time = score_font.render('Time:',1,pygame.Color('green')) |
game_time_numb = score_numb_font.render(str(gameTime/1000),1,pygame.Color('red')) |
screen.blit(game_time,(30,10)) |
screen.blit(game_time_numb,(105,14)) |
defexitScreen(): |
pass |
defmain(): |
score =0 |
#Snake initialization |
mySnake = Snake(SCREEN_WIDTH/2,SCREEN_HEIGHT/2) |
mySnake.setDirection(KEY['UP']) |
mySnake.move() |
start_segments=3 |
while(start_segments>0): |
mySnake.grow() |
mySnake.move() |
start_segments-=1 |
#Apples |
max_apples =1 |
eaten_apple =False |
apples = [Apple(random.randint(60,SCREEN_WIDTH),random.randint(60,SCREEN_HEIGHT),1)] |
respawnApples(apples,max_apples,mySnake.x,mySnake.y) |
startTime = pygame.time.get_ticks() |
endgame =0 |
while(endgame!=1): |
gameClock.tick(FPS) |
#Input |
keyPress = getKey() |
if keyPress 'exit': |
endgame =1 |
#Collision check |
checkLimits(mySnake) |
if(mySnake.checkCrash()True): |
endGame() |
for myApple in apples: |
if(myApple.state 1): |
if(checkCollision(mySnake.getHead(),SNAKE_SIZE,myApple,APPLE_SIZE)True): |
mySnake.grow() |
myApple.state =0 |
score+=5 |
eaten_apple=True |
#Position Update |
if(keyPress): |
mySnake.setDirection(keyPress) |
mySnake.move() |
#Respawning apples |
if(eaten_apple True): |
eaten_apple =False |
respawnApple(apples,0,mySnake.getHead().x,mySnake.getHead().y) |
#Drawing |
screen.fill(background_color) |
for myApple in apples: |
if(myApple.state 1): |
myApple.draw(screen) |
mySnake.draw(screen) |
drawScore(score) |
gameTime = pygame.time.get_ticks() - startTime |
drawGameTime(gameTime) |
pygame.display.flip() |
pygame.display.update() |
main() |
Pygame Download For Python 360
commented Nov 11, 2017
Pygame Download For Python 36 Free
https://planningbrown811.weebly.com/village-life-game-free-download.html. Its really a good game. Great work . You should add mew functionalities such as a start and end screen or a high score |
Pygame Download For Python 36 7
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment