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

20個經(jīng)典面試問題Python面向?qū)ο髮崙?zhàn)--飛機大戰(zhàn)(1),Python中高級面試必知必會

這篇具有很好參考價值的文章主要介紹了20個經(jīng)典面試問題Python面向?qū)ο髮崙?zhàn)--飛機大戰(zhàn)(1),Python中高級面試必知必會。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

each.reset()

繪制中型敵機

for each in mid_enemies:

if each.active:

each.move()

if each.hit:

screen.blit(each.image_hit, each.rect)

each.hit = False

else:

screen.blit(each.image1, each.rect)

繪制血槽

pygame.draw.line(screen, BLACK,

(each.rect.left, each.rect.top - 5),

(each.rect.right, each.rect.top - 5),

energy_remain = each.energy / enemy.MidEnemy.energy

if energy_remain > 0.2:

energy_color = GREEN

else:

energy_color = RED

pygame.draw.line(screen, energy_color,

(each.rect.left, each.rect.top - 5),

(each.rect.left + each.rect.width * energy_remain,

each.rect.top - 5),

else:

if not (delay % 3):

if e2_destroy_index == 0:

enemy2_down_sound.play()

screen.blit(each.destroy_images[e2_destroy_index], each.rect)

e2_destroy_index = (e2_destroy_index + 1) % 4

if e2_destroy_index == 0:

score += 5000

each.reset()

繪制小型敵機

for each in small_enemies:

if each.active:

each.move()

screen.blit(each.image1, each.rect)

else:

if not (delay % 3):

if e1_destroy_index == 0:

enemy1_down_sound.play()

screen.blit(each.destroy_images[e1_destroy_index], each.rect)

e1_destroy_index = (e1_destroy_index + 1) % 4

if e1_destroy_index == 0:

score += 1000

each.reset()

key_pressed = pygame.key.get_pressed()

if key_pressed[K_w] or key_pressed[K_UP]:

me.moveUp()

if key_pressed[K_s] or key_pressed[K_DOWN]:

me.moveDown()

if key_pressed[K_a] or key_pressed[K_LEFT]:

me.moveLeft()

if key_pressed[K_d] or key_pressed[K_RIGHT]:

me.moveRight()

檢測我方飛機是否被撞

enemies_down = pygame.sprite.spritecollide(me, enemies, False, pygame.sprite.collide_mask)

if enemies_down and not me.invincible:

me.active = False

for e in enemies_down:

e.active = False

繪制我方飛機

if me.active:

if switch_image:

screen.blit(me.image1, me.rect)

else:

screen.blit(me.image2, me.rect)

else:

me_down_sound.play()

if not (delay % 3):

screen.blit(each.destroy_images[me_destroy_index], each.rect)

me_destroy_index = (me_destroy_index + 1) % 4

剩余生命數(shù)量

if me_destroy_index == 0:

life_num -= 1

me.reset()

pygame.time.set_timer(INVINCEBLE_TIME, 3 * 1000)

繪制剩余炸彈數(shù)量

bomb_text = bomb_font.render(“x %d” % bomb_num, True, WHITE)

text_rect = bomb_text.get_rect()

screen.blit(bomb_image, (10, height - 10 - bomb_rect.height))

screen.blit(bomb_text, (20 + bomb_rect.width, height - 5 - text_rect.height))

if life_num:

for i in range(life_num):

screen.blit(life_image,

(width - 10 - (i + 1) * life_rect.width,

height - 10 - life_rect.height))

score_text = score_font.render(str(“Score: %s” % score), True, WHITE)

screen.blit(score_text, (10, 5))

elif life_num == 0:

pygame.mixer.music.stop()

pygame.mixer.stop()

停止發(fā)放補給

pygame.time.set_timer(SUPPLY_TIME, 0)

if not recorded:

recorded = True

讀取歷史最高分

with open(“plane/record/record.txt”, “r”) as f:

record_score = int(f.read())

if score > record_score:

with open(“plane/record/record.txt”, “w”) as f:

f.write(str(score))

繪制結(jié)束畫面

record_score_text = score_font.render(“Best: %d” % record_score, True, WHITE)

screen.blit(record_score_text, (50, 50))

gameover_text1 = gameover_font.render("Your Score: ", True, WHITE)

gameover_text1_rect = gameover_text1.get_rect()

gameover_text1_rect.left, gameover_text1_rect.top = \

(width - gameover_text1_rect.width) // 2, height // 2

screen.blit(gameover_text1, gameover_text1_rect)

gameover_text2 = gameover_font.render(str(score), True, WHITE)

gameover_text2_rect = gameover_text2.get_rect()

gameover_text2_rect.left, gameover_text2_rect.top = \

(width - gameover_text2_rect.width) // 2, \

gameover_text1_rect.bottom + 10

screen.blit(gameover_text2, gameover_text2_rect)

again_rect.left, again_rect.top = \

(width - again_rect.width) // 2, \

gameover_text2_rect.bottom + 50

screen.blit(again_image, again_rect)

gameover_rect.left, gameover_rect.top = \

(width - again_rect.width) // 2, \

again_rect.bottom + 10

screen.blit(gameover_image, gameover_rect)

檢測用戶的鼠標(biāo)操作

如果用戶按下鼠標(biāo)左鍵

if pygame.mouse.get_pressed()[0]:

pos = pygame.mouse.get_pos()

if again_rect.left < pos[0] < again_rect.right and \

again_rect.top < pos[1] < again_rect.bottom:

main()

elif gameover_rect.left < pos[0] < gameover_rect.right and \

gameover_rect.top < pos[1] < gameover_rect.bottom:

pygame.quit()

sys.exit()

screen.blit(paused_image, paused_rect)

切換圖片

if not (delay % 5):

switch_image = not switch_image

delay -= 1

if not delay:

delay = 100

pygame.display.flip()

clock.tick(60)

if name == “main”:

try:

main()

except SystemExit:

pass

except:

traceback.print_exc()

pygame.quit()

input()

20個經(jīng)典面試問題Python面向?qū)ο髮崙?zhàn)--飛機大戰(zhàn)(1),Python中高級面試必知必會,2024年程序員學(xué)習(xí),python,面試,pygame

4、子彈模塊


import pygame

class Bullet1(pygame.sprite.Sprite): # 定義一個子彈類Bullet1繼承pygame模塊的sprite,Sprite類

def init(self, position): # 定義構(gòu)造函數(shù),并繼承sprite.Sprite類中的構(gòu)造函數(shù)

pygame.sprite.Sprite.init(self)

定義自己的屬型

self.image = pygame.image.load(“plane/images/bullet1.png”).convert_alpha()

self.rect = self.image.get_rect()

self.rect.left, self.rect.top = position

self.speed = 12

self.active = True

self.mask = pygame.mask.from_surface(self.image)

定義子彈的移動

def move(self):

self.rect.top -= self.speed

if self.rect.top < 0:

self.active = False

def reset(self, position):

self.rect.left, self.rect.top = position

self.active = True

定義第二個子彈類,并繼承pygame.sprite.Sprite類

class Bullet2(pygame.sprite.Sprite):

def init(self, position): # 定義構(gòu)造函數(shù)

pygame.sprite.Sprite.init(self) # 并繼承sprite.Sprite類中的構(gòu)造函數(shù)

實例化第二個子彈屬型

self.image = pygame.image.load(“plane/images/bullet2.png”).convert_alpha()

self.rect = self.image.get_rect()

self.rect.left, self.rect.top = position

self.speed = 14

self.active = True

self.mask = pygame.mask.from_surface(self.image)

#同上

def move(self):

self.rect.top -= self.speed

if self.rect.top < 0:

self.active = False

#同上

def reset(self, position):

self.rect.left, self.rect.top = position

self.active = True

20個經(jīng)典面試問題Python面向?qū)ο髮崙?zhàn)--飛機大戰(zhàn)(1),Python中高級面試必知必會,2024年程序員學(xué)習(xí),python,面試,pygame

5、敵機模塊


import pygame

from random import * # 導(dǎo)入random庫中所有模塊

定義SmallEnemy也就是小敵機類,并繼承pygame.sprite.Sprite類

class SmallEnemy(pygame.sprite.Sprite):

def init(self, bg_size): # 定義構(gòu)造函數(shù),傳入bg_size參數(shù)

pygame.sprite.Sprite.init(self) #繼承pygame.sprite.Sprite的構(gòu)造函數(shù)

實例化屬型,也就是賦值

self.image1 = pygame.image.load(“plane/images/enemy1.png”).convert_alpha()

self.destroy_images = []

敵機爆炸后的圖片

self.destroy_images.extend([

pygame.image.load(“plane/images/enemy1_down1.png”).convert_alpha(),

pygame.image.load(“plane/images/enemy1_down2.png”).convert_alpha(),

pygame.image.load(“plane/images/enemy1_down3.png”).convert_alpha(),

pygame.image.load(“plane/images/enemy1_down4.png”).convert_alpha(),

])

self.rect = self.image1.get_rect()

self.width, self.height = bg_size[0], bg_size[1]

self.speed = 2

self.active = True

self.rect.left, self.rect.top = \

randint(0, self.width - self.rect.width), \

randint(-5 * self.height, 0)

self.mask = pygame.mask.from_surface(self.image1)

def move(self):

if self.rect.top < self.height:

self.rect.top += self.speed

else:

self.reset()

def reset(self):

self.active = True

self.rect.left, self.rect.top = \

randint(0, self.width - self.rect.width), \

randint(-5 * self.height, 0)

同上

class MidEnemy(pygame.sprite.Sprite):

energy = 8

def init(self, bg_size):

pygame.sprite.Sprite.init(self)

self.image1 = pygame.image.load(“plane/images/enemy2.png”).convert_alpha()

self.image_hit = pygame.image.load(“plane/images/enemy2_hit.png”).convert_alpha()

self.destroy_images = []

self.destroy_images.extend([

pygame.image.load(“plane/images/enemy2_down1.png”).convert_alpha(),

pygame.image.load(“plane/images/enemy2_down2.png”).convert_alpha(),

pygame.image.load(“plane/images/enemy2_down3.png”).convert_alpha(),

pygame.image.load(“plane/images/enemy2_down4.png”).convert_alpha(),

])

self.rect = self.image1.get_rect()

self.width, self.height = bg_size[0], bg_size[1]

self.speed = 1

self.active = True

self.hit = False

self.energy = MidEnemy.energy

self.rect.left, self.rect.top = \

randint(0, self.width - self.rect.width), \

randint(-5 * self.height, -self.height)

self.mask = pygame.mask.from_surface(self.image1)

def move(self):

if self.rect.top < self.height:

self.rect.top += self.speed

else:

self.reset()

def reset(self):

self.active = True

self.energy = MidEnemy.energy

self.rect.left, self.rect.top = \

randint(0, self.width - self.rect.width), \

randint(-8 * self.height, -self.height)

同上

class BigEnemy(pygame.sprite.Sprite):

energy = 20

def init(self, bg_size):

pygame.sprite.Sprite.init(self)

self.image1 = pygame.image.load(“plane/images/enemy3_n1.png”).convert_alpha()

self.image2 = pygame.image.load(“plane/images/enemy3_n2.png”).convert_alpha()

self.image_hit = pygame.image.load(“plane/images/enemy3_hit.png”).convert_alpha()

self.destroy_images = []

self.destroy_images.extend([

pygame.image.load(“plane/images/enemy3_down1.png”).convert_alpha(),

pygame.image.load(“plane/images/enemy3_down2.png”).convert_alpha(),

pygame.image.load(“plane/images/enemy3_down3.png”).convert_alpha(),

pygame.image.load(“plane/images/enemy3_down4.png”).convert_alpha(),

pygame.image.load(“plane/images/enemy3_down5.png”).convert_alpha(),

pygame.image.load(“plane/images/enemy3_down6.png”).convert_alpha(),

])

self.rect = self.image1.get_rect()

self.width, self.height = bg_size[0], bg_size[1]

self.speed = 1

self.active = True

self.hit = False

self.energy = BigEnemy.energy

self.rect.left, self.rect.top = \

randint(0, self.width - self.rect.width), \

randint(-10 * self.height, -5 * self.height)

self.mask = pygame.mask.from_surface(self.image1)

def move(self):

if self.rect.top < self.height:

self.rect.top += self.speed

else:

self.reset()

自我介紹一下,小編13年上海交大畢業(yè),曾經(jīng)在小公司待過,也去過華為、OPPO等大廠,18年進入阿里一直到現(xiàn)在。

深知大多數(shù)Python工程師,想要提升技能,往往是自己摸索成長或者是報班學(xué)習(xí),但對于培訓(xùn)機構(gòu)動則幾千的學(xué)費,著實壓力不小。自己不成體系的自學(xué)效果低效又漫長,而且極易碰到天花板技術(shù)停滯不前!

因此收集整理了一份《2024年P(guān)ython開發(fā)全套學(xué)習(xí)資料》,初衷也很簡單,就是希望能夠幫助到想自學(xué)提升又不知道該從何學(xué)起的朋友,同時減輕大家的負擔(dān)。
20個經(jīng)典面試問題Python面向?qū)ο髮崙?zhàn)--飛機大戰(zhàn)(1),Python中高級面試必知必會,2024年程序員學(xué)習(xí),python,面試,pygame
20個經(jīng)典面試問題Python面向?qū)ο髮崙?zhàn)--飛機大戰(zhàn)(1),Python中高級面試必知必會,2024年程序員學(xué)習(xí),python,面試,pygame
20個經(jīng)典面試問題Python面向?qū)ο髮崙?zhàn)--飛機大戰(zhàn)(1),Python中高級面試必知必會,2024年程序員學(xué)習(xí),python,面試,pygame
20個經(jīng)典面試問題Python面向?qū)ο髮崙?zhàn)--飛機大戰(zhàn)(1),Python中高級面試必知必會,2024年程序員學(xué)習(xí),python,面試,pygame
20個經(jīng)典面試問題Python面向?qū)ο髮崙?zhàn)--飛機大戰(zhàn)(1),Python中高級面試必知必會,2024年程序員學(xué)習(xí),python,面試,pygame
20個經(jīng)典面試問題Python面向?qū)ο髮崙?zhàn)--飛機大戰(zhàn)(1),Python中高級面試必知必會,2024年程序員學(xué)習(xí),python,面試,pygame

既有適合小白學(xué)習(xí)的零基礎(chǔ)資料,也有適合3年以上經(jīng)驗的小伙伴深入學(xué)習(xí)提升的進階課程,基本涵蓋了95%以上Python開發(fā)知識點,真正體系化!

由于文件比較大,這里只是將部分目錄大綱截圖出來,每個節(jié)點里面都包含大廠面經(jīng)、學(xué)習(xí)筆記、源碼講義、實戰(zhàn)項目、講解視頻,并且后續(xù)會持續(xù)更新

如果你覺得這些內(nèi)容對你有幫助,可以添加V獲取:vip1024c (備注Python)
20個經(jīng)典面試問題Python面向?qū)ο髮崙?zhàn)--飛機大戰(zhàn)(1),Python中高級面試必知必會,2024年程序員學(xué)習(xí),python,面試,pygame

如果你也是看準(zhǔn)了Python,想自學(xué)Python,在這里為大家準(zhǔn)備了豐厚的免費學(xué)習(xí)大禮包,帶大家一起學(xué)習(xí),給大家剖析Python兼職、就業(yè)行情前景的這些事兒。

一、Python所有方向的學(xué)習(xí)路線

Python所有方向路線就是把Python常用的技術(shù)點做整理,形成各個領(lǐng)域的知識點匯總,它的用處就在于,你可以按照上面的知識點去找對應(yīng)的學(xué)習(xí)資源,保證自己學(xué)得較為全面。

20個經(jīng)典面試問題Python面向?qū)ο髮崙?zhàn)--飛機大戰(zhàn)(1),Python中高級面試必知必會,2024年程序員學(xué)習(xí),python,面試,pygame

二、學(xué)習(xí)軟件

工欲善其必先利其器。學(xué)習(xí)Python常用的開發(fā)軟件都在這里了,給大家節(jié)省了很多時間。

20個經(jīng)典面試問題Python面向?qū)ο髮崙?zhàn)--飛機大戰(zhàn)(1),Python中高級面試必知必會,2024年程序員學(xué)習(xí),python,面試,pygame

三、全套PDF電子書

書籍的好處就在于權(quán)威和體系健全,剛開始學(xué)習(xí)的時候你可以只看視頻或者聽某個人講課,但等你學(xué)完之后,你覺得你掌握了,這時候建議還是得去看一下書籍,看權(quán)威技術(shù)書籍也是每個程序員必經(jīng)之路。

20個經(jīng)典面試問題Python面向?qū)ο髮崙?zhàn)--飛機大戰(zhàn)(1),Python中高級面試必知必會,2024年程序員學(xué)習(xí),python,面試,pygame

四、入門學(xué)習(xí)視頻

我們在看視頻學(xué)習(xí)的時候,不能光動眼動腦不動手,比較科學(xué)的學(xué)習(xí)方法是在理解之后運用它們,這時候練手項目就很適合了。

20個經(jīng)典面試問題Python面向?qū)ο髮崙?zhàn)--飛機大戰(zhàn)(1),Python中高級面試必知必會,2024年程序員學(xué)習(xí),python,面試,pygame

20個經(jīng)典面試問題Python面向?qū)ο髮崙?zhàn)--飛機大戰(zhàn)(1),Python中高級面試必知必會,2024年程序員學(xué)習(xí),python,面試,pygame

四、實戰(zhàn)案例

光學(xué)理論是沒用的,要學(xué)會跟著一起敲,要動手實操,才能將自己的所學(xué)運用到實際當(dāng)中去,這時候可以搞點實戰(zhàn)案例來學(xué)習(xí)。

20個經(jīng)典面試問題Python面向?qū)ο髮崙?zhàn)--飛機大戰(zhàn)(1),Python中高級面試必知必會,2024年程序員學(xué)習(xí),python,面試,pygame

五、面試資料

我們學(xué)習(xí)Python必然是為了找到高薪的工作,下面這些面試題是來自阿里、騰訊、字節(jié)等一線互聯(lián)網(wǎng)大廠最新的面試資料,并且有阿里大佬給出了權(quán)威的解答,刷完這一套面試資料相信大家都能找到滿意的工作。

20個經(jīng)典面試問題Python面向?qū)ο髮崙?zhàn)--飛機大戰(zhàn)(1),Python中高級面試必知必會,2024年程序員學(xué)習(xí),python,面試,pygame

成為一個Python程序員專家或許需要花費數(shù)年時間,但是打下堅實的基礎(chǔ)只要幾周就可以,如果你按照我提供的學(xué)習(xí)路線以及資料有意識地去實踐,你就有很大可能成功!
最后祝你好運!?。?/p>

一個人可以走的很快,但一群人才能走的更遠。如果你從事以下工作或?qū)σ韵赂信d趣,歡迎戳這里加入程序員的圈子,讓我們一起學(xué)習(xí)成長!

AI人工智能、Android移動開發(fā)、AIGC大模型、C C#、Go語言、Java、Linux運維、云計算、MySQL、PMP、網(wǎng)絡(luò)安全、Python爬蟲、UE5、UI設(shè)計、Unity3D、Web前端開發(fā)、產(chǎn)品經(jīng)理、車載開發(fā)、大數(shù)據(jù)、鴻蒙、計算機網(wǎng)絡(luò)、嵌入式物聯(lián)網(wǎng)、軟件測試、數(shù)據(jù)結(jié)構(gòu)與算法、音視頻開發(fā)、Flutter、IOS開發(fā)、PHP開發(fā)、.NET、安卓逆向、云計算文章來源地址http://www.zghlxwxcb.cn/news/detail-852478.html

d0a6a2.png)

四、實戰(zhàn)案例

光學(xué)理論是沒用的,要學(xué)會跟著一起敲,要動手實操,才能將自己的所學(xué)運用到實際當(dāng)中去,這時候可以搞點實戰(zhàn)案例來學(xué)習(xí)。

20個經(jīng)典面試問題Python面向?qū)ο髮崙?zhàn)--飛機大戰(zhàn)(1),Python中高級面試必知必會,2024年程序員學(xué)習(xí),python,面試,pygame

五、面試資料

我們學(xué)習(xí)Python必然是為了找到高薪的工作,下面這些面試題是來自阿里、騰訊、字節(jié)等一線互聯(lián)網(wǎng)大廠最新的面試資料,并且有阿里大佬給出了權(quán)威的解答,刷完這一套面試資料相信大家都能找到滿意的工作。

20個經(jīng)典面試問題Python面向?qū)ο髮崙?zhàn)--飛機大戰(zhàn)(1),Python中高級面試必知必會,2024年程序員學(xué)習(xí),python,面試,pygame

成為一個Python程序員專家或許需要花費數(shù)年時間,但是打下堅實的基礎(chǔ)只要幾周就可以,如果你按照我提供的學(xué)習(xí)路線以及資料有意識地去實踐,你就有很大可能成功!
最后祝你好運?。?!

一個人可以走的很快,但一群人才能走的更遠。如果你從事以下工作或?qū)σ韵赂信d趣,歡迎戳這里加入程序員的圈子,讓我們一起學(xué)習(xí)成長!

AI人工智能、Android移動開發(fā)、AIGC大模型、C C#、Go語言、Java、Linux運維、云計算、MySQL、PMP、網(wǎng)絡(luò)安全、Python爬蟲、UE5、UI設(shè)計、Unity3D、Web前端開發(fā)、產(chǎn)品經(jīng)理、車載開發(fā)、大數(shù)據(jù)、鴻蒙、計算機網(wǎng)絡(luò)、嵌入式物聯(lián)網(wǎng)、軟件測試、數(shù)據(jù)結(jié)構(gòu)與算法、音視頻開發(fā)、Flutter、IOS開發(fā)、PHP開發(fā)、.NET、安卓逆向、云計算

到了這里,關(guān)于20個經(jīng)典面試問題Python面向?qū)ο髮崙?zhàn)--飛機大戰(zhàn)(1),Python中高級面試必知必會的文章就介紹完了。如果您還想了解更多內(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)文章

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

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

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

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

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包