Download presentation
Presentation is loading. Please wait.
1
電腦遊戲設計期末報告 林鴻文 陳韋瑄 徐久泰
2
目錄 程式語法 遊戲背景 遊戲簡介 應用技術
3
背景與音效 background = pygame.image.load('back.jpg') pygame.mixer.init()
backs = pygame.mixer.Sound('start_screen.wav') backs.play(); e1=pygame.mixer.Sound('boom.wav')
4
生成敵人 class Block(pygame.sprite.Sprite):
""" This class represents the block. """ def __init__(self, color): # Call the parent class (Sprite) constructor super().__init__() self.image = pygame.image.load("PI.png") self.rect = self.image.get_rect()
5
生成玩家 class Player(pygame.sprite.Sprite):
""" This class represents the Player. """ def __init__(self): """ Set up the player on creation. """ # Call the parent class (Sprite) constructor super().__init__() self.image = pygame.image.load("player.png") self.rect = self.image.get_rect() def update(self): """ Update the player's position. """ # Get the current mouse position. This returns the position # as a list of two numbers. pos = pygame.mouse.get_pos() # Set the player x position to the mouse x position self.rect.x = pos[0]
6
子彈 class Bullet(pygame.sprite.Sprite):
""" This class represents the bullet . """ def __init__(self): # Call the parent class (Sprite) constructor super().__init__() self.image = pygame.image.load("ball.png") self.rect = self.image.get_rect() def update(self): """ Move the bullet. """ self.rect.y -= 3
7
子彈碰撞敵人後 # Calculate mechanics for each bullet
for bullet in bullet_list: # See if it hit a block block_hit_list = pygame.sprite.spritecollide(bullet, block_list, True) # For each block hit, remove the bullet and add to the score for block in block_hit_list: bullet_list.remove(bullet) e1.play(); all_sprites_list.remove(bullet) score += 1 print(score) # Remove the bullet if it flies up off the screen if bullet.rect.y < -10:
8
遊戲背景 人氣電氣鼠的主人,有一天在宇宙遊走 時遇到了強勁的神奇寶貝路卡利歐,他 將拿出神奇寶貝球中最厲害的天王球與 他一決定勝負。
9
遊戲簡介 在遊戲中小智可以在 底部使用滑鼠左右移 動,並且利用滑鼠左 鍵發射神奇寶貝球, 來收服路卡利歐,獲 取分數。
10
使用技術 Python 與 Pygame 檔案讀入 2D圖片顯示 遊戲音樂音效 圖片碰撞消失
Similar presentations