From 672d7a0457ecfacac9136294034c4d3a5cd9f7a5 Mon Sep 17 00:00:00 2001 From: pxkq8jvuy <1492985642@qq.com> Date: Thu, 30 May 2024 16:09:10 +0800 Subject: [PATCH 1/6] ADD file via upload --- mutiplPicMove.py | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 mutiplPicMove.py diff --git a/mutiplPicMove.py b/mutiplPicMove.py new file mode 100644 index 0000000..11a11a4 --- /dev/null +++ b/mutiplPicMove.py @@ -0,0 +1,52 @@ +import pygame,sys +from random import * +class myBallClass(pygame.sprite.Sprite): + def __init__(self,image_file,location,speed): + pygame.sprite.Sprite.__init__(self) + self.image = pygame.image.load(image_file) + self.rect = self.image.get_rect() + self.rect.left,self.rect.top = location + self.speed = speed + def move(self): + self.rect = self.rect.move(self.speed) + if self.rect.left < 0 or self.rect.right > width: + self.speed[0] = - self.speed[0] + if self.rect.top < 0 or self.rect.bottom > height: + self.speed[1] = - self.speed[1] + +def animate(group): + screen.fill([255,255,255]) + for ball in group: + ball.move() + for ball in group: + group.remove(ball) + if pygame.sprite.spritecollide(ball,group,False): + ball.speed[0] = - ball.speed[0] + ball.speed[1] = - ball.speed[1] + group.add(ball) + screen.blit(ball.image,ball.rect) + + pygame.display.flip() + # pygame.time.delay(20) + + +size = width,height = 640,480 +screen = pygame.display.set_mode(size) +screen.fill([255,255,255]) +img_file = "./bg_img/no.png" +clock = pygame.time.Clock() +group = pygame.sprite.Group() +for row in range(0,2): + for column in range(0,2): + location = [column * 180 + 10,row * 180 + 10] + speed = [choice([-2,2]),choice([-2,2])] + ball = myBallClass(img_file,location,speed) + group.add(ball) +while True: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + frame_rate = clock.get_fps() + print "frame_rate = ",frame_rate + sys.exit() + animate(group) + clock.tick(30) From 7e3be8d14dfc079f16528018155ad4821e1bc82c Mon Sep 17 00:00:00 2001 From: pxkq8jvuy <1492985642@qq.com> Date: Sat, 1 Jun 2024 00:08:29 +0800 Subject: [PATCH 2/6] ADD file via upload --- 桌面 | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 桌面 diff --git a/桌面 b/桌面 new file mode 100644 index 0000000..e69de29 From f78055dd294821f1a27195d001efbd5cf7ebeb9f Mon Sep 17 00:00:00 2001 From: pxkq8jvuy <1492985642@qq.com> Date: Sat, 1 Jun 2024 00:09:03 +0800 Subject: [PATCH 3/6] =?UTF-8?q?Delete=20'=E6=A1=8C=E9=9D=A2'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 桌面 | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 桌面 diff --git a/桌面 b/桌面 deleted file mode 100644 index e69de29..0000000 From c8b1e89e75159cc5581672614f11dfd9d3aa423d Mon Sep 17 00:00:00 2001 From: pxkq8jvuy <1492985642@qq.com> Date: Sat, 1 Jun 2024 00:09:42 +0800 Subject: [PATCH 4/6] ADD file via upload --- singlePicMove.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 singlePicMove.py diff --git a/singlePicMove.py b/singlePicMove.py new file mode 100644 index 0000000..e69de29 From 24d57cb57c7695a49b06593f44825523b2da3f5a Mon Sep 17 00:00:00 2001 From: pxkq8jvuy <1492985642@qq.com> Date: Sat, 1 Jun 2024 00:13:19 +0800 Subject: [PATCH 5/6] Delete 'singlePicMove.py' --- singlePicMove.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 singlePicMove.py diff --git a/singlePicMove.py b/singlePicMove.py deleted file mode 100644 index e69de29..0000000 From d706c7e18e22ce08c18e061864e046ed2e00e577 Mon Sep 17 00:00:00 2001 From: pxkq8jvuy <1492985642@qq.com> Date: Sat, 1 Jun 2024 00:13:59 +0800 Subject: [PATCH 6/6] ADD file via upload --- singlePicMove.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 singlePicMove.py diff --git a/singlePicMove.py b/singlePicMove.py new file mode 100644 index 0000000..e69de29