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

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

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

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