score_font.render("score : %s" % str(score), true, white)
render函式把字元字串轉換為su***ce物件
true拒絕鋸齒
paused_rect.collidepoint(event.pos)
在paused_rect矩形類裡有collidepoint(event.pos)
檢測滑鼠是否在矩形裡,是則返回true,否則返回false
elif event.type == mousemotion:
if paused_rect.collidepoint(event.pos):
if paused:
paused_image = resume_pressed_image
else:
paused_image = pause_pressed_image
else:
if paused:
paused_image = resume_nor_image
else:
paused_image = pause_nor_image
第乙個if是檢測滑鼠是否在圖示上
第二個if如果是暫停的狀態,圖示變成另乙個(就是顏色加深,提醒使用者此圖示是可用的)
如果不是則表現為開始的另乙個圖示(顏色加深,提醒次圖示使用者可用)
若滑鼠不在圖示上,顏色恢復
elif event.type == keydown:
if event.key == k_space:
if bomb_num:
bomb_num -= 1
bomb_sound.play()
for each in enemies:
if each.rect.bottom > 0:
each.active = false
清屏,空格鍵釋放,起始為3個
pygame飛機大戰3
self.destroy images.extend pygame.image.load images enemy1 down1.png convert alpha pygame.image.load images enemy1 down2.png convert alpha pygame.imag...
pygame飛機大戰4
pygame.mask.from su ce self,image 對的非透明部分做標記 pygame.sprite.spritecollide b,enemies,false,pygame.sprite.collide mask 完美檢測碰撞 me.rect.midtop,子彈生成在飛機的中間的頂...
pygame飛機大戰7
if me destroy index 0 life num 1 me.reset pygame.time.set timer invincible time,3 1000 if enemies down and not me.invincible me.active false for e in ...