用【Python】编写【愤怒的小鸟过墙】游戏。


import pygame
import random
 
from objects import Player, Bar, Ball, Block, ScoreCard, Message, Particle, generate_particles
 
pygame.init()
SCREEN = WIDTH, HEIGHT = 288, 512
 
info = pygame.display.Info()
width = info.current_w
height = info.current_h
 
if width >= height:
    win = pygame.display.set_mode(SCREEN, pygame.NOFRAME)
else:
    win = pygame.display.set_mode(SCREEN, pygame.NOFRAME | pygame.SCALED | pygame.FULLSCREEN)
 
clock = pygame.time.Clock()
FPS = 45
 
# COLORS
 
RED = (255, 0, 0)
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
GRAY = (54, 69, 79)
c_list = [RED, BLACK, WHITE]
 
# Fonts
 
pygame.font.init()
score_font = pygame.font.Font('Fonts/BubblegumSans-Regular.ttf', 50)
 
# Sounds
 
coin_fx = pygame.mixer.Sound('Sounds/coin.mp3')
death_fx = pygame.mixer.Sound('Sounds/death.mp3')
move_fx = pygame.mixer.Sound('Sounds/move.mp3')
 
# backgrounds
 
bg_list = []
for i in range(1,5):
    if i == 2:
        ext = "jpeg"
    else:
        ext = "jpg"
    img = pygame.image.load(f"Assets/Backgrounds/bg{i}.{ext}")
    img = pygame.transform.scale(img, (WIDTH, HEIGHT))
    bg_list.append(img)
 
home_bg = pygame.image.load(f"Assets/Backgrounds/home.jpeg")
 
bg = home_bg
 
# objects
bar_group = pygame.sprite.Group()
ball_group = pygame.sprite.Group()
block_group = pygame.sprite.Group()
destruct_group = pygame.sprite.Group()
win_particle_group = pygame.sprite.Group()
bar_gap = 120

  • 22
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值