In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "python uses pygame to realize the code sharing of tank war games". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "python uses pygame to achieve tank war game code sharing"!
Import pygameimport sysimport timefrom pygame.locals import * from random import randintMOVE_SLEEP = 0.01class MyTank: width = 500speed = 10 screen = 0 myshells = [] enemylist = [] enemyshells = [] grade = 0 life = 3 cnt = 0 def startgame (self): pygame.init () self.screen = pygame.display.set_mode ((self.width,self.heights), 0Lab 32) pygame.display.set_caption ("bit tank") self.tank = Tank (self.screen) 275450) for i in range (6): self.enemylist.append (EnmeyTank (self.screen)) while True: key = pygame.key.get_pressed () self.screen.fill ((0mem0) 0) if key [K _ LEFT]: self.tank.move ('L') elif key [K _ RIGHT]: self.tank.move ('R') elif key [K _ UP]: self.tank.move ('U') elif key [K _ DOWN]: self.tank.move ('D') self.get_event () for shell in self.myshells: if shell.move () = True: self.myshells.remove (shell) shell .display () a = shell.hitTank () # bullet collision if a = = True: if self.life > 0: self.myshells.remove (shell) self.grade + = 1 # mytank collision if self.tank.live = = True: if self.tank.hitTank (): self.life-= 1 if self.life
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.