本文整理汇总了Python中score.Score.update方法的典型用法代码示例。如果您正苦于以下问题:Python Score.update方法的具体用法?Python Score.update怎么用?Python Score.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类score.Score
的用法示例。
在下文中一共展示了Score.update方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_evaluation
# 需要导入模块: from score import Score [as 别名]
# 或者: from score.Score import update [as 别名]
def create_evaluation(self, reading_system):
"Create and return a new evaluation, along with an initialized set of result objects."
from test import Test
from score import Score
from result import Result
from category import Category
from testsuite import TestSuite
testsuite = TestSuite.objects.get_most_recent_testsuite()
print "Creating evaluation for testsuite {0}".format(testsuite.version_date)
tests = Test.objects.filter(testsuite = testsuite)
evaluation = self.create(
testsuite = testsuite,
last_updated = generate_timestamp(),
percent_complete = 0.00,
reading_system = reading_system
)
evaluation.save()
total_score = Score(category = None, evaluation = evaluation)
total_score.save()
# create results for this evaluation
for t in tests:
result = Result(test = t, evaluation = evaluation, result = RESULT_NOT_ANSWERED)
result.save()
# update the score once results have been created
total_score.update(evaluation.get_all_results())
# create category score entries for this evaluation
categories = Category.objects.filter(testsuite = evaluation.testsuite)
for cat in categories:
score = Score(
category = cat,
evaluation = evaluation
)
score.update(evaluation.get_category_results(cat))
score.save()
return evaluation
示例2: main
# 需要导入模块: from score import Score [as 别名]
# 或者: from score.Score import update [as 别名]
def main():
open_canvas()
global background, score, timer, burger, character_list
global running
global current_time, frame_time
background = Background()
score = Score()
timer = Timer()
character_list = [Character() for i in range(nCharacter)]
burger.draw()
running = True
current_time = get_time()
while running:
frame_time = get_frame_time()
handle_events()
for character in character_list:
character.update(frame_time)
clear_canvas()
background.draw()
score.draw()
score.update(value)
timer.draw()
timer.update(time_value)
for character in character_list:
character.draw()
character.draw_bb()
burger.draw()
update_canvas()
close_canvas()
示例3: main
# 需要导入模块: from score import Score [as 别名]
# 或者: from score.Score import update [as 别名]
def main(self):
self.music.play()
# Screen base
self.screen.fill((0,0,0))
self.screen.blit(self.img_background,self.img_background_rect)
highscores = Highscores()
# Main instances
pavement = Pavement(self.unit)
snake = Snake(self.unit)
foods = Foods(self.unit)
walls = Walls(self.unit)
score = Score(self.unit,self.surface_rect)
nextgold = random.randint(*Constants.TIMERANGE_GOLD) * Constants.FPS # first gold between 30 & 60 seconds
makegold = False
nextwall = random.randint(*Constants.TIMERANGE_WALL) * Constants.FPS # first gold between 30 & 60 seconds
makewall = False
updatestats = True
counter = 0
flag_music = True
flag_pause = False
#MAIN LOOP
while self.running:
time = pygame.time.get_ticks()
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.running = False
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
self.running = False
elif event.key == pygame.K_m:
flag_music = not flag_music
if flag_music:
self.music.play()
else:
self.music.stop()
elif event.key == pygame.K_1:
pygame.image.save(self.screen, "screenshot.jpg")
elif event.key == pygame.K_SPACE or event.key == pygame.K_p:
flag_pause = True
self.print_text("PAUSE")
while flag_pause:
for event in pygame.event.get():
if event.type==pygame.KEYDOWN:
if event.key==pygame.K_p or event.key == pygame.K_SPACE:
flag_pause = False
else:
# Time to change direction
action = 0
if event.key == pygame.K_UP or event.key == pygame.K_w: action = 1
elif event.key == pygame.K_DOWN or event.key == pygame.K_s: action = 2
elif event.key == pygame.K_LEFT or event.key == pygame.K_a: action = 3
elif event.key == pygame.K_RIGHT or event.key == pygame.K_d: action = 4
if action:
self.sounds.play("move")
snake.action(action)
# Snake movements and pavement reactions
snake.move()
pavement.passage(snake.head)
pavement.make_regrow(snake.tail)
# Snake has eaten?
if foods.check(snake.head):
updatestats = True
snake.grow(Constants.GROW)
score.add_score(foods.score)
self.sounds.play("eat")
# Snake
if walls.check(snake.head):
snake.alive = False
# Snake is dead?
if not snake.alive:
#blood splash (bin on head, little on body)
pavement.bloodsplat(snake.head)
[pavement.bloodsplat(x,1) for x in snake.body if random.randint(0,2)==0]
#redraw all the snake
snake.set_dirty(1)
self.sounds.play("splat")
self.running = False
# Gold generator (After pseudo-random time a golden apple will appear)
nextgold-=1
if nextgold<0:
makegold = True
nextgold = random.randint(*Constants.TIMERANGE_GOLD)*Constants.FPS
#.........这里部分代码省略.........
示例4: Game
# 需要导入模块: from score import Score [as 别名]
# 或者: from score.Score import update [as 别名]
#.........这里部分代码省略.........
size=(self.tile_size, self.tile_size),
pos=self.index_to_pos(x, y),
letter=str(value))
self.remove_widget(self.grid[x][y])
self.grid[x][y] = letter
self.add_widget(letter)
def on_touch_down(self, touch):
"""Catches the touch event on the grid.
"""
relative_coordinates = self.to_widget(touch.pos[0], touch.pos[1], True)
x, y = self.pos_to_index(relative_coordinates)
if x is not None and y is not None:
self.toggle(x, y)
super(Game, self).on_touch_down(touch)
return True
def toggle(self, x, y):
game_screen = self.parent.parent.parent
decrement = Clock.create_trigger(game_screen.ids.timer.decrement)
letter = self.letter_grid[x][y]
if letter is not None:
if letter.is_selected():
self.letter_grid.chain.remove(letter)
else:
self.letter_grid.chain.add(letter)
if not self.letter_grid.chain.is_valid():
decrement()
self.letter_grid.chain.clear()
if self.letter_grid.is_complete_chain():
game_screen.ids.timer.reset()
self.update_grid()
def update_grid(self):
for x, y, letter in self.letter_grid.iterate():
if letter.is_selected():
self.grid[x][y].select()
else:
self.grid[x][y].unselect()
def end(self):
"""Shows a Game over screen inspired from 2048
"""
game_screen = self.parent.parent.parent
game_screen.end = True
self.save_highscore()
end = self.ids.end.__self__
self.remove_widget(end)
self.add_widget(end)
text = 'Game\nover!'
self.ids.end_label.text = text
Animation(opacity=1., d=.5).start(end)
def restart(self):
"""Restarts the game. Puts three random letters on the board.
"""
self.score.reset()
self.level.reset()
for ix, iy, child in self.iterate():
self.remove_widget(child)
self.grid = [[None for i in range(GRID_SIZE)] for j in range(GRID_SIZE)]
self.reposition()
self.letter_grid = LetterGrid(GRID_SIZE)
self.letter_grid.setup(3)
示例5: __init__
# 需要导入模块: from score import Score [as 别名]
# 或者: from score.Score import update [as 别名]
class Game:
sky = None
def __init__(self, screen, endless = False):
self.screen = screen
self.sharks = []
self.shark_sprites = pygame.sprite.Group()
self.player = Steamboat()
self.player_sprite = pygame.sprite.Group()
self.player_sprite.add(self.player)
self.health = Health()
self.health_sprite = pygame.sprite.Group()
self.health_sprite.add(self.health)
self.damage_count = 0
self.t = 0
self.water = Water.global_water
#Water.global_water = self.water
self.water_sprite = pygame.sprite.Group()
self.water_sprite.add(self.water)
if not Game.sky:
Game.sky = util.load_image("taivas")
Game.sky = pygame.transform.scale(self.sky, (SCREEN_WIDTH, SCREEN_HEIGHT))
self.cannonballs = []
self.cannonball_sprites = pygame.sprite.Group()
self.pirates = []
self.pirate_sprites = pygame.sprite.Group()
self.titanic = None
self.titanic_sprite = pygame.sprite.Group()
self.seagulls = []
self.seagull_sprites = pygame.sprite.Group()
self.particles = Particles()
self.particle_sprite = pygame.sprite.Group()
self.particle_sprite.add(self.particles)
self.mines = []
self.mine_sprites = pygame.sprite.Group()
self.score = Score()
self.score_sprite = pygame.sprite.Group()
self.score_sprite.add(self.score)
self.powerups = []
self.powerup_sprites = pygame.sprite.Group()
self.level = Level(endless)
self.lastshot = MIN_FIRE_DELAY + 1
self.gameover = False
self.gameover_image = None
self.gameover_rect = None
self.done = False
self.pause = False
self.pause_image = util.bigfont.render("Pause", Variables.alpha, (0,0,0))
self.pause_rect = self.pause_image.get_rect()
self.pause_rect.center = self.screen.get_rect().center
self.spacepressed = None
def run(self):
while not self.done:
if not self.pause:
if not self.gameover:
self.spawn_enemies()
self.update_enemies()
self.player.update()
self.health.update()
cloud.update()
for cb in self.cannonballs:
if not cb.underwater:
#~ particle_point=cb.rect.left, cb.rect.top
particle_point = cb.tail_point()
self.particles.add_trace_particle(particle_point)
particle_point = [particle_point[i] + cb.vect[i]/2 for i in (0,1)]
self.particles.add_trace_particle(particle_point)
if cb.special and (not cb.underwater or rr()>0.6) :
particle_point = cb.tail_point()
self.particles.add_explosion_particle(particle_point)
und_old=cb.underwater
cb.update()
if cb.underwater and not und_old:
for i in xrange(5):
#.........这里部分代码省略.........
示例6: __init__
# 需要导入模块: from score import Score [as 别名]
# 或者: from score.Score import update [as 别名]
class Game:
def __init__(self, screen, usealpha = True, noparticles = False, endless = False):
self.screen = screen
self.usealpha = usealpha
self.noparticles = noparticles
self.sharks = []
self.shark_sprites = pygame.sprite.Group()
self.player = Steamboat()
self.player_sprite = pygame.sprite.Group()
self.player_sprite.add(self.player)
self.health = Health()
self.health_sprite = pygame.sprite.Group()
self.health_sprite.add(self.health)
self.damage_count = 0
self.t = 0
self.water = Water.global_water #Water(self.usealpha)
#Water.global_water = self.water
self.water_sprite = pygame.sprite.Group()
self.water_sprite.add(self.water)
self.sky = util.load_image("taivas")
self.sky = pygame.transform.scale(self.sky, (SCREEN_WIDTH, SCREEN_HEIGHT))
self.pause_icon = util.load_image("pause")
self.cannonballs = []
self.cannonball_sprites = pygame.sprite.Group()
self.pirates = []
self.pirate_sprites = pygame.sprite.Group()
self.titanic = None
self.titanic_sprite = pygame.sprite.Group()
self.seagulls = []
self.seagull_sprites = pygame.sprite.Group()
self.particles = Particles(self.usealpha)
self.particle_sprite = pygame.sprite.Group()
self.particle_sprite.add(self.particles)
self.mines = []
self.mine_sprites = pygame.sprite.Group()
self.score = Score()
self.score_sprite = pygame.sprite.Group()
self.score_sprite.add(self.score)
self.powerups = []
self.powerup_sprites = pygame.sprite.Group()
self.level = Level(endless)
self.cheat_current = 0
self.lastshot = MIN_FIRE_DELAY + 1
self.gameover = False
self.gameover_image = None
self.gameover_rect = None
self.done = False
self.pause = False
font = util.load_font("Cosmetica", 40) #pygame.font.Font(pygame.font.get_default_font(), 36)
self.pause_image = font.render("Pause", True, (0,0,0))
self.pause_rect = self.pause_image.get_rect()
self.pause_rect.center = self.screen.get_rect().center
def run(self):
while not self.done:
util.android_check_pause()
if not self.pause:
if not self.gameover:
self.spawn_enemies()
self.update_enemies()
self.player.update()
self.health.update()
cloud.update()
for cb in self.cannonballs:
cb.update()
if (cb.rect.right < 0 and cb.vect[0] < 0) or (cb.rect.left > SCREEN_WIDTH and cb.vect[0] > 0):
self.cannonballs.remove(cb)
self.cannonball_sprites.remove(cb)
self.score.update()
# Add steam particles
if not self.noparticles:
for i in range(STEAM_3):
particle_point = self.player.get_point((5.0 + random.random() * 9.0, 0))
particle_point[0] += self.player.rect.centerx
particle_point[1] += self.player.rect.centery
self.particles.add_steam_particle(particle_point)
for i in range(STEAM_3):
#.........这里部分代码省略.........
示例7: str
# 需要导入模块: from score import Score [as 别名]
# 或者: from score.Score import update [as 别名]
if event.key == K_w:
paddle1.change_y += 6
elif event.key == K_s:
paddle1.change_y -= 6
elif event.key == K_UP:
paddle2.change_y += 6
elif event.key == K_DOWN:
paddle2.change_y -= 6
# Updates the game objects
for paddle in paddle_list:
paddle.update()
ball.update()
if ball.rect.right >= constants.screen_width or ball.rect.x <= 0:
if ball.change_x >= 0:
paddle1.score += 1
else:
paddle2.score += 1
ball.change_x = 6
ball.change_y = 6
ball.rect.topleft = (random.randint(0, 800), random.randint(0, 600))
if paddle1.score >= 10 or paddle2.score >= 10:
scoreBoard.update(str(paddle1.score) + " | " + str(paddle2.score))
text_functions.showText("Game Over", (constants.screen_width/2, constants.screen_height/2), screen)
pygame.time.wait(500)
pygame.display.update()
terminate()
scoreBoard.update(str(paddle1.score) + " | " + str(paddle2.score))
pygame.display.update()
clock.tick(constants.fps)