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

Administrator / pygame_lesson5_diy5

  • 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 b802a166 authored 3 years ago by BellCodeEditor's avatar BellCodeEditor
Browse files
Options
  • Browse Files
  • Download
  • Email Patches
  • Plain Diff

save project

parent 8e02d524
Hide whitespace changes
Inline Side-by-side
Showing with 11 additions and 4 deletions
  • my_music.py
my_music.py
View file @ b802a166
import pygame import pygame
import os import os
from pygame import locals from pygame import locals
FPS=pygame.time.Clock()
pygame.init() # 初始化 pygame.init() # 初始化
# 创建窗口 # 创建窗口
screen = pygame.display.set_mode((640, 480)) screen = pygame.display.set_mode((640, 480))
...@@ -58,14 +58,17 @@ while True: ...@@ -58,14 +58,17 @@ while True:
else: else:
play_button = play_img play_button = play_img
pygame.mixer.music.pause() pygame.mixer.music.pause()
if x>120 and x<220 and y>350 and y<400: if x>120 and x<220 and y>350 and y<400:
list_num-=1 list_num-=1
if list_num<0: if list_num<0:
list_num=len(music_list)-1 list_num=len(music_list)-1
pygame.mixer.music.load(path_+"\\"+music_list[list_num]) pygame.mixer.music.load(path_+"\\"+music_list[list_num])
pygame.mixer.music.play() pygame.mixer.music.play()
click=0 #click=0
play_button=stop_img play_button=stop_img
if x>420 and x<520 and y>350 and y<400: if x>420 and x<520 and y>350 and y<400:
list_num+=1 list_num+=1
...@@ -87,8 +90,10 @@ while True: ...@@ -87,8 +90,10 @@ while True:
new_logo = pygame.transform.rotate(logo_img, angle) new_logo = pygame.transform.rotate(logo_img, angle)
newRect = new_logo.get_rect(center=(320,200)) newRect = new_logo.get_rect(center=(320,200))
pos=(newRect[0], newRect[1]) pos=(newRect[0], newRect[1])
angle +=1 if play_button==stop_img:
angle +=1
# 绘制画面 # 绘制画面
screen.blit(bg_img, (0, 0)) # 填充背景 screen.blit(bg_img, (0, 0)) # 填充背景
screen.blit(play_button, (270, 330)) # 暂停按钮 screen.blit(play_button, (270, 330)) # 暂停按钮
...@@ -97,4 +102,6 @@ while True: ...@@ -97,4 +102,6 @@ while True:
screen.blit(next_img, (420, 350)) # 下一曲 screen.blit(next_img, (420, 350)) # 下一曲
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(70)
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