hello,大家好鸭
之前有很多朋友都在问我要一些游戏的代码
所以这篇文章就出来啦
import pygame, os
import time
import random
需要 源码 . 素材 . 点击即可领取 (备注:苏)
effect = pygame.mixer.Sound('sounds/fire.wav')
pygame.mixer.Sound.play(effect)
self.image = pygame.image.load('图片/'+boss_img_name+'.png').convert_alpha()
self.image = pygame.transform.scale(self.image, (1, 12))
self.rect = self.image.get_rect()
self.blood = 1000
self.speed = 3.5
super().__init__()
self.screen = screen
alien_num = random.randint(1,5)
self.image = pygame.image.load('图片/alien_' + str(alien_num) + '.png')
# picture = pygame.transform.scale(picture, (1280, 720))
self.image = pygame.transform.scale(self.image,(62,62))
self.rect = self.image.get_rect()
self.score = 10
self.bullet_img = pygame.image.load("图片/alien_bullet.png").convert_alpha()
self.bullet_img = pygame.transform.scale(self.bullet_img, (12, 12))
picture = pygame.transform.scale(picture, (1280, 720))
self.bullets = Group()
self.shoot_frequency = 0
def move(self):
self.rect.top += 5
self.shoot()
self.moveBullet()
def shoot(self):
if self.shoot_frequency % 200 == 0:
bullet = Enemy_Bullet(self.bullet_img, self.rect.midbottom)
self.bullets.add(bullet)
self.shoot_frequency += 1
if self.shoot_frequency > 200:
self.shoot_frequency = 1
def moveBullet(self):
for bullet in self.bullets:
bullet.move()
if bullet.rect.bottom < 0:
self.bullets.remove(bullet)
def drawBullets(self, scr):
self.bullets.draw(scr)
self.rect.midbottom = init_pos
self.rect.centery +=36
self.speed = 8
self.screen = screen
self.image_big = pygame.image.load('图片/hero.png').convert_alpha()
# subsurface 形成大图的子表面框架
self.image = self.image_big.subsurface(pygame.Rect(120, 0, 318 - 240, 87))
self.rect = self.image.get_rect()
self.screen_rect