Python+Pygame實現(xiàn)海洋之神大冒險游戲
利用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
以上就是Python+Pygame實現(xiàn)海洋之神大冒險游戲的詳細內(nèi)容,更多關于Python Pygame游戲的資料請關注腳本之家其它相關文章!
相關文章
python數(shù)據(jù)處理之Pandas類型轉換的實現(xiàn)
本文主要介紹了python數(shù)據(jù)處理之Pandas類型轉換的實現(xiàn),文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2022-04-04
使用Python實現(xiàn)生命之輪Wheel of life效果
生命之輪Wheel of life這一概念最初由 Success Motivation? Institute, Inc. 的創(chuàng)始人 Paul J. Meyer 提出,生命之輪使人能夠根據(jù)此刻的價值觀、愿景和優(yōu)先事項,本文將使用Python實現(xiàn)生命倒計時圖表,感興趣的可以了解下2024-12-12
解決安裝新版PyQt5、PyQT5-tool后打不開并Designer.exe提示no Qt platform plug
這篇文章主要介紹了解決安裝新版PyQt5、PyQT5-tool后打不開并Designer.exe提示no Qt platform plugin的問題,需要的朋友可以參考下2020-04-04
python裝飾器實現(xiàn)對異常代碼出現(xiàn)進行自動監(jiān)控的實現(xiàn)方法
這篇文章主要介紹了python裝飾器實現(xiàn)對異常代碼出現(xiàn)進行自動監(jiān)控的實現(xiàn)方法,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-09-09

