Python+Pygame實(shí)現(xiàn)海洋之神大冒險(xiǎn)游戲
利用pygame自制小游戲。
海洋之神在漆黑的海底深處,利用自身的光勇敢前進(jìn)!在海里收集魚(yú)骨頭,有些魚(yú)骨頭可以轉(zhuǎn)化為武器,用來(lái)攻擊敵人。
開(kāi)始:
游戲開(kāi)始的界面:
快通關(guān)啦!
結(jié)尾致敬超級(jí)馬里奧,碰到小蘑菇就可以去下一關(guān)冒險(xiǎn)!
海底背景自己畫(huà)的,按鈕圖案自己畫(huà)的,通關(guān)蘑菇自己畫(huà)的。
特效代碼
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
以上就是Python+Pygame實(shí)現(xiàn)海洋之神大冒險(xiǎn)游戲的詳細(xì)內(nèi)容,更多關(guān)于Python Pygame游戲的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
- Pygame改編飛機(jī)大戰(zhàn)制作兔子接月餅游戲
- Python pygame 動(dòng)畫(huà)游戲循環(huán)游戲時(shí)鐘實(shí)現(xiàn)原理
- Python+Pygame實(shí)戰(zhàn)之實(shí)現(xiàn)小蜜蜂歷險(xiǎn)記游戲
- Python+Pygame實(shí)戰(zhàn)之英文版猜字游戲的實(shí)現(xiàn)
- Pygame游戲開(kāi)發(fā)之太空射擊實(shí)戰(zhàn)盾牌篇
- Pygame游戲開(kāi)發(fā)之太空射擊實(shí)戰(zhàn)碰撞改進(jìn)篇
- Pygame游戲開(kāi)發(fā)之太空射擊實(shí)戰(zhàn)添加圖形篇
- Pygame游戲開(kāi)發(fā)之太空射擊實(shí)戰(zhàn)子彈與碰撞處理篇
- pygame實(shí)現(xiàn)一個(gè)類似滿天星游戲流程詳解
相關(guān)文章

用生成器來(lái)改寫(xiě)直接返回列表的函數(shù)方法

Python應(yīng)用03 使用PyQT制作視頻播放器實(shí)例

Python實(shí)現(xiàn)數(shù)字小寫(xiě)轉(zhuǎn)大寫(xiě)的示例詳解

python中if的基礎(chǔ)用法(if?else和if?not)