Skip to content
  • P
    Projects
  • G
    Groups
  • S
    Snippets
  • Help

Administrator / level3-lesson24-diy3

  • This project
    • Loading...
  • Sign in
Go to a project
  • Project
  • Repository
  • Issues 0
  • Merge Requests 0
  • Pipelines
  • Wiki
  • Snippets
  • Members
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Branches
  • Tags
  • Contributors
  • Graph
  • Compare
  • Charts
Commit 8f2aa148 authored 3 years ago by BellCodeEditor's avatar BellCodeEditor
Browse files
Options
  • Browse Files
  • Download
  • Email Patches
  • Plain Diff

save project

parent 5e84fcaf c112593l1746p256a15898/wx057783
Show whitespace changes
Inline Side-by-side
Showing with 15 additions and 2 deletions
  • PYG03-flower.png
  • a.py
PYG03-flower.png 0 → 100644
View file @ 8f2aa148
PYG03-flower.png

2.98 KB

This diff is collapsed. Click to expand it.
a.py
View file @ 8f2aa148
import pygame
pygame.init()
size=width,height=600,400
vInfo=pygame.display.Info()
size=width,height=vInfo.current_w,vInfo.current_h
# size=width,height=600,400
speed=[1,1]
black= 0,0,0
fps=300
......@@ -8,12 +11,18 @@ fclock=pygame.time.Clock()
ball=pygame.image.load(r'C:\Users\Administrator\Desktop\ball.gif')
ballrect=ball.get_rect()
screen=pygame.display.set_mode(size,pygame.RESIZABLE)
# screen=pygame.display.set_mode(size,pygame.NOFRAME)
# screen=pygame.display.set_mode(size,pygame.FULLSCREEN)
pygame.display.set_caption('pygame游戏之旅')
flower=pygame.image.load(r'C:\Users\Administrator\Documents\level3-lesson24-diy3\PYG03-flower.png')
pygame.display.set_icon(flower)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit()
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_q:
exit()
if event.key == pygame.K_LEFT:
speed[0] = speed[0] if speed==0 else abs(speed[0])-1
elif event.key ==pygame.K_RIGHT:
......@@ -22,11 +31,15 @@ while True:
speed[1]= speed[1]+ 1 if speed[1] > 0 else speed[1]-1
elif event.key ==pygame.K_DOWN:
speed[1]= speed[1] if speed==0 else abs(speed[1])-1
elif event.type == pygame.VIDEORESIZE:
size=width,height= event.size[0], event.size[1]
screen=pygame.display.set_mode(size,pygame.RESIZABLE)
if ballrect.left < 0 or ballrect.right >width:
speed[0]=-speed[0]
if ballrect.top < 0 or ballrect.bottom >height:
speed[1]=-speed[1]
if pygame.display.get_active() == True:
ballrect=ballrect.move(speed[0],speed[1])
screen.fill(black)
screen.blit(ball,ballrect)
......
This diff is collapsed. Click to expand it.
  • Write
  • Preview
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment