pygame小游戏 海洋之神大冒险

利用pygame自制小游戏。

海洋之神在漆黑的海底深处,利用自身的光勇敢前进!在海里收集鱼骨头,有些鱼骨头可以转化为武器,用来攻击敌人。

开始:

 游戏开始的界面: 

快通关啦!

结尾致敬超级马里奥,碰到小蘑菇就可以去下一关冒险!

海底背景自己画的,按钮图案自己画的,通关蘑菇自己画的。 

特效代码

import pygame
import random
import sys
import time

pygame.init()
clock = pygame.time.Clock()

win = pygame.display.set_mode((800, 600))
pygame.display.set_caption("Particles")

particles = []
colors = [(255, 255,250), (235, 65, 54), (255, 69, 0)]


class Particle():
    def __init__(self, x, y, xvel, yvel, radius, color, gravity=None):
        self.x = x
        self.y = y
        self.xvel = xvel
        self.yvel = yvel
        self.radius = radius
        self.color = color
        self.gravity = gravity

    def render(self, win):
        self.x += self.xvel
        self.y += self.yvel
        if self.gravity != None:
            self.yvel += self.gravity
        self.radius -= 0.1

        pygame.draw.circle(win, self.color, (self.x, self.y), self.radius)



def DrawParticles():
    for particle in particles:
        particle.render(win)
        if particle.radius <= 0:
            particles.remove(particle)



while True:
    clock.tick(60)
    for event in pygame.event.get():
        pos = pygame.mouse.get_pos()
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit(0)

    for x in range(random.randint(5, 20)):
        particle = Particle(pos[0], pos[1], random.randint(-100, 0) / 10, random.randint(1, 3), random.randint(2, 5),
                            random.choice(colors))
        particles.append(particle)

    win.fill((0, 0, 0))
    DrawParticles()
    pygame.display.update()


Credits:

游戏主角形象 :Cute Girl - Free Sprites | OpenGameArt.org

地图编辑器参考:https://github.com/russs123/LevelEditor

Fish Pack:

Gunner - Animated Character by Secret Hideout

Fantasy Game Music | Soundimage.org

Bullet Whizzing By Sounds | Effects | Sound Bites | Sound Clips from SoundBible.com

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值