本文整理汇总了Python中Ship.move方法的典型用法代码示例。如果您正苦于以下问题:Python Ship.move方法的具体用法?Python Ship.move怎么用?Python Ship.move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ship
的用法示例。
在下文中一共展示了Ship.move方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import Ship [as 别名]
# 或者: from Ship import move [as 别名]
class Main:
def __init__(self, width=Settings.SCREEN_WIDTH,height=Settings.SCREEN_HEIGHT):
pygame.init()
self.width = width
self.height = height
self.screen = pygame.display.set_mode((self.width, self.height))
self.shooting = False
self.shoot_ticker = 0 #Can shoot without waiting
self.MAX_SHOOT_TICKER = 30 #One shot every x frames
self.spawn_ticker = 1800 #Start spawning 1800 frames in.
self.MAX_SPAWN_TICKER = 1800 #Max one new enemy every 1800 frames
self.GAME_OVER = False
self.END_GAME = False
self.END_CREDITS = False
self.RESPAWNING = False
self.respawn_ticker = 0
self.SCORE = 0##################
self.HIGHSCORES = []
self.checkHighscore()
self.wave1_pass = False
self.wave2_pass = False
self.wave3_pass = False
self.boss_spawned = False
self.enemies_killed = 0 #Number of enemy01 killed
self.music = Music("MainLoop")
self.clock = pygame.time.Clock()
self.LIVES = 3#############
def getScores(self):
scores = {}
count = 0
for line in self.HIGHSCORES:
data = line.split("-")
name = str(data[0].strip())
data[1] = data[1].strip().strip('\0')
score = int(data[1])
scores[Settings.SCORE_FORMAT.format(line, count)] = score
count += 1
return scores
def getRank(self, key, value, scores):
rank = 0
for key2, value2 in scores.iteritems():
if key != key2:
if value < value2:
rank += 1
return rank
def getEntries(self, scores):
entries = []
ranks = []
#KNOWN BUG##
"""
If there are more than two scores that are next to eachother
the bump algorithm will move the new value to the next one, but that will also be taken
A fix to this is to loop through again to make sure the newly bumped value doesn't already
exist, but then you would need n loops, where n is the number of numbers close to eachother
To replicate, create a large array of self.HIGHSCORES using random numbers, and it's bound to happen at least once
"""
for key, value in scores.iteritems():
new_rank = self.getRank(key, value, scores)
#print key,value,new_rank#####################
bump = False
#Doot doot gross code here
for rank in ranks:
if new_rank == rank:#Find index for bumpin
bump = True
if bump == True:
new_rank += 1
############
ranks.append(new_rank)
count2 = 0
for key, value in scores.iteritems():
entries.append([str(key.split("-")[0].strip()), value, ranks[count2]]) #["nobody", 0, 3] name,score,rank
count2 += 1
return entries
def sortEntries(self, entries):
new_entries = []
#print entries########################
for i in range(len(entries)):
new_entries.append(i)
for entry in entries:
####3print entry[0],entry[1],entry[2]
new_entries[entry[2]] = Settings.SCORE_FORMAT.format(entry[0], entry[1])
return new_entries
def setHighscore(self, name):
eightcrypt = EightCrypt()
new_entry = Settings.SCORE_FORMAT.format(name, self.SCORE)
self.HIGHSCORES = self.sortEntries(self.getEntries(self.getScores()))
self.HIGHSCORES.append(new_entry)
#.........这里部分代码省略.........