国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

python小游戲畢設(shè) 坦克大戰(zhàn)游戲設(shè)計與實現(xiàn)

這篇具有很好參考價值的文章主要介紹了python小游戲畢設(shè) 坦克大戰(zhàn)游戲設(shè)計與實現(xiàn)。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。


0 項目簡介

?? Hi,各位同學(xué)好呀,這里是L學(xué)長!

??今天向大家分享一個今年(2022)最新完成的畢業(yè)設(shè)計項目作品

python小游戲畢設(shè) 坦克大戰(zhàn)小游戲設(shè)計與實現(xiàn) (源碼)

?? 學(xué)長根據(jù)實現(xiàn)的難度和等級對項目進行評分(最低0分,滿分5分)

  • 難度系數(shù):3分

  • 工作量:3分

  • 創(chuàng)新點:4分

1 游戲介紹

《坦克大戰(zhàn)》是由日本南夢宮Namco游戲公司開發(fā)的一款平面射擊游戲,于1985年發(fā)售。游戲以坦克戰(zhàn)斗及保衛(wèi)基地為主題,屬于策略型聯(lián)機類。

同時也是FC平臺上少有的內(nèi)建關(guān)卡編輯器的幾個游戲之一,玩家可自己創(chuàng)建獨特的關(guān)卡,并通過獲取一些道具使坦克和基地得到強化。

今天我們利用python實現(xiàn)簡易版坦克大戰(zhàn)游戲。

2 實現(xiàn)效果

python小游戲畢設(shè) 坦克大戰(zhàn)游戲設(shè)計與實現(xiàn),Python小游戲,畢業(yè)設(shè)計,python,pygame
python小游戲畢設(shè) 坦克大戰(zhàn)游戲設(shè)計與實現(xiàn),Python小游戲,畢業(yè)設(shè)計,python,pygame
python小游戲畢設(shè) 坦克大戰(zhàn)游戲設(shè)計與實現(xiàn),Python小游戲,畢業(yè)設(shè)計,python,pygame

3 開發(fā)工具

3.1 環(huán)境配置

  • Python版本:3.6.4

  • 相關(guān)模塊:

  • pygame模塊;

  • 以及一些Python自帶的模塊。

3.2 Pygame介紹

簡介

Pygame是一系列專門為編寫電子游戲而設(shè)計的Python模塊(modules)。Pygame在已經(jīng)非常優(yōu)秀的SDL庫的基礎(chǔ)上增加了許多功能。這讓你能夠用Python語言編寫出豐富多彩的游戲程序。

Pygame可移植性高,幾乎能在任何平臺和操作系統(tǒng)上運行。

Pygame已經(jīng)被下載過數(shù)百萬次。

Pygame免費開源。它在LGPL許可證(Lesser General Public License,GNU寬通用公共許可證)下發(fā)行。使用Pygame,你可以創(chuàng)造出免費開源,可共享,或者商業(yè)化的游戲。詳情請見LGPL許可證。

優(yōu)點

  • 能夠輕松使用多核CPU(multi core CPUs) :如今雙核CPU很常用,8核CPU在桌面系統(tǒng)中也很便宜,而利用好多核系統(tǒng),能讓你在你的游戲中實現(xiàn)更多東西。特定的pygame函數(shù)能夠釋放令人生畏的python GIL(全局解釋器鎖),這幾乎是你用C語言才能做的事。

  • 核心函數(shù)用最優(yōu)化的C語言或匯編語言編寫:C語言代碼通常比Python代碼運行速度快10-20倍。而匯編語言編寫的代碼(assembly code)比Python甚至快到100多倍。

  • 安裝便捷:一般僅需包管理程序或二進制系統(tǒng)程序便能安裝。

  • 真正地可移植:支持Linux (主要發(fā)行版), Windows (95, 98, ME, 2000, XP, Vista, 64-bit Windows,), Windows CE, BeOS, MacOS, Mac OS X, FreeBSD, NetBSD, OpenBSD, BSD/OS, Solaris, IRIX, and QNX等操作系統(tǒng).也能支持AmigaOS, Dreamcast, Atari, AIX, OSF/Tru64, RISC OS, SymbianOS and OS/2,但是還沒有受到官方認(rèn)可。你也可以在手持設(shè)備,游戲控制臺, One Laptop Per Child (OLPC) computer項目的電腦等設(shè)備中使用pygame.

  • 用法簡單:無論是小孩子還是大人都能學(xué)會用pygame來制作射擊類游戲。

  • 很多Pygame游戲已發(fā)行:其中包括很多游戲大賽入圍作品、非常受歡迎的開源可分享的游戲。

  • 由你來控制主循環(huán):由你來調(diào)用pygame的函數(shù),pygame的函數(shù)并不需要調(diào)用你的函數(shù)。當(dāng)你同時還在使用其他庫來編寫各種各種的程序時,這能夠為你提供極大的掌控權(quán)。

  • 不需要GUI就能使用所有函數(shù):僅在命令行中,你就可以使用pygame的某些函數(shù)來處理圖片,獲取游戲桿輸入,播放音樂……

  • 對bug反應(yīng)迅速:很多bug在被上報的1小時內(nèi)就能被我們修復(fù)。雖然有時候我們確實會卡在某一個bug上很久,但大多數(shù)時候我們都是很不錯的bug修復(fù)者。如今bug的上報已經(jīng)很少了,因為許多bug早已被我們修復(fù)。

  • 代碼量少:pygame并沒有數(shù)以萬計的也許你永遠(yuǎn)用不到的冗雜代碼。pygame的核心代碼一直保持著簡潔特點,其他附加物諸如GUI庫等,都是在核心代碼之外單獨設(shè)計研發(fā)的。

  • 模塊化:你可以單獨使用pygame的某個模塊。想要換著使用一個別的聲音處理庫?沒問題。pygame的很多核心模塊支持獨立初始化與使用。

最小開發(fā)框架

import pygame,sys #sys是python的標(biāo)準(zhǔn)庫,提供Python運行時環(huán)境變量的操控

pygame.init()  #內(nèi)部各功能模塊進行初始化創(chuàng)建及變量設(shè)置,默認(rèn)調(diào)用
size = width,height = 800,600  #設(shè)置游戲窗口大小,分別是寬度和高度
screen = pygame.display.set_mode(size)  #初始化顯示窗口
pygame.display.set_caption("小游戲程序")  #設(shè)置顯示窗口的標(biāo)題內(nèi)容,是一個字符串類型
while True:  #無限循環(huán),直到Python運行時退出結(jié)束
    for event in pygame.event.get():  #從Pygame的事件隊列中取出事件,并從隊列中刪除該事件
        if event.type == pygame.QUIT:  #獲得事件類型,并逐類響應(yīng)
            sys.exit()   #用于退出結(jié)束游戲并退出          
    pygame.display.update()  #對顯示窗口進行更新,默認(rèn)窗口全部重繪

代碼執(zhí)行流程

python小游戲畢設(shè) 坦克大戰(zhàn)游戲設(shè)計與實現(xiàn),Python小游戲,畢業(yè)設(shè)計,python,pygame文章來源地址http://www.zghlxwxcb.cn/news/detail-743259.html

4 具體實現(xiàn)

4.1 實現(xiàn)游戲主循環(huán)

# 主函數(shù)
def main():
	# 初始化
	pygame.init()
	screen = pygame.display.set_mode((630, 630))
	pygame.display.set_caption("坦克大戰(zhàn)")
	# 加載圖片
	bg_img = pygame.image.load("./圖片/others/background.png")
	# 開始界面
	num_player = show_start_interface(screen, 630, 630)
	# 關(guān)卡
	stage = 0
	num_stage = 2
	# 游戲是否結(jié)束
	is_gameover = False
	# 時鐘
	clock = pygame.time.Clock()
	# 主循環(huán)
	while not is_gameover:
		# 關(guān)卡
		stage += 1
		if stage > num_stage:
			break
		show_switch_stage(screen, 630, 630, stage)
		# 該關(guān)卡坦克總數(shù)量
		enemytanks_total = min(stage * 18, 80)
		# 場上存在的敵方坦克總數(shù)量
		enemytanks_now = 0
		# 場上可以存在的敵方坦克總數(shù)量
		enemytanks_now_max = min(max(stage * 2, 4), 8)
		# 精靈組
		tanksGroup = pygame.sprite.Group()
		mytanksGroup = pygame.sprite.Group()
		enemytanksGroup = pygame.sprite.Group()
		bulletsGroup = pygame.sprite.Group()
		mybulletsGroup = pygame.sprite.Group()
		enemybulletsGroup = pygame.sprite.Group()
		myfoodsGroup = pygame.sprite.Group()
		# 自定義事件
		# 	-生成敵方坦克事件
		genEnemyEvent = pygame.constants.USEREVENT + 0
		pygame.time.set_timer(genEnemyEvent, 100)
		# 	-敵方坦克靜止恢復(fù)事件
		recoverEnemyEvent = pygame.constants.USEREVENT + 1
		pygame.time.set_timer(recoverEnemyEvent, 8000)
		# 	-我方坦克無敵恢復(fù)事件
		noprotectMytankEvent = pygame.constants.USEREVENT + 2
		pygame.time.set_timer(noprotectMytankEvent, 8000)
		# 關(guān)卡地圖
		map_stage = scene.Map(stage)
		# 我方坦克
		tank_player1 = tanks.myTank(1)
		tanksGroup.add(tank_player1)
		mytanksGroup.add(tank_player1)
		if num_player > 1:
			tank_player2 = tanks.myTank(2)
			tanksGroup.add(tank_player2)
			mytanksGroup.add(tank_player2)
		is_switch_tank = True
		player1_moving = False
		player2_moving = False
		# 為了輪胎的動畫效果
		time = 0
		# 敵方坦克
		for i in range(0, 3):
			if enemytanks_total > 0:
				enemytank = tanks.enemyTank(i)
				tanksGroup.add(enemytank)
				enemytanksGroup.add(enemytank)
				enemytanks_now += 1
				enemytanks_total -= 1
		# 大本營
		myhome = home.Home()
		# 出場特效
		appearance_img = pygame.image.load("./圖片/others/appear.png").convert_alpha()
		appearances = []
		appearances.append(appearance_img.subsurface((0, 0), (48, 48)))
		appearances.append(appearance_img.subsurface((48, 0), (48, 48)))
		appearances.append(appearance_img.subsurface((96, 0), (48, 48)))
		# 關(guān)卡主循環(huán)
		while True:
			if is_gameover is True:
				break
			if enemytanks_total < 1 and enemytanks_now < 1:
				is_gameover = False
				break
			for event in pygame.event.get():
				if event.type == pygame.QUIT:
					pygame.quit()
					sys.exit()
				if event.type == genEnemyEvent:
					if enemytanks_total > 0:
						if enemytanks_now < enemytanks_now_max:
							enemytank = tanks.enemyTank()
							if not pygame.sprite.spritecollide(enemytank, tanksGroup, False, None):
								tanksGroup.add(enemytank)
								enemytanksGroup.add(enemytank)
								enemytanks_now += 1
								enemytanks_total -= 1
				if event.type == recoverEnemyEvent:
					for each in enemytanksGroup:
						each.can_move = True
				if event.type == noprotectMytankEvent:
					for each in mytanksGroup:
						mytanksGroup.protected = False
			# 檢查用戶鍵盤操作
			key_pressed = pygame.key.get_pressed()
			# 玩家一
			# WSAD -> 上下左右
			# 空格鍵射擊
			if key_pressed[pygame.K_w]:
				tanksGroup.remove(tank_player1)
				tank_player1.move_up(tanksGroup, map_stage.brickGroup, map_stage.ironGroup, myhome)
				tanksGroup.add(tank_player1)
				player1_moving = True
			elif key_pressed[pygame.K_s]:
				tanksGroup.remove(tank_player1)
				tank_player1.move_down(tanksGroup, map_stage.brickGroup, map_stage.ironGroup, myhome)
				tanksGroup.add(tank_player1)
				player1_moving = True
			elif key_pressed[pygame.K_a]:
				tanksGroup.remove(tank_player1)
				tank_player1.move_left(tanksGroup, map_stage.brickGroup, map_stage.ironGroup, myhome)
				tanksGroup.add(tank_player1)
				player1_moving = True
			elif key_pressed[pygame.K_d]:
				tanksGroup.remove(tank_player1)
				tank_player1.move_right(tanksGroup, map_stage.brickGroup, map_stage.ironGroup, myhome)
				tanksGroup.add(tank_player1)
				player1_moving = True
			elif key_pressed[pygame.K_SPACE]:
				if not tank_player1.bullet.being:
					tank_player1.shoot()
			# 玩家二
			# ↑↓←→ -> 上下左右
			# 小鍵盤0鍵射擊
			if num_player > 1:
				if key_pressed[pygame.K_UP]:
					tanksGroup.remove(tank_player2)
					tank_player2.move_up(tanksGroup, map_stage.brickGroup, map_stage.ironGroup, myhome)
					tanksGroup.add(tank_player2)
					player2_moving = True
				elif key_pressed[pygame.K_DOWN]:
					tanksGroup.remove(tank_player2)
					tank_player2.move_down(tanksGroup, map_stage.brickGroup, map_stage.ironGroup, myhome)
					tanksGroup.add(tank_player2)
					player2_moving = True
				elif key_pressed[pygame.K_LEFT]:
					tanksGroup.remove(tank_player2)
					tank_player2.move_left(tanksGroup, map_stage.brickGroup, map_stage.ironGroup, myhome)
					tanksGroup.add(tank_player2)
					player2_moving = True
				elif key_pressed[pygame.K_RIGHT]:
					tanksGroup.remove(tank_player2)
					tank_player2.move_right(tanksGroup, map_stage.brickGroup, map_stage.ironGroup, myhome)
					tanksGroup.add(tank_player2)
					player2_moving = True
				elif key_pressed[pygame.K_KP0]:
					if not tank_player2.bullet.being:
						tank_player2.shoot()
			# 背景
			screen.blit(bg_img, (0, 0))
			# 石頭墻
			for each in map_stage.brickGroup:
				screen.blit(each.brick, each.rect)
			# 鋼墻
			for each in map_stage.ironGroup:
				screen.blit(each.iron, each.rect)
			# 冰
			for each in map_stage.iceGroup:
				screen.blit(each.ice, each.rect)
			# 河流
			for each in map_stage.riverGroup:
				screen.blit(each.river, each.rect)
			# 樹
			for each in map_stage.treeGroup:
				screen.blit(each.tree, each.rect)
			time += 1
			if time == 5:
				time = 0
				is_switch_tank = not is_switch_tank
			# 我方坦克
			if tank_player1 in mytanksGroup:
				if is_switch_tank and player1_moving:
					screen.blit(tank_player1.tank_0, (tank_player1.rect.left, tank_player1.rect.top))
					player1_moving = False
				else:
					screen.blit(tank_player1.tank_1, (tank_player1.rect.left, tank_player1.rect.top))
				if tank_player1.protected:
					screen.blit(tank_player1.protected_mask1, (tank_player1.rect.left, tank_player1.rect.top))
			if num_player > 1:
				if tank_player2 in mytanksGroup:
					if is_switch_tank and player2_moving:
						screen.blit(tank_player2.tank_0, (tank_player2.rect.left, tank_player2.rect.top))
						player1_moving = False
					else:
						screen.blit(tank_player2.tank_1, (tank_player2.rect.left, tank_player2.rect.top))
					if tank_player2.protected:
						screen.blit(tank_player1.protected_mask1, (tank_player2.rect.left, tank_player2.rect.top))
			# 敵方坦克
			for each in enemytanksGroup:
				# 出生特效
				if each.born:
					if each.times > 0:
						each.times -= 1
						if each.times <= 10:
							screen.blit(appearances[2], (3+each.x*12*24, 3))
						elif each.times <= 20:
							screen.blit(appearances[1], (3+each.x*12*24, 3))
						elif each.times <= 30:
							screen.blit(appearances[0], (3+each.x*12*24, 3))
						elif each.times <= 40:
							screen.blit(appearances[2], (3+each.x*12*24, 3))
						elif each.times <= 50:
							screen.blit(appearances[1], (3+each.x*12*24, 3))
						elif each.times <= 60:
							screen.blit(appearances[0], (3+each.x*12*24, 3))
						elif each.times <= 70:
							screen.blit(appearances[2], (3+each.x*12*24, 3))
						elif each.times <= 80:
							screen.blit(appearances[1], (3+each.x*12*24, 3))
						elif each.times <= 90:
							screen.blit(appearances[0], (3+each.x*12*24, 3))
					else:
						each.born = False
				else:
					if is_switch_tank:
						screen.blit(each.tank_0, (each.rect.left, each.rect.top))
					else:
						screen.blit(each.tank_1, (each.rect.left, each.rect.top))
					if each.can_move:
						tanksGroup.remove(each)
						each.move(tanksGroup, map_stage.brickGroup, map_stage.ironGroup, myhome)
						tanksGroup.add(each)
			# 我方子彈
			for tank_player in mytanksGroup:
				if tank_player.bullet.being:
					tank_player.bullet.move()
					screen.blit(tank_player.bullet.bullet, tank_player.bullet.rect)
					# 子彈碰撞敵方子彈
					for each in enemybulletsGroup:
						if each.being:
							if pygame.sprite.collide_rect(tank_player.bullet, each):
								tank_player.bullet.being = False
								each.being = False
								enemybulletsGroup.remove(each)
								break
						else:
							enemybulletsGroup.remove(each)	
					# 子彈碰撞敵方坦克
					for each in enemytanksGroup:
						if each.being:
							if pygame.sprite.collide_rect(tank_player.bullet, each):
								if each.is_red == True:
									myfood = food.Food()
									myfood.generate()
									myfoodsGroup.add(myfood)
									each.is_red = False
								each.blood -= 1
								each.color -= 1
								if each.blood < 0:
									each.being = False
									enemytanksGroup.remove(each)
									enemytanks_now -= 1
									tanksGroup.remove(each)
								else:
									each.reload()
								tank_player.bullet.being = False
								break
						else:
							enemytanksGroup.remove(each)
							tanksGroup.remove(each)
					# 子彈碰撞石頭墻
					if pygame.sprite.spritecollide(tank_player.bullet, map_stage.brickGroup, True, None):
						tank_player.bullet.being = False
					'''
					# 等價方案(更科學(xué)點)
					for each in map_stage.brickGroup:
						if pygame.sprite.collide_rect(tank_player.bullet, each):
							tank_player.bullet.being = False
							each.being = False
							map_stage.brickGroup.remove(each)
							break
					'''
					# 子彈碰鋼墻
					if tank_player.bullet.stronger:
						if pygame.sprite.spritecollide(tank_player.bullet, map_stage.ironGroup, True, None):
							tank_player.bullet.being = False
					else:
						if pygame.sprite.spritecollide(tank_player.bullet, map_stage.ironGroup, False, None):
							tank_player.bullet.being = False
					'''
					# 等價方案(更科學(xué)點)
					for each in map_stage.ironGroup:
						if pygame.sprite.collide_rect(tank_player.bullet, each):
							tank_player.bullet.being = False
							if tank_player.bullet.stronger:
								each.being = False
								map_stage.ironGroup.remove(each)
							break
					'''
					# 子彈碰大本營
					if pygame.sprite.collide_rect(tank_player.bullet, myhome):
						tank_player.bullet.being = False
						myhome.set_dead()
						is_gameover = True
			# 敵方子彈
			for each in enemytanksGroup:
				if each.being:
					if each.can_move and not each.bullet.being:
						enemybulletsGroup.remove(each.bullet)
						each.shoot()
						enemybulletsGroup.add(each.bullet)
					if not each.born:
						if each.bullet.being:
							each.bullet.move()
							screen.blit(each.bullet.bullet, each.bullet.rect)
							# 子彈碰撞我方坦克
							for tank_player in mytanksGroup:
								if pygame.sprite.collide_rect(each.bullet, tank_player):
									if not tank_player.protected:
										tank_player.life -= 1
										if tank_player.life < 0:
											mytanksGroup.remove(tank_player)
											tanksGroup.remove(tank_player)
											if len(mytanksGroup) < 1:
												is_gameover = True
										else:
											tank_player.reset()
									each.bullet.being = False
									enemybulletsGroup.remove(each.bullet)
									break
							# 子彈碰撞石頭墻
							if pygame.sprite.spritecollide(each.bullet, map_stage.brickGroup, True, None):
								each.bullet.being = False
								enemybulletsGroup.remove(each.bullet)
							'''
							# 等價方案(更科學(xué)點)
							for one in map_stage.brickGroup:
								if pygame.sprite.collide_rect(each.bullet, one):
									each.bullet.being = False
									one.being = False
									enemybulletsGroup.remove(one)
									break
							'''
							# 子彈碰鋼墻
							if each.bullet.stronger:
								if pygame.sprite.spritecollide(each.bullet, map_stage.ironGroup, True, None):
									each.bullet.being = False
							else:
								if pygame.sprite.spritecollide(each.bullet, map_stage.ironGroup, False, None):
									each.bullet.being = False
							'''
							# 等價方案(更科學(xué)點)
							for one in map_stage.ironGroup:
								if pygame.sprite.collide_rect(each.bullet, one):
									each.bullet.being = False
									if each.bullet.stronger:
										one.being = False
										map_stage.ironGroup.remove(one)
									break
							'''
							# 子彈碰大本營
							if pygame.sprite.collide_rect(each.bullet, myhome):
								each.bullet.being = False
								myhome.set_dead()
								is_gameover = True
				else:
					enemytanksGroup.remove(each)
					tanksGroup.remove(each)
			# 家
			screen.blit(myhome.home, myhome.rect)
			# 食物
			for myfood in myfoodsGroup:
				if myfood.being and myfood.time > 0:
					screen.blit(myfood.food, myfood.rect)
					myfood.time -= 1
					for tank_player in mytanksGroup:
						if pygame.sprite.collide_rect(tank_player, myfood):
							# 消滅當(dāng)前所有敵人
							if myfood.kind == 0:
								enemytanksGroup = pygame.sprite.Group()
								enemytanks_total -= enemytanks_now
								enemytanks_now = 0
							# 敵人靜止
							if myfood.kind == 1:
								for each in enemytanksGroup:
									each.can_move = False
							# 子彈增強
							if myfood.kind == 2:
								tank_player.bullet.stronger = True
							# 使得大本營的墻變?yōu)殇摪?/span>
							if myfood.kind == 3:
								map_stage.protect_home()
							# 坦克獲得一段時間的保護罩
							if myfood.kind == 4:
								for tank_player in mytanksGroup:
									tank_player.protected = True
							# 坦克升級
							if myfood.kind == 5:
								tank_player.up_level()
							# 坦克生命+1
							if myfood.kind == 6:
								tank_player.life += 1
							myfood.being = False
							myfoodsGroup.remove(myfood)
							break
				else:
					myfood.being = False
					myfoodsGroup.remove(myfood)
			pygame.display.flip()
			clock.tick(60)
	if not is_gameover:
		show_end_interface(screen, 630, 630, True)
	else:
		show_end_interface(screen, 630, 630, False)

4.2 制作游戲開始和結(jié)束界面

# 開始界面顯示
def show_start_interface(screen, width, height):
	tfont = pygame.font.Font('./font/simkai.ttf', width//4)
	cfont = pygame.font.Font('./font/simkai.ttf', width//20)
	title = tfont.render(u'坦克大戰(zhàn)', True, (255, 0, 0))
	content1 = cfont.render(u'按1鍵進入單人游戲', True, (0, 0, 255))
	content2 = cfont.render(u'按2鍵進入雙人人游戲', True, (0, 0, 255))
	trect = title.get_rect()
	trect.midtop = (width/2, height/4)
	crect1 = content1.get_rect()
	crect1.midtop = (width/2, height/1.8)
	crect2 = content2.get_rect()
	crect2.midtop = (width/2, height/1.6)
	screen.blit(title, trect)
	screen.blit(content1, crect1)
	screen.blit(content2, crect2)
	pygame.display.update()
	while True:
		for event in pygame.event.get():
			if event.type == QUIT:
				sys.exit()
			elif event.type == pygame.KEYDOWN:
				if event.key == pygame.K_1:
					return 1
				if event.key == pygame.K_2:
					return 2
# 結(jié)束界面顯示
def show_end_interface(screen, width, height, is_win):
	bg_img = pygame.image.load("./圖片/others/background.png")
	screen.blit(bg_img, (0, 0))
	if is_win:
		font = pygame.font.Font('./font/simkai.ttf', width//10)
		content = font.render(u'恭喜通關(guān)!', True, (255, 0, 0))
		rect = content.get_rect()
		rect.midtop = (width/2, height/2)
		screen.blit(content, rect)
	else:
		fail_img = pygame.image.load("./圖片/others/gameover.png")
		rect = fail_img.get_rect()
		rect.midtop = (width/2, height/2)
		screen.blit(fail_img, rect)
	pygame.display.update()
	while True:
		for event in pygame.event.get():
			if event.type == QUIT:
				sys.exit()


# 關(guān)卡切換
def show_switch_stage(screen, width, height, stage):
	bg_img = pygame.image.load("./圖片/others/background.png")
	screen.blit(bg_img, (0, 0))
	font = pygame.font.Font('./font/simkai.ttf', width//10)
	content = font.render(u'第%d關(guān)' % stage, True, (0, 255, 0))
	rect = content.get_rect()
	rect.midtop = (width/2, height/2)
	screen.blit(content, rect)
	pygame.display.update()
	delay_event = pygame.constants.USEREVENT
	pygame.time.set_timer(delay_event, 1000)
	while True:
		for event in pygame.event.get():
			if event.type == QUIT:
				sys.exit()
			if event.type == delay_event:
				return


5 最后

到了這里,關(guān)于python小游戲畢設(shè) 坦克大戰(zhàn)游戲設(shè)計與實現(xiàn)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • 畢業(yè)設(shè)計 python坦克大戰(zhàn)小游戲

    畢業(yè)設(shè)計 python坦克大戰(zhàn)小游戲

    ?? Hi,各位同學(xué)好呀,這里是L學(xué)長! ??今天向大家分享一個今年(2022)最新完成的畢業(yè)設(shè)計項目作品 python小游戲畢設(shè) 坦克大戰(zhàn)小游戲設(shè)計與實現(xiàn) (源碼) ?? 學(xué)長根據(jù)實現(xiàn)的難度和等級對項目進行評分(最低0分,滿分5分) 難度系數(shù):3分 工作量:3分 創(chuàng)新點:4分 項目獲取:

    2024年02月21日
    瀏覽(28)
  • python小游戲畢設(shè) 飛機大戰(zhàn)設(shè)計與實現(xiàn)

    python小游戲畢設(shè) 飛機大戰(zhàn)設(shè)計與實現(xiàn)

    ?? Hi,各位同學(xué)好呀,這里是L學(xué)長! ??今天向大家分享一個今年(2022)最新完成的畢業(yè)設(shè)計項目作品 飛機大戰(zhàn)小游戲設(shè)計與實現(xiàn) ?? 學(xué)長根據(jù)實現(xiàn)的難度和等級對項目進行評分(最低0分,滿分5分) 難度系數(shù):3分 工作量:3分 創(chuàng)新點:3分 利用Python制作的一個簡易版類\\\"飛機大

    2024年02月10日
    瀏覽(30)
  • python項目分享 - python坦克大戰(zhàn)小游戲

    python項目分享 - python坦克大戰(zhàn)小游戲

    ?? Hi,各位同學(xué)好呀,這里是L學(xué)長! ??今天向大家分享一個今年(2022)最新完成的畢業(yè)設(shè)計項目作品 python小游戲畢設(shè) 坦克大戰(zhàn)小游戲設(shè)計與實現(xiàn) (源碼) ?? 學(xué)長根據(jù)實現(xiàn)的難度和等級對項目進行評分(最低0分,滿分5分) 難度系數(shù):3分 工作量:3分 創(chuàng)新點:4分 項目獲取:

    2024年02月03日
    瀏覽(26)
  • python小游戲畢設(shè) 掃雷小游戲設(shè)計與實現(xiàn)

    python小游戲畢設(shè) 掃雷小游戲設(shè)計與實現(xiàn)

    ?? Hi,各位同學(xué)好呀,這里是L學(xué)長! ??今天向大家分享一個今年(2022)最新完成的畢業(yè)設(shè)計項目作品 python小游戲畢設(shè) 掃雷小游戲設(shè)計與實現(xiàn) (源碼) ?? 學(xué)長根據(jù)實現(xiàn)的難度和等級對項目進行評分(最低0分,滿分5分) 難度系數(shù):3分 工作量:3分 創(chuàng)新點:4分 《掃雷》是一款大

    2024年02月04日
    瀏覽(92)
  • python小游戲畢設(shè) 2048小游戲設(shè)計與實現(xiàn) (源碼)

    python小游戲畢設(shè) 2048小游戲設(shè)計與實現(xiàn) (源碼)

    ?? Hi,各位同學(xué)好呀,這里是L學(xué)長! ??今天向大家分享一個今年(2022)最新完成的畢業(yè)設(shè)計項目作品 python小游戲畢設(shè) 2048小游戲設(shè)計與實現(xiàn) (源碼) ?? 學(xué)長根據(jù)實現(xiàn)的難度和等級對項目進行評分(最低0分,滿分5分) 難度系數(shù):3分 工作量:3分 創(chuàng)新點:4分 項目獲?。?https://

    2024年02月12日
    瀏覽(29)
  • python小游戲畢設(shè) 掃雷小游戲設(shè)計與實現(xiàn) (源碼)

    python小游戲畢設(shè) 掃雷小游戲設(shè)計與實現(xiàn) (源碼)

    ?? Hi,各位同學(xué)好呀,這里是L學(xué)長! ??今天向大家分享一個今年(2022)最新完成的畢業(yè)設(shè)計項目作品 python小游戲畢設(shè) 掃雷小游戲設(shè)計與實現(xiàn) (源碼) ?? 學(xué)長根據(jù)實現(xiàn)的難度和等級對項目進行評分(最低0分,滿分5分) 難度系數(shù):3分 工作量:3分 創(chuàng)新點:4分 項目獲?。?https:

    2024年02月06日
    瀏覽(34)
  • 【python小游戲畢設(shè)】吃豆人小游戲設(shè)計與實現(xiàn)

    【python小游戲畢設(shè)】吃豆人小游戲設(shè)計與實現(xiàn)

    ?? 這兩年開始畢業(yè)設(shè)計和畢業(yè)答辯的要求和難度不斷提升,傳統(tǒng)的畢設(shè)題目缺少創(chuàng)新和亮點,往往達(dá)不到畢業(yè)答辯的要求,這兩年不斷有學(xué)弟學(xué)妹告訴學(xué)長自己做的項目系統(tǒng)達(dá)不到老師的要求。 為了大家能夠順利以及最少的精力通過畢設(shè),學(xué)長分享優(yōu)質(zhì)畢業(yè)設(shè)計項目,今天

    2024年02月15日
    瀏覽(25)
  • python小游戲畢設(shè) 消消樂小游戲設(shè)計與實現(xiàn) (源碼)

    python小游戲畢設(shè) 消消樂小游戲設(shè)計與實現(xiàn) (源碼)

    ?? Hi,各位同學(xué)好呀,這里是L學(xué)長! ??今天向大家分享一個今年(2022)最新完成的畢業(yè)設(shè)計項目作品 python小游戲畢設(shè) 消消樂小游戲設(shè)計與實現(xiàn) (源碼) ?? 學(xué)長根據(jù)實現(xiàn)的難度和等級對項目進行評分(最低0分,滿分5分) 難度系數(shù):3分 工作量:3分 創(chuàng)新點:4分 項目獲?。?htt

    2024年02月09日
    瀏覽(26)
  • python小游戲畢設(shè) 飛揚的小鳥小游戲設(shè)計與實現(xiàn) (源碼)

    python小游戲畢設(shè) 飛揚的小鳥小游戲設(shè)計與實現(xiàn) (源碼)

    ?? Hi,各位同學(xué)好呀,這里是L學(xué)長! ??今天向大家分享一個今年(2022)最新完成的畢業(yè)設(shè)計項目作品 python小游戲畢設(shè) 飛揚的小鳥小游戲設(shè)計與實現(xiàn) (源碼) ?? 學(xué)長根據(jù)實現(xiàn)的難度和等級對項目進行評分(最低0分,滿分5分) 難度系數(shù):3分 工作量:3分 創(chuàng)新點:4分 項目獲取:

    2024年02月08日
    瀏覽(26)
  • python小游戲畢設(shè) 吃豆人小游戲設(shè)計與實現(xiàn) (源碼)

    python小游戲畢設(shè) 吃豆人小游戲設(shè)計與實現(xiàn) (源碼)

    ?? Hi,各位同學(xué)好呀,這里是L學(xué)長! ??今天向大家分享一個今年(2022)最新完成的畢業(yè)設(shè)計項目作品 python小游戲畢設(shè) 吃豆人小游戲設(shè)計與實現(xiàn) (源碼) ?? 學(xué)長根據(jù)實現(xiàn)的難度和等級對項目進行評分(最低0分,滿分5分) 難度系數(shù):3分 工作量:3分 創(chuàng)新點:4分 項目獲取: htt

    2024年02月10日
    瀏覽(33)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包