本文整理汇总了Python中screen.Screen.to_screen方法的典型用法代码示例。如果您正苦于以下问题:Python Screen.to_screen方法的具体用法?Python Screen.to_screen怎么用?Python Screen.to_screen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类screen.Screen
的用法示例。
在下文中一共展示了Screen.to_screen方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Game
# 需要导入模块: from screen import Screen [as 别名]
# 或者: from screen.Screen import to_screen [as 别名]
class Game(object):
## MAIN GAME CLASS
def __init__(self):
# init pygame and abstract classes
self.clock = pygame.time.Clock()
self.screen = Screen()
self.gamemap = GameMap()
# init game state
self.game_state = 'PREPARING'
# create player paddle and inventory
self.player = Player(100, 50, 50)
self.inventory = Inventory()
# create sprite Groups for game logic
self.player_list = pygame.sprite.Group()
self.weapon_list = pygame.sprite.Group()
self.expReward_list = pygame.sprite.Group()
self.player_list.add(self.player)
# sword swing int
self.sword_count = 0
# invulnerability timer
self.invuln_count = 0
# create rooms
# there has to be a better way
self.rooms = self.gamemap.get_rooms()
self.current_room_num = 0
self.current_room = self.rooms[self.current_room_num]
# define default weapon type
self.combat = Combat(self.player,self.weapon_list,self.current_room.wall_list,
self.current_room.enemy_list, self.current_room.treasure_list, self.expReward_list)
self.run()
def terminate(self):
pygame.quit()
sys.exit()
def run(self):
self.screen.to_screen(self.current_room.wall_list, self.screen.mapSurf)
self.game_state = 'RUNNING'
while 1:
self.clock.tick(60)
# event processing
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.terminate()
if event.type == pygame.KEYDOWN:
self.keyboardDown(event)
if event.type == pygame.KEYUP:
self.keyboardUp(event)
# game logic
if self.game_state == 'RUNNING':
self.gameplay_modelUpdate()
self.gameplay_viewerUpdate(self.screen)
pygame.quit()
def add_treasure(self, treasure):
text = 'You found %s. %s' % (treasure.title, treasure.desc)
self.inventory.add_to_inventory(treasure, self.player)
# self.screen.draw_alert(text)
def blit_alpha(self, target, source, location, opacity):
x = location[0]
y = location[1]
temp = pygame.Surface((source.get_width(), source.get_height())).convert()
temp.blit(target, (-x, -y))
temp.blit(source, (0, 0))
temp.set_alpha(opacity)
target.blit(temp, location)
def keyboardDown(self, evt):
if evt.key == pygame.K_ESCAPE:
self.doMenu()
if self.game_state == 'RUNNING':
if evt.key == pygame.K_LCTRL:
self.combat.weaponSelect()
if evt.key == pygame.K_LEFT:
self.player.change_speed(-5, 0)
if evt.key == pygame.K_RIGHT:
self.player.change_speed(5, 0)
if evt.key == pygame.K_UP:
self.player.change_speed(0, -5)
if evt.key == pygame.K_DOWN:
self.player.change_speed(0, 5)
#.........这里部分代码省略.........